name: CI tests on: [push, pull_request] env: SCCACHE_GHA_ENABLED: "true" RUSTC_WRAPPER: "sccache" jobs: build: name: Build project runs-on: ubuntu-latest outputs: rustc_cache_key: ${{ steps.setup_rust.outputs.cachekey }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable id: setup_rust with: components: "rustfmt, clippy" - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: "cargo-base-${{ steps.setup_rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}" restore-keys: | cargo-base-${{ env.RUSTC_CACHEKEY }} - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - run: cargo build --locked --all-targets lint: name: Run lints runs-on: ubuntu-latest needs: build steps: - uses: actions/checkout@v4 - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: "cargo-lint-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}" restore-keys: | cargo-lint-${{ env.RUSTC_CACHEKEY }} cargo-base-${{ env.RUSTC_CACHEKEY }} fail-on-cache-miss: true - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - run: cargo fmt --all -- --check - run: cargo check - run: cargo clippy -- -D warnings pre-commit: name: Run pre-commit runs-on: ubuntu-latest needs: build env: # These hooks are expensive and already run as dedicated jobs above SKIP: "tests,clippy" steps: - uses: actions/checkout@v4 - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: "cargo-lint-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}" restore-keys: | cargo-lint-${{ env.RUSTC_CACHEKEY }} cargo-base-${{ env.RUSTC_CACHEKEY }} fail-on-cache-miss: true - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - uses: actions/setup-python@v4 - name: set PYVERSION run: echo "PYVERSION=$(python --version | tr ' ' '-')" >> $GITHUB_ENV - uses: actions/cache@v3 with: path: ~/.cache/pre-commit # Changes to pre-commit-config.yaml may require the installation of # new binaries/scripts. When a cache hit occurs, changes to the cache # aren't persisted at the end of the run, so making the key dependent # on the configuration file ensures we always persist a complete cache. key: pre-commit-${{ env.PYVERSION }}-${{ hashFiles('.pre-commit-config.yaml') }} - run: pip install pre-commit - run: pre-commit run --all --color=always --show-diff-on-failure test-linux: name: Test on Linux runs-on: ubuntu-latest needs: build steps: - uses: actions/checkout@v4 - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: "cargo-test-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}" restore-keys: | cargo-test-${{ env.RUSTC_CACHEKEY }} cargo-base-${{ env.RUSTC_CACHEKEY }} fail-on-cache-miss: true - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - run: cargo test test-windows: name: Test on Windows runs-on: windows-latest needs: build steps: - run: git config --system core.autocrlf false && git config --system core.eol lf - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable id: setup_rust - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: "cargo-windows-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}" restore-keys: | cargo-windows-${{ env.RUSTC_CACHEKEY }} cargo-base-${{ env.RUSTC_CACHEKEY }} fail-on-cache-miss: true - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - run: cargo test coverage: name: Code coverage runs-on: ubuntu-latest needs: build steps: - uses: actions/checkout@v4 - uses: actions/cache@v3 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: "cargo-coverage-${{ needs.build.outputs.rustc_cache_key }}-${{ hashFiles('**/Cargo.lock') }}" restore-keys: | cargo-coverage-${{ env.RUSTC_CACHEKEY }} cargo-base-${{ env.RUSTC_CACHEKEY }} fail-on-cache-miss: true - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - uses: actions-rs/tarpaulin@v0.1 with: # Constrained by https://github.com/actions-rs/tarpaulin/pull/23 version: "0.22.0" args: "--ignore-tests" out-type: "Html" - uses: actions/upload-artifact@v3 with: name: tarpaulin-report path: tarpaulin-report.html