From 7d5059ab45c84fe3dd5414c1e130c06b34c3d525 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Sat, 31 Aug 2024 16:40:51 +0200 Subject: [PATCH] ci: Remove duplicated steps for running tests The environment variable FEATURES sets the set of features used while testing, that makes it possible to have just one step and prevent code duplication. --- .github/workflows/test_rust.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_rust.yml b/.github/workflows/test_rust.yml index 34777e39a..1132a25d6 100644 --- a/.github/workflows/test_rust.yml +++ b/.github/workflows/test_rust.yml @@ -10,6 +10,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + FEATURES: lzma,jpegxr + jobs: changes: name: Paths filter @@ -67,6 +70,11 @@ jobs: if: runner.os == 'Linux' run: echo RUSTFLAGS=${RUSTFLAGS}\ --cfg=web_sys_unstable_apis\ -Clink-args=-znostart-stop-gc >> $GITHUB_ENV + - name: Enable image tests + if: runner.os != 'macOS' + shell: bash + run: echo FEATURES=${FEATURES},imgtests | tee -a $GITHUB_ENV + - name: Cache Cargo output uses: Swatinem/rust-cache@v2 with: @@ -78,9 +86,9 @@ jobs: with: tool: cargo-nextest - - name: Run tests with image tests - if: runner.os != 'macOS' - run: cargo nextest run --profile ci --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features imgtests,lzma,jpegxr + - name: Run tests + shell: bash + run: cargo nextest run --profile ci --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features ${FEATURES} env: # This is to counteract the disabling by rust-cache. # See: https://github.com/Swatinem/rust-cache/issues/43 @@ -93,12 +101,6 @@ jobs: RUSTUP_WINDOWS_PATH_ADD_BIN: '1' XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing - - name: Run tests without image tests - if: runner.os == 'macOS' - run: cargo nextest run --profile ci --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features lzma,jpegxr - env: - XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing - - name: Upload images if: failure() uses: actions/upload-artifact@v4