Skip to content

Commit

Permalink
Merge pull request #1022 from input-output-hk/djo/978/cargo-nextest-i…
Browse files Browse the repository at this point in the history
…n-ci

Use cargo-nextest to run test on CI and reenable tests report
  • Loading branch information
Alenar authored Jun 29, 2023
2 parents 6a7130f + 754771c commit 69c34d7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
12 changes: 12 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## cargo nextest configuration file

[profile.ci]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"
# Do not cancel the test run on the first failure.
fail-fast = false

[profile.ci.junit]
path = "tests-result.junit.xml"
report-name = "mithril-tests"
12 changes: 10 additions & 2 deletions .github/workflows/actions/toolchain-and-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ runs:
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-cache-v${{ inputs.cache-version }}


- name: Install cargo tools installer
uses: taiki-e/install-action@v2
if: inputs.cargo-tools != ''
with:
tool: cargo-binstall

- name: Install cargo tools
if: inputs.cargo-tools != ''
shell: bash
run: |
cargo install ${{ inputs.cargo-tools }} 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
# Sometimes without the `--force` options the installed binaries are not found by cargo
# leading to error such as: `error: no such command: `my-tool``
cargo binstall --force --no-confirm ${{ inputs.cargo-tools }}
20 changes: 9 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,25 @@ jobs:
uses: ./.github/workflows/actions/toolchain-and-cache
with:
cache-version: ${{ secrets.CACHE_VERSION }}
cargo-tools: cargo2junit
cargo-tools: cargo-nextest

- name: Build tests
run: cargo nextest run --no-run ${{ matrix.test-args }}

- name: Run tests
shell: bash
run: |
set -o pipefail && \
cargo test --no-fail-fast ${{ matrix.test-args }}
# TODO: Previous command that uses unstable options which are not supported anymore in stable toolchain
#cargo test --no-fail-fast ${{ matrix.test-args }} \
# -- -Z unstable-options --format json --report-time \
# | tee >(cargo2junit > test-results${{ matrix.artifact-suffix }}-${{ runner.os }}-${{ runner.arch }}.xml)
cargo nextest run --profile ci ${{ matrix.test-args }}
# Rename junit file to include runner info
mv target/nextest/ci/tests-result.junit.xml test-results${{ matrix.artifact-suffix }}-${{ runner.os }}-${{ runner.arch }}.xml
- name: Upload Tests Results
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results${{ matrix.artifact-suffix }}-${{ runner.os }}-${{ runner.arch }}
path: |
./**/test-results-*.xml
./test-results-*.xml
check:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -232,9 +232,7 @@ jobs:
if-no-files-found: error

publish-tests-results:
# TODO: reactivate when cargo test errors export to json works in stable version
#if: success() || failure()
if: false
if: success() || failure()
runs-on: ubuntu-22.04
needs:
- test
Expand Down

0 comments on commit 69c34d7

Please sign in to comment.