Repository navigation
352 lines (339 loc) · 14.7 KB
/
Copy pathci.yml
File metadata and controls
352 lines (339 loc) · 14.7 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
name: CI
on:
push:
branches: [main, master, "release/**"]
tags: ["v*"]
pull_request:
branches: [main, master, "release/**"]
jobs:
# Local gates only: lint, types, unit/property/REST tests, evals, schema drift.
# Does NOT certify live AKTA / PF / PCS / S3 Object Lock / remote ledger.
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ matrix.python-version }}
- name: Run CI (install, lint, typecheck, unit tests, evals)
run: bash scripts/ci.sh
# Institutional profile: live PostgreSQL always; live PF/PCS/AKTA when sibling
# checkouts / org vars are configured. Fail-closed when SCOPE_REQUIRE_LIVE_CONTRACTS.
#
# Org/repo VARIABLES (see docs/env.institutional.example):
# PF_CORE_REPO | PF_CORE_REPO_CLONE_URL
# PCS_CORE_REPO | PCS_CORE_REPO_CLONE_URL
# AKTA_REPO | AKTA_REPO_CLONE_URL
# PF_CORE_REPO_PATH / PCS_CORE_REPO_PATH / AKTA_REPO_PATH (self-hosted)
# SCOPE_REQUIRE_LIVE_CONTRACTS=true
institutional:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: scope
POSTGRES_PASSWORD: scope
POSTGRES_DB: scope
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U scope -d scope"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Optional sibling checkouts
env:
PF_CORE_REPO: ${{ vars.PF_CORE_REPO }}
PF_CORE_REPO_CLONE_URL: ${{ vars.PF_CORE_REPO_CLONE_URL }}
PCS_CORE_REPO: ${{ vars.PCS_CORE_REPO }}
PCS_CORE_REPO_CLONE_URL: ${{ vars.PCS_CORE_REPO_CLONE_URL }}
AKTA_REPO: ${{ vars.AKTA_REPO }}
AKTA_REPO_CLONE_URL: ${{ vars.AKTA_REPO_CLONE_URL }}
PF_CORE_REPO_PATH_VAR: ${{ vars.PF_CORE_REPO_PATH }}
PCS_CORE_REPO_PATH_VAR: ${{ vars.PCS_CORE_REPO_PATH }}
AKTA_REPO_PATH_VAR: ${{ vars.AKTA_REPO_PATH }}
SCOPE_REQUIRE_LIVE_CONTRACTS: ${{ vars.SCOPE_REQUIRE_LIVE_CONTRACTS }}
run: |
set -euo pipefail
mkdir -p "$HOME/siblings"
resolve_clone() {
local a="${1:-}" b="${2:-}"
if [ -n "$a" ]; then echo "$a"; elif [ -n "$b" ]; then echo "$b"; else echo ""; fi
}
clone_or_path() {
local label="$1" clone_url="$2" path_var="$3" dest="$4" env_name="$5"
if [ -n "$clone_url" ]; then
git clone --depth 1 "$clone_url" "$dest"
echo "${env_name}=$dest" >> "$GITHUB_ENV"
echo "Configured ${env_name} via clone ($label)"
elif [ -n "$path_var" ]; then
echo "${env_name}=$path_var" >> "$GITHUB_ENV"
echo "Configured ${env_name} via pre-mounted path ($label)"
else
echo "No clone URL or path for $label"
if [ "${SCOPE_REQUIRE_LIVE_CONTRACTS:-}" = "true" ] || [ "${SCOPE_REQUIRE_LIVE_CONTRACTS:-}" = "1" ] || [ "${SCOPE_REQUIRE_LIVE_CONTRACTS:-}" = "institutional" ]; then
echo "SCOPE_REQUIRE_LIVE_CONTRACTS requires ${env_name} (set ${label} clone URL or path org var)" >&2
exit 1
fi
fi
}
PF_URL="$(resolve_clone "${PF_CORE_REPO:-}" "${PF_CORE_REPO_CLONE_URL:-}")"
PCS_URL="$(resolve_clone "${PCS_CORE_REPO:-}" "${PCS_CORE_REPO_CLONE_URL:-}")"
AKTA_URL="$(resolve_clone "${AKTA_REPO:-}" "${AKTA_REPO_CLONE_URL:-}")"
clone_or_path "PF_CORE_REPO|PF_CORE_REPO_CLONE_URL" "$PF_URL" "${PF_CORE_REPO_PATH_VAR:-}" "$HOME/siblings/pf-core" "PF_CORE_REPO_PATH"
clone_or_path "PCS_CORE_REPO|PCS_CORE_REPO_CLONE_URL" "$PCS_URL" "${PCS_CORE_REPO_PATH_VAR:-}" "$HOME/siblings/pcs-core" "PCS_CORE_REPO_PATH"
clone_or_path "AKTA_REPO|AKTA_REPO_CLONE_URL" "$AKTA_URL" "${AKTA_REPO_PATH_VAR:-}" "$HOME/siblings/akta" "AKTA_REPO_PATH"
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.12"
- name: Run institutional CI profile
env:
SCOPE_CI_PROFILE: institutional
SCOPE_REQUIRE_LIVE_POSTGRES: "true"
SCOPE_LEDGER_DATABASE_URL: postgresql://scope:scope@localhost:5432/scope
SCOPE_LEDGER_BACKEND: postgres
SCOPE_REQUIRE_LIVE_CONTRACTS: ${{ vars.SCOPE_REQUIRE_LIVE_CONTRACTS }}
run: bash scripts/ci.sh --institutional
# Backward-compatible alias job: live contracts only (no Postgres). Prefer
# the institutional job for full institutional readiness.
live-ecosystem:
runs-on: ubuntu-latest
if: >-
vars.PF_CORE_REPO_PATH != '' ||
vars.PCS_CORE_REPO_PATH != '' ||
vars.AKTA_REPO_PATH != '' ||
vars.SCOPE_REQUIRE_LIVE_CONTRACTS == 'true' ||
vars.PF_CORE_REPO != '' ||
vars.PCS_CORE_REPO != '' ||
vars.AKTA_REPO != '' ||
vars.PF_CORE_REPO_CLONE_URL != '' ||
vars.PCS_CORE_REPO_CLONE_URL != '' ||
vars.AKTA_REPO_CLONE_URL != ''
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Optional sibling checkouts
env:
PF_CORE_REPO: ${{ vars.PF_CORE_REPO }}
PF_CORE_REPO_CLONE_URL: ${{ vars.PF_CORE_REPO_CLONE_URL }}
PCS_CORE_REPO: ${{ vars.PCS_CORE_REPO }}
PCS_CORE_REPO_CLONE_URL: ${{ vars.PCS_CORE_REPO_CLONE_URL }}
AKTA_REPO: ${{ vars.AKTA_REPO }}
AKTA_REPO_CLONE_URL: ${{ vars.AKTA_REPO_CLONE_URL }}
PF_CORE_REPO_PATH_VAR: ${{ vars.PF_CORE_REPO_PATH }}
PCS_CORE_REPO_PATH_VAR: ${{ vars.PCS_CORE_REPO_PATH }}
AKTA_REPO_PATH_VAR: ${{ vars.AKTA_REPO_PATH }}
SCOPE_REQUIRE_LIVE_CONTRACTS: ${{ vars.SCOPE_REQUIRE_LIVE_CONTRACTS }}
run: |
set -euo pipefail
mkdir -p "$HOME/siblings"
resolve_clone() {
local a="${1:-}" b="${2:-}"
if [ -n "$a" ]; then echo "$a"; elif [ -n "$b" ]; then echo "$b"; else echo ""; fi
}
clone_or_path() {
local label="$1" clone_url="$2" path_var="$3" dest="$4" env_name="$5"
if [ -n "$clone_url" ]; then
git clone --depth 1 "$clone_url" "$dest"
echo "${env_name}=$dest" >> "$GITHUB_ENV"
elif [ -n "$path_var" ]; then
echo "${env_name}=$path_var" >> "$GITHUB_ENV"
else
if [ "${SCOPE_REQUIRE_LIVE_CONTRACTS:-}" = "true" ] || [ "${SCOPE_REQUIRE_LIVE_CONTRACTS:-}" = "1" ] || [ "${SCOPE_REQUIRE_LIVE_CONTRACTS:-}" = "institutional" ]; then
echo "SCOPE_REQUIRE_LIVE_CONTRACTS requires ${env_name}" >&2
exit 1
fi
fi
}
PF_URL="$(resolve_clone "${PF_CORE_REPO:-}" "${PF_CORE_REPO_CLONE_URL:-}")"
PCS_URL="$(resolve_clone "${PCS_CORE_REPO:-}" "${PCS_CORE_REPO_CLONE_URL:-}")"
AKTA_URL="$(resolve_clone "${AKTA_REPO:-}" "${AKTA_REPO_CLONE_URL:-}")"
clone_or_path "PF" "$PF_URL" "${PF_CORE_REPO_PATH_VAR:-}" "$HOME/siblings/pf-core" "PF_CORE_REPO_PATH"
clone_or_path "PCS" "$PCS_URL" "${PCS_CORE_REPO_PATH_VAR:-}" "$HOME/siblings/pcs-core" "PCS_CORE_REPO_PATH"
clone_or_path "AKTA" "$AKTA_URL" "${AKTA_REPO_PATH_VAR:-}" "$HOME/siblings/akta" "AKTA_REPO_PATH"
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.12"
- name: Install SCOPE (contracts first)
run: |
python -m pip install --upgrade pip
python -m pip install -e "./scientific-authorization-contracts"
python -m pip install -e ".[dev]"
- name: Enforce institutional live-contract profile
if: vars.SCOPE_REQUIRE_LIVE_CONTRACTS == 'true'
env:
SCOPE_REQUIRE_LIVE_CONTRACTS: "true"
run: |
set -euo pipefail
for var in PF_CORE_REPO_PATH PCS_CORE_REPO_PATH AKTA_REPO_PATH; do
if [ -z "${!var:-}" ] || [ ! -d "${!var}" ]; then
echo "Institutional profile requires $var" >&2
exit 1
fi
done
- name: Live contract tests
env:
SCOPE_REQUIRE_LIVE_CONTRACTS: ${{ vars.SCOPE_REQUIRE_LIVE_CONTRACTS }}
run: pytest tests/test_live_contracts.py -m live_contract -v
# Fail-closed dependency audit on release branches.
dependency-audit:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/release/') || startsWith(github.base_ref, 'release/') || contains(github.ref, 'release/')
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.12"
- name: Install packages then audit
run: |
python -m pip install --upgrade pip
python -m pip install -e "./scientific-authorization-contracts"
python -m pip install -e ".[dev]"
python -m pip install pip-audit
pip-audit --strict
codeql:
runs-on: ubuntu-latest
permissions:
security-events: write
contents: read
actions: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Initialize CodeQL
uses: github/codeql-action/init@a65a038433a26f4363cf9f029e3b9ceac831ad5d # v3.28.10
with:
languages: python
- name: Autobuild
uses: github/codeql-action/autobuild@a65a038433a26f4363cf9f029e3b9ceac831ad5d # v3.28.10
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@a65a038433a26f4363cf9f029e3b9ceac831ad5d # v3.28.10
sbom:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Generate SBOM
uses: anchore/sbom-action@f325610c9f50a54015d37c8d16cb3b0e2c8f4de0 # v0.18.0
with:
path: .
format: spdx-json
output-file: sbom.spdx.json
- name: Upload SBOM artifact
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: sbom-spdx
path: sbom.spdx.json
# Release tags (refs/tags/v*): mandatory gates — not skippable via repo vars.
release-acceptance:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: scope
POSTGRES_PASSWORD: scope
POSTGRES_DB: scope
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U scope -d scope"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.12"
- name: Install SCOPE (contracts first)
run: |
python -m pip install --upgrade pip
python -m pip install -e "./scientific-authorization-contracts"
python -m pip install -e ".[dev,postgres]"
- name: Contract wheel identity
env:
SCOPE_REQUIRE_LIVE_CONTRACTS: "true"
run: pytest tests/test_contract_wheel_identity.py -v
- name: Acceptance suite
run: pytest tests/test_scope_2_2_acceptance.py -v
- name: Live Postgres ledger tests
env:
SCOPE_REQUIRE_LIVE_POSTGRES: "true"
SCOPE_LEDGER_DATABASE_URL: postgresql://scope:scope@localhost:5432/scope
SCOPE_LEDGER_BACKEND: postgres
run: pytest -m live_postgres -v
- name: AKTA wheel interop (fail-closed on tags)
env:
SCOPE_REQUIRE_LIVE_CONTRACTS: "true"
AKTA_REPO_PATH: ${{ vars.AKTA_REPO_PATH }}
AKTA_WHEEL_PATH: ${{ vars.AKTA_WHEEL_PATH }}
run: |
set -euo pipefail
if [ -n "${AKTA_WHEEL_PATH:-}" ] && [ -f "${AKTA_WHEEL_PATH}" ]; then
python -m pip install "${AKTA_WHEEL_PATH}"
fi
pytest tests/test_akta_wheel_interop.py -v
python scripts/run_akta_interop_conformance.py
# SCOPE 2.2: on release tags, force acceptance + wheel identity + interop
# regardless of optional live-ecosystem org vars (fail closed if AKTA missing).
release-gate:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: scope
POSTGRES_PASSWORD: scope
POSTGRES_DB: scope
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U scope -d scope"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: "3.12"
- name: Install contracts then SCOPE
run: |
python -m pip install --upgrade pip
python -m pip install -e "./scientific-authorization-contracts"
python -m pip install -e ".[dev,postgres]"
- name: Contract wheel identity + 2.2 acceptance
run: |
pytest tests/test_contract_wheel_identity.py tests/test_scope_2_2_acceptance.py \
tests/test_operation_covers_properties.py tests/test_control_evidence_fail_closed.py -v
- name: PostgreSQL ledger tests
env:
SCOPE_REQUIRE_LIVE_POSTGRES: "true"
SCOPE_LEDGER_DATABASE_URL: postgresql://scope:scope@localhost:5432/scope
SCOPE_LEDGER_BACKEND: postgres
run: pytest tests/test_postgres_ledger.py -m live_postgres -v || pytest tests -k postgres -v --maxfail=5
- name: Clean-venv package smoke
run: python scripts/check_clean_venv_imports.py
- name: AKTA interop (fail closed on tags)
env:
SCOPE_REQUIRE_AKTA_INTEROP: "release"
run: |
python scripts/run_akta_interop_conformance.py
pytest tests/test_akta_wheel_interop.py -v
- name: Dependency audit
run: |
python -m pip install pip-audit
pip-audit --strict