ci: Cache xtask and reuse it between jobs

This commit is contained in:
Kévin Commaille 2022-06-14 13:58:46 +02:00 committed by Kévin Commaille
parent f60202c554
commit 191a747541

View File

@ -10,8 +10,37 @@ on:
branches: [main, next] branches: [main, next]
jobs: jobs:
xtask:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Check xtask cache
uses: actions/cache@v3
id: xtask-cache
with:
path: target/debug/xtask
key: xtask-${{ hashFiles('xtask/src/**', 'xtask/Cargo.toml') }}
- name: Install rust stable toolchain
if: steps.xtask-cache.outputs.cache-hit != 'true'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Build
if: steps.xtask-cache.outputs.cache-hit != 'true'
uses: actions-rs/cargo@v1
with:
command: build
args: -p xtask
style: style:
name: Style name: Style
needs: xtask
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo - name: Checkout repo
@ -34,14 +63,18 @@ jobs:
with: with:
crate: cargo-sort crate: cargo-sort
- name: Run lints - name: Get xtask
uses: actions-rs/cargo@v1 uses: actions/cache@v3
with: with:
command: run path: target/debug/xtask
args: -p xtask --no-default-features ci lint key: xtask-${{ hashFiles('xtask/src/**', 'xtask/Cargo.toml') }}
- name: Run lints
run: target/debug/xtask ci lint
msrv: msrv:
name: Rust 1.60 / ${{ matrix.name }} name: Rust 1.60 / ${{ matrix.name }}
needs: xtask
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
@ -86,14 +119,18 @@ jobs:
# fresh cache. # fresh cache.
sharedKey: msrv1.60 sharedKey: msrv1.60
- name: Run checks - name: Get xtask
uses: actions-rs/cargo@v1 uses: actions/cache@v3
with: with:
command: run path: target/debug/xtask
args: -p xtask --no-default-features ci ${{ matrix.cmd }} key: xtask-${{ hashFiles('xtask/src/**', 'xtask/Cargo.toml') }}
- name: Run checks
run: target/debug/xtask ci ${{ matrix.cmd }}
stable: stable:
name: Rust Stable / ${{ matrix.name }} name: Rust Stable / ${{ matrix.name }}
needs: xtask
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
@ -129,14 +166,18 @@ jobs:
- uses: Swatinem/rust-cache@v1 - uses: Swatinem/rust-cache@v1
- name: Run checks - name: Get xtask
uses: actions-rs/cargo@v1 uses: actions/cache@v3
with: with:
command: run path: target/debug/xtask
args: -p xtask --no-default-features ci ${{ matrix.cmd }} key: xtask-${{ hashFiles('xtask/src/**', 'xtask/Cargo.toml') }}
- name: Run checks
run: target/debug/xtask ci ${{ matrix.cmd }}
nightly: nightly:
name: Rust Nightly / ${{ matrix.name }} name: Rust Nightly / ${{ matrix.name }}
needs: xtask
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
@ -173,14 +214,18 @@ jobs:
- uses: Swatinem/rust-cache@v1 - uses: Swatinem/rust-cache@v1
- name: Run checks - name: Get xtask
uses: actions-rs/cargo@v1 uses: actions/cache@v3
with: with:
command: run path: target/debug/xtask
args: -p xtask --no-default-features ci ${{ matrix.cmd }} key: xtask-${{ hashFiles('xtask/src/**', 'xtask/Cargo.toml') }}
- name: Run checks
run: target/debug/xtask ci ${{ matrix.cmd }}
docs: docs:
name: Docs name: Docs
needs: xtask
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo - name: Checkout repo
@ -196,11 +241,14 @@ jobs:
- uses: Swatinem/rust-cache@v1 - uses: Swatinem/rust-cache@v1
- name: Build docs - name: Get xtask
uses: actions-rs/cargo@v1 uses: actions/cache@v3
with: with:
command: run path: target/debug/xtask
args: -p xtask --no-default-features -- doc --deny-warnings key: xtask-${{ hashFiles('xtask/src/**', 'xtask/Cargo.toml') }}
- name: Build docs
run: target/debug/xtask doc --deny-warnings
- name: Deploy to docs branch - name: Deploy to docs branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}