-
Notifications
You must be signed in to change notification settings - Fork 13
160 lines (138 loc) · 5.28 KB
/
Copy pathvalidate-release.yml
File metadata and controls
160 lines (138 loc) · 5.28 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
name: Validate Release
on:
pull_request:
branches:
- prod
push:
branches:
- main
permissions:
contents: read
jobs:
validate-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract Node version
id: node-version
run: |
VERSION=$(node -p "require('./node/package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Node version: $VERSION"
- name: Extract Python version
id: python-version
run: |
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' python/pyproject.toml)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Python version: $VERSION"
- name: Ensure versions match
run: |
NODE_VERSION="${{ steps.node-version.outputs.VERSION }}"
PYTHON_VERSION="${{ steps.python-version.outputs.VERSION }}"
if [ "$NODE_VERSION" != "$PYTHON_VERSION" ]; then
echo "Version mismatch: Node=$NODE_VERSION Python=$PYTHON_VERSION"
exit 1
fi
echo "Versions match: $NODE_VERSION"
- name: Ensure ClawHub skill version matches package version
# rf-zgwj — the SKILL.md frontmatter version is what ClawHub publishes
# under. Drift here would silently ship a stale version on the next
# `clawhub skill publish` (publish.yaml). Both the Node and Python
# resource copies must match the package version exactly.
run: |
PACKAGE_VERSION="${{ steps.node-version.outputs.VERSION }}"
for skill_file in node/resources/rafter-security-skill.md python/rafter_cli/resources/rafter-security-skill.md; do
SKILL_VERSION=$(sed -n 's/^version: *\(.*\)$/\1/p' "$skill_file" | head -1 | tr -d ' ')
if [ -z "$SKILL_VERSION" ]; then
echo "FAIL: $skill_file has no top-level 'version:' field"
exit 1
fi
if [ "$SKILL_VERSION" != "$PACKAGE_VERSION" ]; then
echo "FAIL: $skill_file version=$SKILL_VERSION but package=$PACKAGE_VERSION"
echo "Update the version: line in $skill_file to match."
exit 1
fi
echo "OK: $skill_file version matches ($SKILL_VERSION)"
done
- name: Check CHANGELOG updated
run: |
VERSION="${{ steps.node-version.outputs.VERSION }}"
if ! grep -q "\[$VERSION\]" CHANGELOG.md; then
echo "Warning: CHANGELOG.md missing entry for $VERSION"
else
echo "CHANGELOG.md updated for $VERSION"
fi
test-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build Node package
run: |
cd node
corepack enable
corepack prepare pnpm@10 --activate
pnpm install --frozen-lockfile
pnpm run build
pnpm test
# sable-cazq — this job ran `pnpm test` for Node and nothing but a
# wheel build for Python, so the pre-release gate asserted that the
# Python package *compiles*, never that it works. ~80s of pytest is
# the difference between those two claims.
- name: Build and test Python package
run: |
cd python
python -m pip install --upgrade build
python -m build
pip install -e .
pip install pytest pytest-mock pytest-asyncio
python -m pytest tests/ -q
- name: Verify all artifacts
run: |
test -f node/dist/index.js || exit 1
test -f python/dist/*.whl || exit 1
test -f python/dist/*.tar.gz || exit 1
echo "All build artifacts verified"
test-package:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./node
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10 --activate
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Pack
run: npm pack
- name: Verify resources/pre-commit-hook.sh in tarball
run: |
TARBALL=$(ls rafter-security-cli-*.tgz | head -1)
echo "Inspecting: $TARBALL"
tar -tzf "$TARBALL" | grep "resources/pre-commit-hook.sh" \
|| (echo "FAIL: resources/pre-commit-hook.sh not found in tarball" && exit 1)
echo "OK: resources/pre-commit-hook.sh present in tarball"
- name: Test install-hook end-to-end from packed tarball
run: |
TARBALL=$(ls rafter-security-cli-*.tgz | head -1)
npm install -g "./$TARBALL"
rafter --version
TMPDIR=$(mktemp -d)
git init "$TMPDIR"
git -C "$TMPDIR" config user.email "ci@test.local"
git -C "$TMPDIR" config user.name "CI Test"
(cd "$TMPDIR" && rafter agent install-hook)
test -f "$TMPDIR/.git/hooks/pre-commit" \
|| (echo "FAIL: pre-commit hook not installed" && exit 1)
echo "OK: pre-commit hook installed end-to-end"