-
Notifications
You must be signed in to change notification settings - Fork 0
245 lines (226 loc) Β· 8.63 KB
/
Copy pathci.yml
File metadata and controls
245 lines (226 loc) Β· 8.63 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: CI
permissions:
contents: read
pull-requests: write
checks: write
# NOTE: intentionally no `paths:` filter. These jobs (test/lint/audit/spec-check)
# are the branch-protection required status checks β a required check that is
# skipped by a path filter never reports, which blocks the PR forever (e.g. a
# docs-only PR). Running the gate on every PR/push is the cost of enforcing it.
# See issue #451. Do not re-add path filters here without also removing these
# jobs from the required-checks list.
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
# Never cancel in-progress runs on main: every merged commit must get a
# completed CI verdict (for bisection and post-merge signal). PR branches
# keep fast-cancel on new pushes.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --verbose --locked
lint:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --check
- run: cargo clippy -- -D warnings
audit:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- run: cargo generate-lockfile
- uses: rustsec/audit-check@v2.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
integration:
name: Integration (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: [test]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build fledge
run: cargo build --release --locked
- name: Add fledge to PATH (unix)
if: runner.os != 'Windows'
run: echo "${{ github.workspace }}/target/release" >> $GITHUB_PATH
- name: Add fledge to PATH (windows)
if: runner.os == 'Windows'
run: echo "${{ github.workspace }}/target/release" >> $env:GITHUB_PATH
- name: Verify fledge runs
run: fledge --version
- name: Run lanes (check)
run: fledge lanes run check
- name: Install default plugins
run: fledge plugins install --defaults --non-interactive
continue-on-error: true
- name: List installed plugins
run: fledge plugins list
- name: Run default plugin - github (smoke test)
run: fledge github --help
continue-on-error: true
- name: Run default plugin - deps (smoke test)
run: fledge deps --help
continue-on-error: true
- name: Run default plugin - metrics
run: fledge metrics
continue-on-error: true
spec-check:
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
body: ${{ steps.specsync.outputs.body }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build the branch Fledge CLI
run: cargo build --locked
- name: Add the branch Fledge CLI to PATH
run: echo "${{ github.workspace }}/target/debug" >> "$GITHUB_PATH"
- name: Run spec-sync
id: specsync
uses: CorvidLabs/spec-sync@342bd053d410211c16fcd041a9eb94ed53012fe2 # v5.2.0
with:
version: 5.2.0
strict: true
comment: false
# Enforce reverse coverage: every production source file must be
# claimed by a spec (test-only + template CI files are excluded in
# .specsync/config.toml). Fails CI if an unclaimed file is added (#448).
require-coverage: 100
lifecycle-enforce: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enforce SpecSync change workspaces
run: specsync change check --strict --require-coverage 100
corvid-pet:
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event_name == 'pull_request' && always()
needs: [test, lint, audit, spec-check, integration]
steps:
- uses: actions/checkout@v5
- name: Determine combined status
id: status
env:
CHECK_TEST: "Tests (3 OS)=${{ needs.test.result }}"
CHECK_INTEGRATION: "Integration (3 OS)=${{ needs.integration.result }}"
CHECK_LINT: "Lint (fmt + clippy)=${{ needs.lint.result }}"
CHECK_SPEC: "Spec Validation=${{ needs.spec-check.result }}"
CHECK_AUDIT: "Dependency Audit=${{ needs.audit.result }}"
REPORT_SPEC: ${{ needs.spec-check.outputs.body }}
run: |
OVERALL="success"
TABLE="| Check | Status |\n|-------|--------|\n"
DETAILS=""
while IFS= read -r line; do
VAR_NAME="${line%%=*}"
VAR_VALUE="${!VAR_NAME}"
LABEL="${VAR_VALUE%%=*}"
RESULT="${VAR_VALUE##*=}"
if [ "$RESULT" = "success" ]; then
ICON="β
Passed"
else
ICON="β ${RESULT}"
OVERALL="failure"
fi
TABLE+="| **${LABEL}** | ${ICON} |\n"
SUFFIX="${VAR_NAME#CHECK_}"
REPORT_VAR="REPORT_${SUFFIX}"
REPORT_VALUE="${!REPORT_VAR}"
if [ -n "$REPORT_VALUE" ]; then
DETAILS+="\n<details>\n<summary>π ${LABEL} Details</summary>\n\n${REPORT_VALUE}\n\n</details>\n"
fi
done < <(env | grep '^CHECK_' | sort)
echo "result=${OVERALL}" >> "$GITHUB_OUTPUT"
{
echo "context<<CONTEXT_EOF"
echo "### CI Summary"
echo ""
echo -e "$TABLE"
if [ -n "$DETAILS" ]; then
echo -e "$DETAILS"
fi
echo "CONTEXT_EOF"
} >> "$GITHUB_OUTPUT"
- uses: CorvidLabs/corvid-pet@v1.0.0
with:
mode: pr-comment
event: auto
pet-name: Corvin
review-on-pr: "true"
context: ${{ steps.status.outputs.context }}
job-status: ${{ steps.status.outputs.result }}
attest:
name: Record attestation
runs-on: ubuntu-latest
needs: [test, lint, audit, spec-check, integration]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# contents: write lets the step push refs/notes/attest.
permissions:
contents: write
steps:
- uses: actions/checkout@v4
# After the gates pass, record a provenance attestation on this commit and
# push it to refs/notes/attest, so fledge builds a trust ledger (and its
# /trust/ attest pip lights). attest ships a public Linux binary
# (checksum-verified), so no token is needed; the step is additive and
# best-effort, so a hiccup logs a warning and never fails CI.
- name: Record attestation (attest)
env:
ATTEST_VERSION: v0.5.0
run: |
base="https://github.com/CorvidLabs/attest/releases/download/${ATTEST_VERSION}"
bin="${RUNNER_TEMP}/attest"; sum="${bin}.sha256"
retry="--retry 5 --retry-connrefused --retry-delay 1"
if curl -fsSL $retry "${base}/attest-linux-x86_64" -o "$bin" \
&& curl -fsSL $retry "${base}/attest-linux-x86_64.sha256" -o "$sum" \
&& want="$(awk '{print $1}' "$sum")" && [ -n "$want" ] \
&& printf '%s %s\n' "$want" "$bin" | sha256sum -c - ; then
chmod +x "$bin"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git fetch origin "+refs/notes/attest:refs/notes/attest" 2>/dev/null || true
if "$bin" sign --commit HEAD --reviewer agent:ci --confidence 0.9 --tests-passed \
--verdict proceed --note "CI: tests + integration + lint + audit + spec-check green" \
&& git push origin refs/notes/attest ; then
echo "attestation recorded for $(git rev-parse --short HEAD)"
else
echo "::warning::attest sign/push failed; provenance not recorded this run"
fi
else
echo "::warning::attest download/verify failed; provenance not recorded this run"
fi