diff options
-rw-r--r-- | .github/workflows/build.yml | 328 | ||||
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | book/en/src/migration/migration_v5.md | 19 | ||||
-rw-r--r-- | book/ru/src/by-example/tips.md | 4 | ||||
-rw-r--r-- | macros/src/codegen/module.rs | 2 | ||||
-rw-r--r-- | macros/src/codegen/software_tasks.rs | 1 | ||||
-rw-r--r-- | macros/src/codegen/util.rs | 26 | ||||
-rw-r--r-- | src/tq.rs | 1 |
8 files changed, 171 insertions, 217 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2b45c42..923c30f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,8 @@ on: - master - staging - trying + - bors/staging + - bors/trying env: CARGO_TERM_COLOR: always @@ -17,7 +19,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -52,28 +54,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -84,6 +64,9 @@ jobs: - name: Fail on warnings run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: cargo check uses: actions-rs/cargo@v1 with: @@ -91,6 +74,33 @@ jobs: command: check args: --target=${{ matrix.target }} + # Clippy + clippy: + name: Cargo clippy + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-unknown-linux-gnu + override: true + + - name: Fail on warnings + run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: cargo clippy + uses: actions-rs/cargo@v1 + with: + use-cross: false + command: clippy + # Verify all examples, checks checkexamples: name: checkexamples @@ -106,28 +116,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -136,8 +124,10 @@ jobs: override: true components: llvm-tools-preview + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Check the examples - if: matrix.target == 'thumbv7m-none-eabi' uses: actions-rs/cargo@v1 with: use-cross: false @@ -159,28 +149,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -197,6 +165,9 @@ jobs: version: latest use-tool-cache: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Install QEMU run: | sudo apt update @@ -223,28 +194,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -252,6 +201,9 @@ jobs: target: ${{ matrix.target }} override: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Fail on warnings run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs @@ -266,45 +218,20 @@ jobs: testmacros: name: testmacros runs-on: ubuntu-20.04 - strategy: - matrix: - target: - - x86_64-unknown-linux-gnu - toolchain: - - stable steps: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: ${{ matrix.toolchain }} - target: ${{ matrix.target }} + toolchain: stable + target: x86_64-unknown-linux-gnu override: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Fail on warnings run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs @@ -313,84 +240,43 @@ jobs: with: use-cross: false command: test - args: --manifest-path macros/Cargo.toml --target=${{ matrix.target }} + args: --manifest-path macros/Cargo.toml - # Run test suite for thumbv7m + # Run test suite tests: name: tests runs-on: ubuntu-20.04 - strategy: - matrix: - target: - - x86_64-unknown-linux-gnu - toolchain: - - stable steps: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: ${{ matrix.toolchain }} - target: ${{ matrix.target }} + toolchain: stable + target: x86_64-unknown-linux-gnu override: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Fail on warnings + run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs + - uses: actions-rs/cargo@v1 with: use-cross: false command: test - args: --test tests --target=${{ matrix.target }} + args: --test tests # Build documentation, check links docs: name: docs runs-on: ubuntu-20.04 - steps: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - - name: Cache pip installed linkchecker uses: actions/cache@v2 with: @@ -453,15 +339,17 @@ jobs: run: pip install git+https://github.com/linkchecker/linkchecker.git - name: mdBook Action - uses: peaceiris/actions-mdbook@v1.1.13 + uses: peaceiris/actions-mdbook@v1 with: mdbook-version: 'latest' - name: Build book in English - run: cd book/en && mdbook build + shell: 'script --return --quiet --command "bash {0}"' + run: cd book/en && if mdbook build |& tee /dev/tty | grep "\[ERROR\]"; then exit 1; else exit 0; fi - name: Build book in Russian - run: cd book/ru && mdbook build + shell: 'script --return --quiet --command "bash {0}"' + run: cd book/ru && if mdbook build |& tee /dev/tty | grep "\[ERROR\]"; then echo "Russian book needs updating!"; else exit 0; fi - name: Check links run: | @@ -475,13 +363,16 @@ jobs: linkchecker $td/book/en/ linkchecker $td/book/ru/ - # Only runs when pushing to master branch - deploy: - name: deploy + # Update stable branch + # + # This needs to run before book is built + mergetostablebranch: + name: If CI passes, merge master branch into release/vX runs-on: ubuntu-20.04 needs: - style - check + - clippy - checkexamples - testexamples - checkmacros @@ -489,6 +380,39 @@ jobs: - tests - docs - mdbook + + # Only run this when pushing to master branch + if: github.ref == 'refs/heads/master' + steps: + - uses: actions/checkout@v2 + + - name: Get crate version and print output branch release/vX + id: crateversionbranch + # Parse metadata for version number, extract the Semver Major + run: | + VERSION=$(cargo metadata --format-version 1 --no-deps --offline | jq -r '.packages[] | select(.name =="cortex-m-rtic") | .version') + VERSIONMAJOR=${VERSION%.*.*} + echo "branch=release/v$VERSIONMAJOR" >> $GITHUB_ENV + echo "versionmajor=$VERSIONMAJOR" >> $GITHUB_ENV + echo "version=$VERSION" >> $GITHUB_ENV + + - uses: everlytic/branch-merge@1.1.2 + with: + github_token: ${{ github.token }} + source_ref: 'master' + target_branch: ${{ env.branch }} + commit_message_template: '[Bors] Merged {source_ref} into target {target_branch}' + + # Only runs when pushing to master branch + # Bors run CI against staging branch, + # if that succeeds Borst tries against master branch + # If all tests pass, then deploy stage is run + deploy: + name: deploy + runs-on: ubuntu-20.04 + needs: + mergetostablebranch + # Only run this when pushing to master branch if: github.ref == 'refs/heads/master' steps: @@ -507,10 +431,20 @@ jobs: run: python -c "import sys; print(sys.version)" - name: mdBook Action - uses: peaceiris/actions-mdbook@v1.1.13 + uses: peaceiris/actions-mdbook@v1 with: mdbook-version: 'latest' + - name: Get crate version + id: crateversion + # Parse metadata for version number, extract the Semver Major + run: | + VERSION=$(cargo metadata --format-version 1 --no-deps --offline | jq -r '.packages[] | select(.name =="cortex-m-rtic") | .version') + VERSIONMAJOR=${VERSION%.*.*} + echo "branch=release/v$VERSIONMAJOR" >> $GITHUB_ENV + echo "versionmajor=$VERSIONMAJOR" >> $GITHUB_ENV + echo "version=$VERSION" >> $GITHUB_ENV + - name: Remove cargo-config run: rm -f .cargo/config @@ -518,16 +452,17 @@ jobs: run: cargo doc - name: Build books + shell: 'script --return --quiet --command "bash {0}"' run: | langs=( en ru ) devver=( dev ) # The latest stable must be the first element in the array - vers=( 1.0.x 0.5.x 0.4.x ) + vers=( "1" "0.5" "0.4" ) # All releases start with "v" # followed by MAJOR.MINOR.PATCH, see semver.org - # Retain MAJOR.MINOR as $stable - stable=${vers%.*} + # Store first in array as stable + stable=${vers} echo "Stable version: $stable" @@ -544,12 +479,24 @@ jobs: sed "s|URL|$stable|g" redirect.html > $td/index.html # Create the redirects for dev-version - sed 's|URL|rtic/index.html|g' redirect.html > $td/$devver/api/index.html - sed 's|URL|book/en|g' redirect.html > $td/$devver/index.html + # If the current stable and the version being built differ, + # then there is a dev-version and the links should point to it. + if [[ "$stable" != "{{ env.versionmajor }}" ]]; + then + sed 's|URL|rtic/index.html|g' redirect.html > $td/$devver/api/index.html + sed 's|URL|book/en|g' redirect.html > $td/$devver/index.html + else + # If the current stable and the "dev" version in master branch + # share the same major version, redirect dev/ to stable book + sed 's|URL|rtic.rs/$stable/api/rtic|g' redirect.html > $td/$devver/api/index.html + sed 's|URL|rtic.rs/$stable|g' redirect.html > $td/$devver/index.html + fi # Build books for lang in ${langs[@]}; do - ( cd book/$lang && mdbook build ) + ( cd book/$lang && + if mdbook build |& tee /dev/tty | grep "\[ERROR\]"; then exit 1; else exit 0; fi + ) cp -r book/$lang/book $td/$devver/book/$lang cp LICENSE-* $td/$devver/book/$lang/ done @@ -557,11 +504,11 @@ jobs: # Build older versions, including stable root=$(pwd) for ver in ${vers[@]}; do - prefix=${ver%.*} + prefix=${ver} mkdir -p $td/$prefix/book src=$(mktemp -d) - curl -L https://github.com/rtic-rs/cortex-m-rtic/archive/v${ver}.tar.gz | tar xz --strip-components 1 -C $src + curl -L https://github.com/rtic-rs/cortex-m-rtic/archive/release/v${ver}.tar.gz | tar xz --strip-components 1 -C $src pushd $src rm -f .cargo/config @@ -569,7 +516,9 @@ jobs: cp -r target/doc $td/$prefix/api sed 's|URL|rtic/index.html|g' $root/redirect.html > $td/$prefix/api/index.html for lang in ${langs[@]}; do - ( cd book/$lang && mdbook build ) + ( cd book/$lang && + if mdbook build |& tee /dev/tty | grep "\[ERROR\]"; then exit 1; else exit 0; fi + ) cp -r book/$lang/book $td/$prefix/book/$lang cp LICENSE-* $td/$prefix/book/$lang/ done @@ -603,6 +552,7 @@ jobs: needs: - style - check + - clippy - checkexamples - testexamples - checkmacros diff --git a/CHANGELOG.md b/CHANGELOG.md index 112491dd..702d4892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added +- If current $stable and master version matches, dev-book redirects to $stable book +- During deploy stage, merge master branch into current stable IFF cargo package version matches +- Rework branch structure, release/vVERSION +- Cargo clippy in CI +- Use rust-cache Github Action - CI changelog entry enforcer - `examples/periodic-at.rs`, an example of a periodic timer without accumulated drift. - `examples/periodic-at2.rs`, an example of a periodic process with two tasks, with offset timing. Here we depict two alternative usages of the timer type, explicit and trait based. @@ -14,6 +19,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fix dated migration docs for spawn +- Force mdBook to return error codes - Readded missing ramfunc output to book ## [v1.0.0] - 2021-12-25 diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md index e19fb62f..731931f0 100644 --- a/book/en/src/migration/migration_v5.md +++ b/book/en/src/migration/migration_v5.md @@ -316,11 +316,10 @@ mod app { } ``` -## Spawn/schedule from anywhere - -With the new "spawn/schedule from anywhere", old code such as: - +## Spawn from anywhere +With the new spawn/spawn_after/spawn_at interface, +old code requiring the context `cx` for spawning such as: ``` rust #[task(spawn = [bar])] @@ -344,12 +343,20 @@ fn foo(_c: foo::Context) { #[task] fn bar(_c: bar::Context) { - foo::schedule(/* ... */).unwrap(); + // Takes a Duration, relative to “now” + let spawn_handle = foo::spawn_after(/* ... */); +} + +#[task] +fn bar(_c: bar::Context) { + // Takes an Instant + let spawn_handle = foo::spawn_at(/* ... */); } ``` -Note that the attributes `spawn` and `schedule` are no longer needed. +Thus the requirement of having access to the context is dropped. +Note that the attributes `spawn`/`schedule` in the task definition are no longer needed. --- diff --git a/book/ru/src/by-example/tips.md b/book/ru/src/by-example/tips.md index f19cfee9..7d4fc2f4 100644 --- a/book/ru/src/by-example/tips.md +++ b/book/ru/src/by-example/tips.md @@ -83,12 +83,12 @@ $ cargo run --example ramfunc ``` console $ cargo nm --example ramfunc --release | grep ' foo::' -{{#include ../../../../ci/expected/ramfunc.grep.foo}} +{{#include ../../../../ci/expected/ramfunc.run.grep.foo}} ``` ``` console $ cargo nm --example ramfunc --release | grep ' bar::' -{{#include ../../../../ci/expected/ramfunc.grep.bar}} +{{#include ../../../../ci/expected/ramfunc.run.grep.bar}} ``` ## Обходной путь для быстрой передачи сообщений diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 996af641..8410b7d7 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -269,7 +269,7 @@ pub fn codegen( let m_ident = util::monotonic_ident(&monotonic_name); let m_isr = &monotonic.args.binds; let enum_ = util::interrupt_ident(); - let spawn_handle_string = format!("{}::SpawnHandle", m.to_string()); + let spawn_handle_string = format!("{}::SpawnHandle", m); let (enable_interrupt, pend) = if &*m_isr.to_string() == "SysTick" { ( diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 2008b6c9..c767032f 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -38,6 +38,7 @@ pub fn codegen( // Create free queues and inputs / instants buffers let fq = util::fq_ident(name); + #[allow(clippy::redundant_closure)] let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = { ( quote!(rtic::export::SCFQ<#cap_lit_p1>), diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index e8654345..46eace4c 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -16,7 +16,7 @@ pub fn capacity_literal(capacity: usize) -> LitInt { /// Identifier for the free queue pub fn fq_ident(task: &Ident) -> Ident { - mark_internal_name(&format!("{}_FQ", task.to_string())) + mark_internal_name(&format!("{}_FQ", task)) } /// Generates a `Mutex` implementation @@ -103,17 +103,12 @@ pub fn mark_internal_name(name: &str) -> Ident { /// Generate an internal identifier for monotonics pub fn internal_monotonics_ident(task: &Ident, monotonic: &Ident, ident_name: &str) -> Ident { - mark_internal_name(&format!( - "{}_{}_{}", - task.to_string(), - monotonic.to_string(), - ident_name, - )) + mark_internal_name(&format!("{}_{}_{}", task, monotonic, ident_name,)) } /// Generate an internal identifier for tasks pub fn internal_task_ident(task: &Ident, ident_name: &str) -> Ident { - mark_internal_name(&format!("{}_{}", task.to_string(), ident_name)) + mark_internal_name(&format!("{}_{}", task, ident_name)) } fn link_section_index() -> usize { @@ -253,26 +248,19 @@ pub fn monotonic_ident(name: &str) -> Ident { } pub fn static_shared_resource_ident(name: &Ident) -> Ident { - mark_internal_name(&format!("shared_resource_{}", name.to_string())) + mark_internal_name(&format!("shared_resource_{}", name)) } pub fn static_local_resource_ident(name: &Ident) -> Ident { - mark_internal_name(&format!("local_resource_{}", name.to_string())) + mark_internal_name(&format!("local_resource_{}", name)) } pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident { - mark_internal_name(&format!( - "local_{}_{}", - task_name.to_string(), - name.to_string() - )) + mark_internal_name(&format!("local_{}_{}", task_name, name)) } pub fn need_to_lock_ident(name: &Ident) -> Ident { - Ident::new( - &format!("{}_that_needs_to_be_locked", name.to_string()), - name.span(), - ) + Ident::new(&format!("{}_that_needs_to_be_locked", name), name.span()) } /// The name to get better RT flag errors @@ -71,6 +71,7 @@ where } /// Update the instant at an marker value to a new instant + #[allow(clippy::result_unit_err)] pub fn update_marker<F: FnOnce()>( &mut self, marker: u32, |