Repository navigation
178 lines (166 loc) · 5.78 KB
/
Copy pathci.yml
File metadata and controls
178 lines (166 loc) · 5.78 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: CI
on:
pull_request:
branches: [develop, main]
push:
# A push to develop mostly exists to fill the build cache: a cache written
# inside a pull request is visible to that pull request only, so without a
# run on the base branch no PR could ever restore one. Skip it when only
# documents changed (nothing to cache). Never put paths-ignore under
# pull_request: the required checks must run on every PR.
branches: [develop, main]
paths-ignore:
- '**/*.md'
- 'docs/**'
- 'assets/**'
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
permissions:
contents: read
security-events: write
pull-requests: write
id-token: write
jobs:
# ── Rust ──
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
# Pull requests restore the cache of develop, they do not write their own.
save-if: ${{ github.event_name == 'push' }}
- run: cargo check --all-targets --features tree-sitter
# The release build compiles the model in; keep that code path building.
- name: Check the bundled-model build
run: CORA_BUNDLED_MODEL_DIR="$PWD/tests/fixtures/tiny-model" cargo check --features tree-sitter,bundled-model
# The build without Tree-sitter (regex extraction only) is documented, and it
# had stopped compiling without anyone noticing (#793).
- name: Lint the build without Tree-sitter
run: cargo clippy --all-targets --no-default-features -- -D warnings
- name: Test the build without Tree-sitter
run: cargo test --no-default-features
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
# Pull requests restore the cache of develop, they do not write their own.
save-if: ${{ github.event_name == 'push' }}
- run: cargo clippy --all-targets --features tree-sitter -- -D warnings
audit:
name: Security Audit (CVE)
runs-on: ubuntu-latest
# rustsec/audit-check reports its result as a check run, which needs
# checks: write on push events (pull requests did not need it).
permissions:
contents: read
checks: write
steps:
- uses: actions/checkout@v4
- uses: rustsec/audit-check@858dc40f52ca2b8570b7a997c1c4e35c6fc9a432
with:
token: ${{ secrets.GITHUB_TOKEN }}
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
# Pull requests restore the cache of develop, they do not write their own.
save-if: ${{ github.event_name == 'push' }}
- run: cargo test --features tree-sitter
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
# Pull requests restore the cache of develop, they do not write their own.
save-if: ${{ github.event_name == 'push' }}
- run: cargo build --release --features tree-sitter
# ── Docs (VitePress) ──
docs-build:
name: Website Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
cache-dependency-path: docs/package-lock.json
- run: npm ci
working-directory: docs
- run: npm run docs:build
working-directory: docs
- name: Verify build output
run: |
if [ ! -d "docs/.vitepress/dist" ] || [ -z "$(ls -A docs/.vitepress/dist)" ]; then
echo "::error::Build output is empty or missing."
exit 1
fi
# ── Dependency freshness ──
npm-audit:
name: NPM Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
cache-dependency-path: docs/package-lock.json
- run: npm audit --audit-level=moderate || true
working-directory: docs
cargo-outdated:
name: Cargo Outdated
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# Compiling cargo-outdated took about four minutes on every run and decided
# the wall time of the whole PR. Keep the binary in the cache (refreshed
# weekly) and install it only on a miss; pushes write the cache.
- name: Week of the year
id: week
run: echo "week=$(date +%G-%V)" >> "$GITHUB_OUTPUT"
- name: Restore cargo-outdated
id: tool
uses: actions/cache/restore@v4
with:
path: ~/.cargo/bin/cargo-outdated
key: cargo-outdated-${{ runner.os }}-${{ steps.week.outputs.week }}
- name: Install cargo-outdated
if: steps.tool.outputs.cache-hit != 'true'
run: cargo install cargo-outdated --locked
- name: Save cargo-outdated
if: github.event_name == 'push' && steps.tool.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.cargo/bin/cargo-outdated
key: cargo-outdated-${{ runner.os }}-${{ steps.week.outputs.week }}
- run: cargo outdated || true