Merge pull request #129 from eirtools/renovate/cargo-llvm-cov-0.x #252
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: CI checks | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| source: | |
| description: Source ref used to build bindings. Uses `github.ref`` by default. | |
| required: false | |
| sha: | |
| description: Source SHA used to build bindings. Uses `github.sha`` by default. | |
| required: false | |
| mutants_force: | |
| type: boolean | |
| description: Run all mutants. | |
| required: false | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - Cargo.toml | |
| - Cargo.lock | |
| - src/** | |
| - tests/** | |
| - .config/nextest.toml | |
| - .github/workflows/ci.yaml | |
| - .github/ci-tools.toml | |
| pull_request: | |
| paths: | |
| - Cargo.toml | |
| - Cargo.lock | |
| - src/** | |
| - tests/** | |
| - .config/nextest.toml | |
| - .github/workflows/ci.yaml | |
| - .github/ci-tools.toml | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: true | |
| env: | |
| COLOR: yes | |
| FORCE_COLOR: 1 | |
| CARGO_TERM_COLOR: always | |
| CARGO_TERM_PROGRESS_WHEN: never | |
| CARGO_INCREMENTAL: 0 | |
| RUST_BACKTRACE: 1 | |
| CARGO_NET_RETRY: 10 | |
| BINSTALL_DISABLE_TELEMETRY: true | |
| permissions: {} | |
| jobs: | |
| ci-build: | |
| name: Build and test | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Rust version | |
| run: | | |
| rustc --version | |
| cargo --version | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: ${{ github.ref == 'refs/heads/main' && 1 || 0 }} | |
| ref: ${{ github.event.inputs.source || github.ref || github.event.ref }} | |
| - name: Cache Cargo | |
| uses: ./.github/actions/cache | |
| - name: Install CLI tools | |
| uses: ./.github/actions/install-tools | |
| with: | |
| default-datasource: crate | |
| - name: Run tests (docs only) | |
| run: | | |
| cargo test --doc | |
| - name: Run tests (no features) | |
| run: | | |
| cargo llvm-cov --no-report nextest --tests --lib -P ci | |
| - name: Run tests (all features) | |
| run: | | |
| cargo llvm-cov --no-report nextest --tests --lib -P ci-all --all-features | |
| - name: Collect coverage | |
| if: ${{ (github.event_name == 'pull_request') && (success() || failure()) }} | |
| run: | | |
| cargo llvm-cov report --output-path target/lcov.info --ignore-filename-regex=src/lib.rs --lcov & | |
| cargo llvm-cov report --output-path target/lcov.xml --ignore-filename-regex=src/lib.rs --cobertura & | |
| wait $(jobs -p) | |
| - name: Collect PR diff | |
| if: ${{ github.ref != 'refs/heads/main' }} | |
| run: | | |
| ./.github/scripts/mut_diff.sh ${{ github.base_ref }} | |
| - name: Collect files | |
| if: ${{ (github.event_name == 'pull_request') && (success() || failure()) }} | |
| run: | | |
| mkdir -p coverage | |
| mv target/lcov.info coverage/ | |
| mv target/lcov.xml coverage/ | |
| mv target/nextest/ci/ci.xml coverage/ | |
| mv target/nextest/ci-all/ci-all.xml coverage/ | |
| mv git.diff coverage/ | |
| - name: Publish test results and coverage | |
| if: ${{ (github.event_name == 'pull_request') && (success() || failure()) }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: coverage | |
| path: coverage | |
| compression-level: 9 | |
| retention-days: 1 | |
| report-test-results: | |
| name: Report test results | |
| permissions: | |
| pull-requests: write # Comment PR | |
| needs: ci-build | |
| if: ${{ (github.event_name == 'pull_request') && (success() || failure()) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: coverage | |
| path: coverage | |
| - name: Report test results | |
| uses: mikepenz/action-junit-report@v6 | |
| with: | |
| comment: true | |
| include_passed: true | |
| report_paths: | | |
| ${{ github.workspace }}/coverage/ci.xml | |
| ${{ github.workspace }}/coverage/ci-all.xml | |
| check_name: | | |
| Deku String | |
| annotate_only: true | |
| report-coverage: | |
| name: Report coverage | |
| permissions: | |
| pull-requests: write # Comment PR | |
| contents: read # Read list of modified files | |
| needs: ci-build | |
| if: ${{ (github.event_name == 'pull_request') && (success() || failure()) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: coverage | |
| path: coverage | |
| - name: Publish coverage report | |
| uses: orgoro/[email protected] | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| coverageFile: ${{ github.workspace }}/coverage/lcov.xml | |
| build-mutants: | |
| name: Run mutants tests | |
| permissions: | |
| contents: read | |
| needs: ci-build | |
| if: ${{ github.event.inputs.mutants_force || github.ref != 'refs/heads/main' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.inputs.source || github.ref || github.event.ref }} | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: coverage | |
| path: coverage | |
| - name: Cache Cargo | |
| uses: ./.github/actions/cache | |
| - name: Install CLI tools | |
| uses: ./.github/actions/install-tools | |
| with: | |
| default-datasource: crate | |
| - name: Run cargo-mutants | |
| run: | | |
| if [[ -f coverage/git.diff ]]; then | |
| cargo mutants --colors=always -vV --in-diff coverage/git.diff; | |
| else | |
| cargo mutants --colors=always -vV; | |
| fi |