on:
push:
pull_request:
schedule:
- cron: '15 3 * * 6'
name: CI
jobs:
update-deps:
name: Update dependencies
runs-on: ubuntu-latest
outputs:
crates-io-index-head: ${{ steps.ls-crates-io-index.outputs.head }}
steps:
- uses: actions/checkout@v2
- id: ls-crates-io-index
name: Get head commit hash of crates.io registry index
shell: bash
run: |
commit=$(
git ls-remote --heads https://github.com/rust-lang/crates.io-index.git master |
cut -f 1
)
echo "$commit"
echo "::set-output name=head::$commit"
- name: Cache cargo registry index
uses: actions/cache@v2
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ steps.ls-crates-io-index.outputs.head }}
restore-keys: cargo-index-
- name: Generate Cargo.lock
run: cargo generate-lockfile
- id: cargo-deps
name: Cache dependency crates
uses: actions/cache@v2
with:
path: ~/.cargo/registry/cache
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
- if: ${{ steps.cargo-deps.outputs.cache-hit != 'true' }}
name: Fetch dependencies
run: cargo fetch --locked
- name: Upload Cargo.lock
uses: actions/upload-artifact@v2
with:
name: lockfile
path: Cargo.lock
test:
name: Test
needs: update-deps
strategy:
matrix:
toolchain: [stable, nightly]
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v2
- name: Download Cargo.lock
uses: actions/download-artifact@v2
with:
name: lockfile
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
- name: Restore cargo registry index
uses: actions/cache@v2
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ needs.update-deps.outputs.crates-io-index-head }}
- name: Restore dependency crates
uses: actions/cache@v2
with:
path: ~/.cargo/registry/cache
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --lib --tests --locked
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --locked
test-release-and-bench:
name: Test and Benchmark (nightly, --release)
needs: update-deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Cargo.lock
uses: actions/download-artifact@v2
with:
name: lockfile
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Restore cargo registry index
uses: actions/cache@v2
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ needs.update-deps.outputs.crates-io-index-head }}
- name: Restore dependency crates
uses: actions/cache@v2
with:
path: ~/.cargo/registry/cache
key: cargo-deps-${{ hashFiles('Cargo.lock') }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-targets --locked
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --release --locked
- name: Run benchmarks
uses: actions-rs/cargo@v1
with:
command: bench
args: --locked