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.
This commit is contained in:
Kamil Jarosz 2024-08-31 16:40:51 +02:00 committed by TÖRÖK Attila
parent a38ae27703
commit 7d5059ab45
1 changed files with 11 additions and 9 deletions

View File

@ -10,6 +10,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
env:
FEATURES: lzma,jpegxr
jobs: jobs:
changes: changes:
name: Paths filter name: Paths filter
@ -67,6 +70,11 @@ jobs:
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: echo RUSTFLAGS=${RUSTFLAGS}\ --cfg=web_sys_unstable_apis\ -Clink-args=-znostart-stop-gc >> $GITHUB_ENV 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 - name: Cache Cargo output
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with: with:
@ -78,9 +86,9 @@ jobs:
with: with:
tool: cargo-nextest tool: cargo-nextest
- name: Run tests with image tests - name: Run tests
if: runner.os != 'macOS' shell: bash
run: cargo nextest run --profile ci --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features imgtests,lzma,jpegxr run: cargo nextest run --profile ci --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features ${FEATURES}
env: env:
# This is to counteract the disabling by rust-cache. # This is to counteract the disabling by rust-cache.
# See: https://github.com/Swatinem/rust-cache/issues/43 # See: https://github.com/Swatinem/rust-cache/issues/43
@ -93,12 +101,6 @@ jobs:
RUSTUP_WINDOWS_PATH_ADD_BIN: '1' RUSTUP_WINDOWS_PATH_ADD_BIN: '1'
XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing 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 - name: Upload images
if: failure() if: failure()
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4