2021-08-13 21:07:47 +00:00
|
|
|
# https://www.infinyon.com/blog/2021/04/github-actions-best-practices/
|
|
|
|
|
|
|
|
name: Test
|
|
|
|
|
|
|
|
on:
|
2023-01-14 18:27:34 +00:00
|
|
|
push:
|
2021-08-13 21:07:47 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
tests:
|
|
|
|
name: Test (${{ matrix.os }})
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, macos-latest]
|
2021-08-15 08:32:46 +00:00
|
|
|
rust: [stable]
|
2021-08-13 21:07:47 +00:00
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
sccache-path: /home/runner/.cache/sccache
|
|
|
|
- os: macos-latest
|
|
|
|
sccache-path: /Users/runner/Library/Caches/Mozilla.sccache
|
|
|
|
env:
|
|
|
|
RUST_BACKTRACE: full
|
|
|
|
RUSTC_WRAPPER: sccache
|
|
|
|
RUSTV: ${{ matrix.rust }}
|
|
|
|
SCCACHE_CACHE_SIZE: 2G
|
|
|
|
SCCACHE_DIR: ${{ matrix.sccache-path }}
|
|
|
|
# SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Install sccache (ubuntu-latest)
|
|
|
|
if: matrix.os == 'ubuntu-latest'
|
|
|
|
env:
|
|
|
|
LINK: https://github.com/mozilla/sccache/releases/download
|
|
|
|
SCCACHE_VERSION: v0.2.15
|
|
|
|
run: |
|
|
|
|
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
|
|
|
|
mkdir -p $HOME/.local/bin
|
|
|
|
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
|
|
|
|
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
|
|
|
|
chmod +x $HOME/.local/bin/sccache
|
|
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- name: Install sccache (macos-latest)
|
|
|
|
if: matrix.os == 'macos-latest'
|
|
|
|
run: |
|
|
|
|
brew update
|
|
|
|
brew install sccache
|
|
|
|
- name: Install Rust ${{ matrix.rust }}
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
profile: minimal
|
|
|
|
override: true
|
|
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache cargo registry
|
|
|
|
uses: actions/cache@v2
|
|
|
|
continue-on-error: false
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cargo-
|
|
|
|
- name: Save sccache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
continue-on-error: false
|
|
|
|
with:
|
|
|
|
path: ${{ matrix.sccache-path }}
|
|
|
|
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-sccache-
|
|
|
|
- name: Start sccache server
|
|
|
|
run: sccache --start-server
|
|
|
|
- name: cargo check
|
|
|
|
run: cargo check --all --all-features --tests
|
|
|
|
- name: cargo test
|
2021-08-16 23:21:08 +00:00
|
|
|
run: cargo test --no-default-features
|
2021-08-13 21:07:47 +00:00
|
|
|
- name: cargo clippy
|
|
|
|
run: cargo clippy --all --all-features --tests
|
|
|
|
- name: cargo fmt
|
|
|
|
run: cargo fmt -- --check
|
|
|
|
- name: Print sccache stats
|
|
|
|
run: sccache --show-stats
|
|
|
|
- name: Stop sccache server
|
|
|
|
run: sccache --stop-server || true
|