From 715c7ddb38bce200d6e53629d718f407a50246e9 Mon Sep 17 00:00:00 2001 From: shun suzuki Date: Sat, 25 Jan 2025 20:16:27 +0900 Subject: [PATCH 1/2] update actions --- .github/workflows/build.yml | 36 +++++++++++++++++++++++++++++ .github/workflows/coverage.yml | 39 -------------------------------- .github/workflows/miri.yml | 3 +-- .github/workflows/pr.yml | 41 ++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f23270c..cff7b5c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,21 @@ jobs: tool: cargo-nextest - run: cargo make check --features "${{ matrix.features }}" + miri: + name: test-with-miri + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: ./.github/actions/setup-build + with: + toolchain: nightly + components: miri + - uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - run: cargo make miri build-docs: name: build-docs @@ -65,3 +80,24 @@ jobs: cargo +nightly docs-rs -pautd3-link-twincat cargo +nightly docs-rs -pautd3-modulation-audio-file cargo +nightly docs-rs -pautd3-protobuf + + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: ./.github/actions/setup-build + with: + components: llvm-tools + - uses: SierraSoftworks/setup-grcov@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: latest + - run: cargo make cov lcov + - uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage + disable_search: true + fail_ci_if_error: true diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 775e9019..00000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Coverage - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -defaults: - run: - shell: bash - -env: - RUSTFLAGS: "-Cinstrument-coverage" - LLVM_PROFILE_FILE: "target/coverage/%p-%m.profraw" - -jobs: - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: ./.github/actions/setup-build - with: - components: llvm-tools - - run: cargo install grcov - - run: | - cargo make cov lcov - - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage - disable_search: true - fail_ci_if_error: true diff --git a/.github/workflows/miri.yml b/.github/workflows/miri.yml index 5fa49b0c..151753b4 100644 --- a/.github/workflows/miri.yml +++ b/.github/workflows/miri.yml @@ -31,5 +31,4 @@ jobs: - uses: taiki-e/install-action@v2 with: tool: cargo-nextest - - run: | - cargo make -e CARGO_TOOLCHAIN=${{ inputs.channel }} miri + - run: cargo make -e CARGO_TOOLCHAIN=${{ inputs.channel }} miri diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 93fb5cbf..b46642b2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -67,6 +67,24 @@ jobs: - if: ${{ needs.test.result == 'failure' || needs.test.result == 'cancelled' }} run: exit 1 + miri: + needs: changed-files + if: ${{ needs.changed-files.outputs.src == 'true' }} + name: test-with-miri + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: ./.github/actions/setup-build + with: + toolchain: nightly + components: miri + - uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - run: cargo make miri + build-docs: needs: changed-files if: ${{ needs.changed-files.outputs.src == 'true' }} @@ -93,10 +111,33 @@ jobs: cargo +nightly docs-rs -pautd3-modulation-audio-file cargo +nightly docs-rs -pautd3-protobuf + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: ./.github/actions/setup-build + with: + components: llvm-tools + - uses: SierraSoftworks/setup-grcov@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: latest + - run: cargo make cov lcov + - uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage + disable_search: true + fail_ci_if_error: true + auto-merge: needs: - all-tests-passed + - miri - build-docs + - coverage permissions: pull-requests: write contents: write From 37ec40e1748e09f44945741cd43963c298732c05 Mon Sep 17 00:00:00 2001 From: shun suzuki Date: Sat, 25 Jan 2025 20:16:31 +0900 Subject: [PATCH 2/2] update `with_parallel_unsafe` test --- autd3/src/datagram/gain/group.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/autd3/src/datagram/gain/group.rs b/autd3/src/datagram/gain/group.rs index 1c4446d1..e307710a 100644 --- a/autd3/src/datagram/gain/group.rs +++ b/autd3/src/datagram/gain/group.rs @@ -319,7 +319,7 @@ mod tests { #[test] fn with_parallel_unsafe() -> anyhow::Result<()> { - let geometry = create_geometry(5); + let geometry = create_geometry(2); let mut rng = rand::thread_rng(); @@ -344,16 +344,13 @@ mod tests { let gain = Group::new(|dev| { let dev_idx = dev.idx(); move |tr| match (dev_idx, tr.idx()) { - (0, 0..=99) => Some("null"), (0, 100..=199) => Some("test"), (1, 200..) => Some("test2"), - (3, _) => Some("test"), _ => None, } }) - .set("null", Null {}.into_boxed())? - .set("test", g1.into_boxed())? - .set("test2", g2.into_boxed())?; + .set("test", g1)? + .set("test2", g2)?; let mut g = gain.init_full(&geometry, None, true)?; let drives = geometry @@ -366,7 +363,7 @@ mod tests { ) }) .collect::>(); - assert_eq!(5, drives.len()); + assert_eq!(2, drives.len()); drives[&0].iter().enumerate().for_each(|(i, &d)| match i { i if i <= 99 => { assert_eq!(Drive::NULL, d); @@ -386,15 +383,6 @@ mod tests { assert_eq!(d2, d); } }); - drives[&2].iter().for_each(|&d| { - assert_eq!(Drive::NULL, d); - }); - drives[&3].iter().for_each(|&d| { - assert_eq!(d1, d); - }); - drives[&4].iter().for_each(|&d| { - assert_eq!(Drive::NULL, d); - }); Ok(()) }