GITv
master
ci.yml58 lines, 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: CI

on:
  push:
  pull_request:
  schedule:
    # Weekly, so new advisories against unchanged dependencies still surface.
    - cron: "17 6 * * 1"

permissions:
  contents: read

# Every action is pinned to a commit, not a tag a compromised upstream could move. To update
# one, look up the new release's commit (git ls-remote --tags https://github.com/<owner>/<repo>)
# and change the hash and its comment together.

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    name: Format, lint and test
    runs-on: ubuntu-latest
    # The suite takes seconds; a hang should fail fast rather than run for GitHub's six hours.
    timeout-minutes: 20
    if: github.event_name != 'schedule'
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
      - uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable branch
        with:
          # Pinned to a commit, the action can't read the toolchain from a branch name.
          toolchain: stable
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
      - run: cargo fmt --all --check
      - run: cargo clippy --workspace --all-targets --locked -- -D warnings
      # The integration tests drive real git, rsync, flock and mountpoint, all on the runner.
      # The whole workspace at once: the web tests use the gitv binary too.
      - run: cargo test --workspace --locked

  audit:
    name: Dependency advisories and licences
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
      - uses: taiki-e/install-action@fe3acb53a98b62c772db35de75ce0e4595e7ca8c # v2.90.8
        with:
          # cargo-about is pinned so THIRD-PARTY-LICENSES only changes when dependencies do.
          tool: cargo-audit,cargo-about@0.9.3
      - run: cargo audit
      - name: THIRD-PARTY-LICENSES is current
        run: |
          scripts/third-party-licenses "$RUNNER_TEMP/THIRD-PARTY-LICENSES"
          diff -u THIRD-PARTY-LICENSES "$RUNNER_TEMP/THIRD-PARTY-LICENSES" || {
            echo "::error::THIRD-PARTY-LICENSES is out of date: run scripts/third-party-licenses and commit the result"
            exit 1
          }