/ .github / workflows / check.yml
check.yml
 1  name: Check
 2  
 3  on:
 4    push:
 5      branches: ["master"]
 6    pull_request:
 7  
 8  permissions:
 9    contents: read
10  
11  env:
12    CARGO_TERM_COLOR: always
13    IS_CI: true
14    CLICOLOR: 1
15  
16  jobs:
17    check:
18      name: Check code
19      runs-on: ubuntu-latest
20  
21      steps:
22        - uses: actions/checkout@v4
23  
24        - name: Cache cargo git and registry
25          uses: actions/cache@v4
26          with:
27            path: |
28              ~/.cargo/registry
29              ~/.cargo/git
30            key: ${{ runner.os }}-cargo-git-registry-${{ hashFiles('**/Cargo.lock') }}
31            restore-keys: |
32              ${{ runner.os }}-cargo-git-registry-
33  
34        - name: Cache target dir
35          uses: actions/cache@v4
36          with:
37            path: target
38            key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/*.rs') }}
39            restore-keys: |
40              ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}-
41              ${{ runner.os }}-cargo-target-
42  
43        - name: Install cargo-binstall
44          uses: cargo-bins/cargo-binstall@v1.14.1
45  
46        - name: Install taplo and typos
47          run: |
48            cargo binstall taplo-cli typos-cli --no-confirm
49  
50        - name: Run checks
51          id: check
52          continue-on-error: true
53          run: cargo xtask check
54  
55        - name: How to fix failures
56          if: steps.check.outcome == 'failure'
57          run: |
58            echo "The automated check failed!"
59            echo "To fix, run locally:"
60            echo ""
61            echo "  cargo xtask check"
62            echo ""
63            echo "and push the resulting fixes back to this branch."
64            exit 1