build: cache docker images in ci #62
This file contains 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: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: -D warnings | |
# RUSTDOCFLAGS: -D warnings | |
jobs: | |
check: | |
name: Check | |
timeout-minutes: 2 | |
permissions: | |
# required for ppremk/lfs-warning | |
pull-requests: read | |
# required for LouisBrunner/checks-action | |
checks: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-all-crates: true | |
cache-on-failure: true | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: typos,cargo-deny | |
- name: Check spelling | |
if: success() || failure() | |
id: typos | |
run: typos | |
- name: Check dependencies | |
if: success() || failure() | |
id: cargo-deny | |
run: cargo deny check | |
- name: Check formatting | |
if: success() || failure() | |
id: cargo-fmt | |
run: cargo fmt --all -- --check | |
- name: Check file size | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
id: lfs | |
uses: mahor1221/lfs-warning@master | |
with: | |
filesizelimit: 256000 | |
sendComment: false | |
# create check runs for pull requests | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check file size | |
conclusion: ${{ steps.lfs.outcome }} | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check spelling | |
conclusion: ${{ steps.typos.outcome }} | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check dependencies | |
conclusion: ${{ steps.cargo-deny.outcome }} | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check formatting | |
conclusion: ${{ steps.cargo-fmt.outcome }} | |
check-target: | |
name: Check target | |
timeout-minutes: 2 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu } | |
- { os: ubuntu-latest, target: aarch64-unknown-linux-musl } | |
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu } | |
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl } | |
# - { os: windows-latest, target: aarch64-pc-windows-msvc } | |
# - { os: windows-latest, target: x86_64-pc-windows-msvc } | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-all-crates: true | |
cache-on-failure: true | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- if: startsWith(matrix.target, 'aarch64-unknown-linux-') | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cross | |
# cache cross docker images | |
- uses: ScribeMD/docker-cache@0.5.0 | |
with: | |
key: docker-${{ matrix.target }} | |
- name: Check build | |
if: success() || failure() | |
id: cargo-check | |
run: cargo check --profile=ci --locked --target ${{ matrix.target }} | |
- name: Check lints | |
if: success() || failure() | |
id: cargo-clippy | |
run: cargo clippy --profile=ci --locked --target ${{ matrix.target }} | |
- name: Check tests | |
if: success() | |
id: cargo-test | |
run: | | |
case ${{ matrix.target }} in | |
aarch64-unknown-linux-*) | |
cross test --profile=ci --locked --target ${{ matrix.target }};; | |
*) | |
cargo test --profile=ci --locked --target ${{ matrix.target }};; | |
esac | |
- name: Check documents | |
if: success() | |
id: cargo-doc | |
run: cargo doc --profile=ci --locked --target ${{ matrix.target }} --no-deps | |
# create check runs for pull requests | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check build ${{ matrix.target }} | |
conclusion: ${{ steps.cargo-check.outcome }} | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check lints ${{ matrix.target }} | |
conclusion: ${{ steps.cargo-clippy.outcome }} | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check tests ${{ matrix.target }} | |
conclusion: ${{ steps.cargo-test.outcome }} | |
- uses: LouisBrunner/checks-action@v2.0.0 | |
if: (success() || failure()) && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Check documents ${{ matrix.target }} | |
conclusion: ${{ steps.cargo-doc.outcome }} |