cargo: update dep versions #1205
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 | |
| on: | |
| push: | |
| branches: ['**'] | |
| paths: | |
| - "Cargo.*" | |
| - "**/*.rs" | |
| - "crates/*/testdata/**" | |
| - ".github/workflows/ci.yml" | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - "Cargo.*" | |
| - "crates/*/src/**" | |
| jobs: | |
| msrv: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.msrv.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Get the minimum supported rust version (MSRV) | |
| id: msrv | |
| run: | | |
| version=$(sed -rn '/^rust-version\s*=/ s/^.*=\s*"([0-9](\.[0-9]+)+)(.*)/\1/p' Cargo.toml) | |
| if [[ -n ${version} ]]; then | |
| echo "version=${version}" >> $GITHUB_OUTPUT | |
| else | |
| exit 1 | |
| fi | |
| test: | |
| needs: msrv | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| rust-version: ${{ needs.msrv.outputs.version }} | |
| - os: ubuntu-latest | |
| rust-version: stable | |
| - os: macos-latest | |
| rust-version: stable | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up rust toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| id: rust | |
| with: | |
| toolchain: ${{ matrix.rust-version }} | |
| components: llvm-tools-preview | |
| - name: Restore cache | |
| uses: actions/cache/restore@v4 | |
| id: restore-cache | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry/index | |
| ~/.cargo/registry/cache | |
| ~/.cargo/git/db | |
| target | |
| key: ${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-rust-${{ steps.rust.outputs.cachekey }}-cargo-${{ hashFiles('Cargo.lock') }} | |
| - name: Remove old caches | |
| if: ${{ matrix.rust-version != 'stable' && github.ref_name == 'main' && steps.restore-cache.outputs.cache-hit != 'true' }} | |
| continue-on-error: true | |
| run: | | |
| gh extension install actions/gh-actions-cache | |
| REPO=${{ github.repository }} | |
| BRANCH=${{ github.ref }} | |
| KEY=${{ github.workflow }}-${{ github.job }}- | |
| # find matching caches | |
| mapfile -t cache_keys < <( gh actions-cache list -R $REPO -B $BRANCH --key $KEY --sort created-at --order desc | cut -f 1 ) | |
| # remove all matching caches | |
| for key in ${cache_keys[@]} | |
| do | |
| gh actions-cache delete $key -R $REPO -B $BRANCH --confirm | |
| done | |
| exit 0 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install cargo-llvm-cov | |
| if: ${{ matrix.rust-version == 'stable' && runner.os == 'Linux' }} | |
| uses: taiki-e/install-action@cargo-llvm-cov | |
| - name: Install cargo-nextest | |
| uses: taiki-e/install-action@nextest | |
| - name: Build and run tests | |
| run: | | |
| # only collect code coverage for the latest rust release on linux | |
| if [[ ${{ matrix.rust-version }} == 'stable' && ${{ runner.os }} == 'Linux' ]]; then | |
| cargo llvm-cov --no-report nextest --features test --workspace --tests | |
| cargo llvm-cov report --lcov --output-path lcov.info | |
| # remove generated coverage data to avoid caching it | |
| find . -name \*.profraw -delete | |
| else | |
| cargo nextest run --features test --workspace --tests | |
| fi | |
| - name: Upload build artifacts | |
| if: ${{ matrix.rust-version == 'stable' && runner.os == 'Linux' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage | |
| path: lcov.info | |
| if-no-files-found: error | |
| retention-days: 3 | |
| - name: Save cache | |
| if: ${{ github.ref_name == 'main' && steps.restore-cache.outputs.cache-hit != 'true' }} | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin | |
| ~/.cargo/registry/index | |
| ~/.cargo/registry/cache | |
| ~/.cargo/git/db | |
| target | |
| key: ${{ steps.restore-cache.outputs.cache-primary-key }} | |
| coverage: | |
| if: ${{ github.ref_name == 'main' }} | |
| needs: test | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage/lcov.info | |
| fail_ci_if_error: true |