-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (67 loc) · 2.47 KB
/
ci.yml
File metadata and controls
81 lines (67 loc) · 2.47 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
repository_dispatch:
types: [contract-updated]
jobs:
check:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Type check
run: npm run check
- name: Run tests with coverage
run: npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
use_oidc: true
files: ./coverage/coverage-final.json
flags: unittests
name: openboot-web-coverage
fail_ci_if_error: false
- name: Build
run: npm run build
- name: Contract schema validation
run: |
git clone --depth 1 https://github.com/openbootdotdev/openboot-contract.git /tmp/contract
pip install jsonschema
python3 -c "
import json, jsonschema, sys
checks = [
('/tmp/contract/schemas/remote-config.json', '/tmp/contract/fixtures/config-v1.json'),
('/tmp/contract/schemas/snapshot.json', '/tmp/contract/fixtures/snapshot-v1.json'),
]
failed = 0
for schema_path, fixture_path in checks:
schema = json.load(open(schema_path))
data = json.load(open(fixture_path))
try:
jsonschema.validate(data, schema)
print(f' ✓ {fixture_path.split(\"/\")[-1]} matches {schema_path.split(\"/\")[-1]}')
except jsonschema.ValidationError as e:
print(f' ✗ {fixture_path.split(\"/\")[-1]}: {e.message}')
failed += 1
# Also validate the packages schema structure against package-metadata expectations
pkg_schema = json.load(open('/tmp/contract/schemas/packages.json'))
required_fields = set(pkg_schema['properties']['packages']['items']['required'])
expected = {'name', 'desc', 'category', 'type', 'installer'}
if required_fields != expected:
print(f' ✗ packages schema required fields mismatch: {required_fields} vs {expected}')
failed += 1
else:
print(f' ✓ packages schema has correct required fields')
sys.exit(1 if failed else 0)
"