From 380cc10dc347ef4ce056dacd22a0b96d5b79f1d8 Mon Sep 17 00:00:00 2001 From: DaughterOfMars Date: Tue, 27 Aug 2024 11:42:53 -0400 Subject: [PATCH] chore(CI): Always compile the entire workspace for CI tests (#2028) * chore(CI): Always compile the entire workspace for CI tests * remove changes from udeps * Remove check for empty changes * Try fromJson * remove accidental command * echo * temp * quotes for echo * try building and eval * try quotes * fix exprs * Update mysticeti workflow too * temp2 * Revert "temp" This reverts commit 372e552e132b831b627e466e85db81dc1c2b4751. * Revert "temp2" This reverts commit 5b3933ed6df89024277241870463fd0f8dd0cc62. --------- Co-authored-by: Thibault Martinez --- .github/crates-filters.yml | 2 + .github/workflows/_external_rust_tests.yml | 48 ++++++++----- .github/workflows/_mysticeti_tests.yml | 28 ++++++-- .github/workflows/_rust_tests.yml | 83 ++++++---------------- 4 files changed, 76 insertions(+), 85 deletions(-) diff --git a/.github/crates-filters.yml b/.github/crates-filters.yml index c7934c7d9ac..699375150ce 100644 --- a/.github/crates-filters.yml +++ b/.github/crates-filters.yml @@ -116,6 +116,8 @@ iota-rosetta: - "crates/iota-rosetta/**" iota-rpc-loadgen: - "crates/iota-rpc-loadgen/**" +iota-sdk: + - "crates/iota-sdk/**" iota-simulator: - "crates/iota-simulator/**" iota-single-node-benchmark: diff --git a/.github/workflows/_external_rust_tests.yml b/.github/workflows/_external_rust_tests.yml index 383a5a0b8d2..1476aede848 100644 --- a/.github/workflows/_external_rust_tests.yml +++ b/.github/workflows/_external_rust_tests.yml @@ -25,18 +25,14 @@ jobs: filters: .github/external-crates-filters.yml test: - name: Test ${{ matrix.components }} + name: Test external crates needs: changes - if: always() && inputs.isRust && needs.changes.outputs.components != '[]' + if: always() && inputs.isRust env: # Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var # causes #[sim_test] to only run under the deterministic `simtest` job, and not the # non-deterministic `test` job. IOTA_SKIP_SIMTESTS: 1 - strategy: - matrix: - components: ${{ fromJson(needs.changes.outputs.components) }} - fail-fast: false runs-on: [self-hosted] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 @@ -44,26 +40,42 @@ jobs: - name: Install python dependencies run: pip install pyopenssl --upgrade --break-system-packages - name: cargo test - run: > - cargo nextest run - --config-file .config/nextest.toml - --manifest-path external-crates/move/Cargo.toml - -E '!test(prove) and !test(run_all::simple_build_with_docs/args.txt) and !test(run_test::nested_deps_bad_parent/Move.toml) and rdeps(${{matrix.components}})' - -p ${{matrix.components}} - --profile ci + run: | + array=(${{ join(fromJson(needs.changes.outputs.components), ' ') }}) + + result="" + + for item in "${array[@]}"; do + mapped_item="-E 'rdeps(${item})'" + + if [ -z "$result" ]; then + result="$mapped_item" + else + result="$result $mapped_item" + fi + done + + command="cargo nextest run \ + --config-file .config/nextest.toml \ + --manifest-path external-crates/move/Cargo.toml \ + -E '!test(prove) and !test(run_all::simple_build_with_docs/args.txt) and !test(run_test::nested_deps_bad_parent/Move.toml)' \ + $result \ + --profile ci" + + echo "$command" + + eval ${command} check-unused-deps: - name: Check Unused Dependencies of ${{ matrix.components }} (${{ matrix.flags }}) - if: always() && inputs.isRust && needs.changes.outputs.components != '[]' + name: Check Unused Dependencies (${{ matrix.flags }}) + if: always() && inputs.isRust strategy: matrix: - components: ${{ fromJson(needs.changes.outputs.components) }} flags: ["--all-features", "--no-default-features"] fail-fast: false runs-on: [self-hosted] - needs: changes steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 - name: Run Cargo Udeps - run: cargo +nightly ci-udeps-external -p ${{matrix.components}} ${{ matrix.flags }} + run: cargo +nightly ci-udeps-external ${{ matrix.flags }} diff --git a/.github/workflows/_mysticeti_tests.yml b/.github/workflows/_mysticeti_tests.yml index 88d70cb3c98..a04643ad836 100644 --- a/.github/workflows/_mysticeti_tests.yml +++ b/.github/workflows/_mysticeti_tests.yml @@ -61,25 +61,39 @@ jobs: filters: .github/crates-filters.yml test: - name: Test ${{ matrix.components }} - if: needs.changes.outputs.components != '[]' + name: Test Mysticeti timeout-minutes: 45 env: # Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var # causes #[sim_test] to only run under the deterministic `simtest` job, and not the # non-deterministic `test` job. IOTA_SKIP_SIMTESTS: 1 - strategy: - matrix: - components: ${{ fromJson(needs.changes.outputs.components) }} - fail-fast: false runs-on: [self-hosted] needs: changes steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: taiki-e/install-action@nextest - name: cargo test - run: cargo nextest run --profile ci -E 'rdeps(${{matrix.components}})' -p ${{matrix.components}} + run: | + array=(${{ join(fromJson(needs.changes.outputs.components), ' ') }}) + + result="" + + for item in "${array[@]}"; do + mapped_item="-E 'rdeps(${item})'" + + if [ -z "$result" ]; then + result="$mapped_item" + else + result="$result $mapped_item" + fi + done + + command="cargo nextest run --profile ci $result" + + echo "$command" + + eval ${command} test-extra: timeout-minutes: 45 diff --git a/.github/workflows/_rust_tests.yml b/.github/workflows/_rust_tests.yml index a38d639ade5..daf6ab724bc 100644 --- a/.github/workflows/_rust_tests.yml +++ b/.github/workflows/_rust_tests.yml @@ -25,90 +25,53 @@ jobs: filters: .github/crates-filters.yml test: - name: Test ${{ matrix.components }} + name: Test rust crates needs: changes - if: always() && inputs.isRust && needs.changes.outputs.components != '[]' + if: always() && inputs.isRust env: # Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var # causes #[sim_test] to only run under the deterministic `simtest` job, and not the # non-deterministic `test` job. IOTA_SKIP_SIMTESTS: 1 - strategy: - matrix: - components: ${{ fromJson(needs.changes.outputs.components) }} - fail-fast: false runs-on: [self-hosted] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: taiki-e/install-action@nextest - name: cargo test - run: cargo nextest run --profile ci -E 'rdeps(${{matrix.components}})' -p ${{matrix.components}} + run: | + array=(${{ join(fromJson(needs.changes.outputs.components), ' ') }}) - iota-sdk-changes: - if: inputs.isRust - runs-on: [self-hosted] - outputs: - changed: ${{ steps.filter.outputs.iota-sdk }} - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - iota-sdk: - - "crates/iota-sdk/**" + result="" - test-iota-sdk: - name: Test iota-sdk - if: always() && inputs.isRust && needs.iota-sdk-changes.outputs.changed == 'true' - env: - # Tests written with #[sim_test] are often flaky if run as #[tokio::test] - this var - # causes #[sim_test] to only run under the deterministic `simtest` job, and not the - # non-deterministic `test` job. - IOTA_SKIP_SIMTESTS: 1 - runs-on: [self-hosted] - needs: iota-sdk-changes - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: taiki-e/install-action@nextest - - name: cargo test - # iota-sdk version needs to be explicitly defined here due to this bug - # https://github.com/rust-lang/cargo/issues/12891 - # (we have the stardust iota-sdk package as a dependency) - run: cargo nextest run --profile ci -E 'rdeps(iota-sdk)' -p iota-sdk@0.1.6 + for item in "${array[@]}"; do + mapped_item="-E 'rdeps(${item})'" + + if [ -z "$result" ]; then + result="$mapped_item" + else + result="$result $mapped_item" + fi + done + + command="cargo nextest run --profile ci $result" + + echo "$command" + + eval ${command} check-unused-deps: - name: Check Unused Dependencies of ${{ matrix.components }} (${{ matrix.flags }}) - if: always() && inputs.isRust && needs.changes.outputs.components != '[]' + name: Check Unused Dependencies (${{ matrix.flags }}) + if: always() && inputs.isRust strategy: matrix: - components: ${{ fromJson(needs.changes.outputs.components) }} flags: ["--all-features", "--no-default-features"] fail-fast: false runs-on: [self-hosted] - needs: changes - - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 - - name: Run Cargo Udeps - run: cargo +nightly ci-udeps -p ${{matrix.components}} ${{ matrix.flags }} - - check-unused-deps-iota-sdk: - name: Check Unused Dependencies of iota-sdk (${{ matrix.flags }}) - if: always() && inputs.isRust && needs.iota-sdk-changes.outputs.changed == 'true' - runs-on: [self-hosted] - needs: iota-sdk-changes - strategy: - matrix: - flags: ["--all-features", "--no-default-features"] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 - # iota-sdk version needs to be explicitly defined here due to this bug - # https://github.com/rust-lang/cargo/issues/12891 - # (we have the stardust iota-sdk package as a dependency) - name: Run Cargo Udeps - run: cargo +nightly ci-udeps -p iota-sdk@0.1.6 ${{ matrix.flags }} + run: cargo +nightly ci-udeps ${{ matrix.flags }} test-extra: env: