Repository navigation
180 lines (177 loc) · 9.04 KB
/
Copy pathci.yml
File metadata and controls
180 lines (177 loc) · 9.04 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
name: GuardEngine CI
on:
push:
pull_request:
jobs:
rust:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets -- -D warnings
- run: cargo test --all-targets
- name: Verify shared installer formatting
run: cargo fmt --manifest-path crates/guard-install/Cargo.toml -- --check
- name: Check shared installer
run: cargo clippy --manifest-path crates/guard-install/Cargo.toml --all-targets --features test-fixture -- -D warnings
- name: Test shared installer
run: cargo test --manifest-path crates/guard-install/Cargo.toml --locked --features test-fixture
- name: Verify shared evidence formatting
run: cargo fmt --manifest-path crates/guard-evidence/Cargo.toml -- --check
- name: Check shared evidence
run: cargo clippy --manifest-path crates/guard-evidence/Cargo.toml --locked --all-targets -- -D warnings
- name: Test shared evidence
run: cargo test --manifest-path crates/guard-evidence/Cargo.toml --locked
- name: Verify protocol formatting
run: cargo fmt --manifest-path crates/guard-protocol/Cargo.toml -- --check
- name: Check protocol
run: cargo clippy --manifest-path crates/guard-protocol/Cargo.toml --locked --all-targets -- -D warnings
- name: Test protocol
run: cargo test --manifest-path crates/guard-protocol/Cargo.toml --locked
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Compare JCS bytes with ECMAScript
env:
CARGO_TARGET_DIR: target/protocol
run: |
cargo build --manifest-path crates/guard-protocol/Cargo.toml --locked --example canonicalize
node crates/guard-protocol/scripts/verify_jcs_ecmascript.mjs target/protocol/debug/examples/canonicalize
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Test offline skill bundles
run: python -B -m unittest discover -s scripts/tests -p test_skill_bundle.py
- name: Verify protocol schemas
run: python -B crates/guard-protocol/scripts/generate_schemas.py --check
- name: Test delivery inventory validator
run: python -B -m unittest discover -s scripts/tests -p test_delivery_inventory.py
- name: Test restricted OPA CI preparation
run: python -B -m unittest discover -s scripts/tests -p test_prepare_ci_opa.py
kernel-components:
name: ${{ matrix.component }} / ${{ matrix.os }} / MSRV
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-latest]
component: [guard-contract, guard-subject, guard-store, guard-plan, guard-runner, guard-run-ledger, guard-runtime, guard-policy, guard-authority, guard-cli]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/[email protected]
with:
components: rustfmt, clippy
- name: Verify component formatting
run: cargo fmt --manifest-path crates/${{ matrix.component }}/Cargo.toml -- --check
- name: Check component
if: matrix.component != 'guard-policy' && matrix.component != 'guard-cli'
run: cargo clippy --manifest-path crates/${{ matrix.component }}/Cargo.toml --locked --all-features --all-targets -- -D warnings
- name: Test component with real local tools and storage
if: matrix.component != 'guard-policy' && matrix.component != 'guard-authority' && matrix.component != 'guard-cli'
run: cargo test --manifest-path crates/${{ matrix.component }}/Cargo.toml --locked --all-features
- name: Test independent approvals with real Git and SQLite
if: matrix.component == 'guard-authority'
run: cargo test --manifest-path crates/guard-authority/Cargo.toml --locked --all-features -- --test-threads=1
- name: Check default policy interfaces
if: matrix.component == 'guard-policy'
run: cargo clippy --manifest-path crates/guard-policy/Cargo.toml --locked --all-targets -- -D warnings
- name: Test default policy interfaces (real OPA has separate required job)
if: matrix.component == 'guard-policy'
run: cargo test --manifest-path crates/guard-policy/Cargo.toml --locked
- name: Check production CLI without fixture configuration
if: matrix.component == 'guard-cli'
run: cargo clippy --manifest-path crates/guard-cli/Cargo.toml --locked --all-targets -- -D warnings
- name: Test production CLI discovery and missing-host behavior
if: matrix.component == 'guard-cli'
run: cargo test --manifest-path crates/guard-cli/Cargo.toml --locked
real-opa:
name: Real OPA / ${{ matrix.os }} / MSRV
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
env:
CARGO_TERM_COLOR: always
PYTHONDONTWRITEBYTECODE: '1'
steps:
- uses: actions/checkout@v4
with:
path: guardengine
# 首次发布须先有core准备器,再发布Flow包,然后重跑本job;无缺依赖回退或skip。
- uses: actions/checkout@v4
with:
repository: full-stack-plugins/flowguard
ref: main
path: flowguard
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- uses: dtolnay/[email protected]
with:
components: rustfmt, clippy
- name: Create job-local policy paths
shell: python
run: |
import os, shutil
from pathlib import Path
state = Path(os.environ['RUNNER_TEMP']) / 'guardengine-real-opa'
state.mkdir(mode=0o700)
for name in ['tmp', 'tools', 'cargo-home', 'target']:
(state / name).mkdir(mode=0o700)
executable = state / 'tools' / ('opa.exe' if os.name == 'nt' else 'opa')
values = {
'GUARD_POLICY_OPA_EXECUTABLE': str(executable),
'GUARD_POLICY_FLOWGUARD_PACKAGE': str(Path(os.environ['GITHUB_WORKSPACE']) / 'flowguard/policy/engineering-gate/v1'),
'GUARD_POLICY_FLOWGUARD_CASES': str(state / 'flowguard-policy-cases.json'),
'CARGO_HOME': str(state / 'cargo-home'),
'CARGO_TARGET_DIR': str(state / 'target'),
'TEMP': str(state / 'tmp'),
'TMP': str(state / 'tmp'),
'TMPDIR': str(state / 'tmp'),
'GUARDCORE_TEST_HOST_ROOT': str(state / 'guardcore-test-host'),
'GUARDCORE_TEST_GIT_EXE': str(Path(shutil.which('git') or '').resolve()),
}
assert shutil.which('git'), 'real Git is required for CLI integration'
with open(os.environ['GITHUB_ENV'], 'a', encoding='utf-8') as output:
for key, value in values.items():
output.write(f'{key}={value}\n')
- name: Test restricted OPA preparation
run: python -B guardengine/scripts/tests/test_prepare_ci_opa.py
- name: Prepare fixed official OPA and independent cases
shell: python
run: |
import json, os, subprocess, sys
from pathlib import Path
observed = subprocess.run([
sys.executable, '-B', 'guardengine/scripts/prepare_ci_opa.py',
'--output', os.environ['GUARD_POLICY_OPA_EXECUTABLE'],
], check=True, capture_output=True, text=True, timeout=240)
metadata = json.loads(observed.stdout)
assert metadata['version'] == '1.21.2'
assert Path(metadata['path']).resolve() == Path(os.environ['GUARD_POLICY_OPA_EXECUTABLE']).resolve()
with open(os.environ['GITHUB_ENV'], 'a', encoding='utf-8') as output:
output.write(f"GUARD_POLICY_OPA_SHA256={metadata['sha256']}\n")
subprocess.run([
sys.executable, '-B', 'flowguard/tests/policy_gate.py',
'--export-cases', os.environ['GUARD_POLICY_FLOWGUARD_CASES'],
], check=True)
print(json.dumps(metadata))
- name: Check policy including real-tool tests
working-directory: guardengine
run: cargo clippy --manifest-path crates/guard-policy/Cargo.toml --locked --all-targets --features real-opa-tests -- -D warnings
- name: Run real OPA, bound-plan, recovery and independent FlowGuard differential tests
working-directory: guardengine
run: cargo test --manifest-path crates/guard-policy/Cargo.toml --locked --features real-opa-tests -- --test-threads=1 --nocapture
- name: Check complete CLI integration with fixed test host
working-directory: guardengine
run: cargo clippy --manifest-path crates/guard-cli/Cargo.toml --locked --all-features --all-targets -- -D warnings
- name: Exercise six CLI groups with real Git, SQLite, signatures and OPA
working-directory: guardengine
run: cargo test --manifest-path crates/guard-cli/Cargo.toml --locked --features test-fixture --test real -- --test-threads=1 --nocapture