diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9213705d85c1..550e16b96e3b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,10 +55,33 @@ jobs: # Only check cargo lib for now - run: cargo clippy -p cargo --lib -- -D warnings + # Generate strategy matrix for different platforms and channels + # (see ci/matrix.json) + matrix: + runs-on: ubuntu-latest + needs: + - channel + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - name: Generate strategy matrix + id: matrix + run: | + CHANNEL=${{ needs.channel.outputs.CHANNEL }} + MATRIX=$( + jq --arg C "$CHANNEL" 'map (. | + if ($C == "beta") then select(.rust | startswith("nightly") | not) + elif ($C == "stable") then select(.rust | startswith("stable")) + else . end)' ci/matrix.json + ) + echo "$MATRIX" + echo "MATRIX={\"include\":$(echo $MATRIX)}" >> "$GITHUB_OUTPUT" + test: runs-on: ${{ matrix.os }} needs: - - channel + - matrix env: CARGO_PROFILE_DEV_DEBUG: 1 CARGO_PROFILE_TEST_DEBUG: 1 @@ -67,82 +90,37 @@ jobs: # Deny warnings on CI to avoid warnings getting into the codebase. RUSTFLAGS: -D warnings strategy: - matrix: - include: - - name: Linux x86_64 stable - os: ubuntu-latest - rust: stable - other: i686-unknown-linux-gnu - if: always() - - name: Linux x86_64 beta - os: ubuntu-latest - rust: beta - other: i686-unknown-linux-gnu - if: ${{ needs.channel.outputs.CHANNEL == 'beta' || needs.channel.outputs.CHANNEL == 'nightly' }} - - name: Linux x86_64 nightly - os: ubuntu-latest - rust: nightly - other: i686-unknown-linux-gnu - if: ${{ needs.channel.outputs.CHANNEL == 'nightly' }} - - name: macOS x86_64 stable - os: macos-latest - rust: stable - other: x86_64-apple-ios - if: always() - - name: macOS x86_64 nightly - os: macos-latest - rust: nightly - other: x86_64-apple-ios - if: ${{ needs.channel.outputs.CHANNEL == 'nightly' }} - - name: Windows x86_64 MSVC stable - os: windows-latest - rust: stable-msvc - other: i686-pc-windows-msvc - if: always() - - name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite - os: windows-latest - rust: nightly-gnu - other: i686-pc-windows-gnu - if: ${{ needs.channel.outputs.CHANNEL == 'nightly' }} + matrix: ${{ fromJSON(needs.matrix.outputs.MATRIX) }} name: Tests ${{ matrix.name }} steps: - uses: actions/checkout@v3 - if: matrix.if - name: Dump Environment run: ci/dump-environment.sh - if: matrix.if - name: Update Rustup (temporary workaround) run: rustup self update shell: bash - if: matrix.if && startsWith(matrix.os, 'windows') + if: startsWith(matrix.os, 'windows') - run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }} - if: matrix.if - run: rustup target add ${{ matrix.other }} - if: matrix.if - run: rustup component add rustc-dev llvm-tools-preview rust-docs - if: matrix.if && startsWith(matrix.rust, 'nightly') + if: startsWith(matrix.rust, 'nightly') - run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y - if: matrix.if && matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' - run: rustup component add rustfmt || echo "rustfmt not available" - if: matrix.if - name: Configure extra test environment run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV - if: matrix.if && matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' - run: cargo test - if: matrix.if - name: Clear intermediate test output run: ci/clean-test-output.sh - if: matrix.if - name: gitoxide tests (all git-related tests) run: cargo test git env: __CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2: 1 - if: matrix.if # The testsuite generates a huge amount of data, and fetch-smoke-test was # running out of disk space. - name: Clear test output run: ci/clean-test-output.sh - if: matrix.if - name: Check operability of rustc invocation with argfile env: __CARGO_TEST_FORCE_ARGFILE: 1 @@ -150,29 +128,21 @@ jobs: # This only tests `cargo fix` because fix-proxy-mode is one of the most # complicated subprocess management in Cargo. cargo test --test testsuite -- fix:: - if: matrix.if - run: cargo test --manifest-path crates/cargo-test-support/Cargo.toml env: CARGO_TARGET_DIR: target - if: matrix.if - run: cargo test -p cargo-test-support - if: matrix.if - run: cargo test -p cargo-platform - if: matrix.if - run: cargo test -p cargo-util - if: matrix.if - run: cargo test --manifest-path crates/home/Cargo.toml - if: matrix.if - run: cargo test --manifest-path crates/mdman/Cargo.toml - if: matrix.if - run: cargo build --manifest-path crates/credential/cargo-credential-1password/Cargo.toml - if: matrix.if - run: cargo build --manifest-path crates/credential/cargo-credential-gnome-secret/Cargo.toml - if: matrix.if && matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' - run: cargo build --manifest-path crates/credential/cargo-credential-macos-keychain/Cargo.toml - if: matrix.if && matrix.os == 'macos-latest' + if: matrix.os == 'macos-latest' - run: cargo build --manifest-path crates/credential/cargo-credential-wincred/Cargo.toml - if: matrix.if && matrix.os == 'windows-latest' + if: matrix.os == 'windows-latest' - name: Check benchmarks env: # Share the target dir to try to cache a few build-time deps. @@ -182,15 +152,12 @@ jobs: # download all workspaces. cargo test --manifest-path benches/benchsuite/Cargo.toml --all-targets -- cargo cargo check --manifest-path benches/capture/Cargo.toml - if: matrix.if # The testsuite generates a huge amount of data, and fetch-smoke-test was # running out of disk space. - name: Clear benchmark output run: ci/clean-test-output.sh - if: matrix.if - name: Fetch smoke test run: ci/fetch-smoke-test.sh - if: matrix.if resolver: runs-on: ubuntu-latest diff --git a/ci/matrix.json b/ci/matrix.json new file mode 100644 index 000000000000..f325caefd123 --- /dev/null +++ b/ci/matrix.json @@ -0,0 +1,44 @@ +[ + { + "name": "Linux x86_64 stable", + "os": "ubuntu-latest", + "rust": "stable", + "other": "i686-unknown-linux-gnu" + }, + { + "name": "Linux x86_64 beta", + "os": "ubuntu-latest", + "rust": "beta", + "other": "i686-unknown-linux-gnu" + }, + { + "name": "Linux x86_64 nightly", + "os": "ubuntu-latest", + "rust": "nightly", + "other": "i686-unknown-linux-gnu" + }, + { + "name": "macOS x86_64 stable", + "os": "macos-latest", + "rust": "stable", + "other": "x86_64-apple-ios" + }, + { + "name": "macOS x86_64 nightly", + "os": "macos-latest", + "rust": "nightly", + "other": "x86_64-apple-ios" + }, + { + "name": "Windows x86_64 MSVC stable", + "os": "windows-latest", + "rust": "stable-msvc", + "other": "i686-pc-windows-msvc" + }, + { + "name": "Windows x86_64 gnu nightly", + "os": "windows-latest", + "rust": "nightly-gnu", + "other": "i686-pc-windows-gnu" + } +]