Skip to content

Commit 0fd90d0

Browse files
committed
GitHub Workflow to verify that the cog-generated code is up-to-date
1 parent d26ef6c commit 0fd90d0

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Summary code generation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
check-generated-code:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
22+
with:
23+
persist-credentials: false
24+
25+
- name: Install cog
26+
run: |
27+
COG_VERSION="v0.0.46"
28+
curl -sSL "https://github.com/grafana/cog/releases/download/${COG_VERSION}/cog_Linux_x86_64.tar.gz" \
29+
| sudo tar -xz -C /usr/local/bin
30+
cog --version
31+
32+
- name: Checkout schemas
33+
run: |
34+
./internal/lib/summary/machinereadable/checkout.sh
35+
36+
- name: Generate code
37+
run: |
38+
./internal/lib/summary/machinereadable/generate.sh
39+
40+
- name: Check for uncommitted changes
41+
run: |
42+
# Check if there are any changes in the Git working directory
43+
if ! git diff --exit-code; then
44+
echo "❌ Generated code is not up-to-date!"
45+
echo ""
46+
echo "The following files have uncommitted changes:"
47+
git diff --name-only
48+
echo ""
49+
echo "Please run the following commands to update the generated code:"
50+
echo " ./internal/lib/summary/machinereadable/checkout.sh"
51+
echo " ./internal/lib/summary/machinereadable/generate.sh"
52+
echo ""
53+
echo "Then commit the changes."
54+
exit 1
55+
fi
56+
57+
# Also check for untracked files
58+
if [ -n "$(git ls-files --others --exclude-standard internal/lib/summary/machinereadable/ | grep -v k6-summary/)" ]; then
59+
echo "❌ There are untracked generated files!"
60+
echo ""
61+
echo "Untracked files:"
62+
git ls-files --others --exclude-standard internal/lib/summary/machinereadable/ | grep -v k6-summary/
63+
echo ""
64+
echo "Please run the generation scripts and commit all generated files."
65+
exit 1
66+
fi
67+
68+
echo "✅ Generated code is up-to-date!"

0 commit comments

Comments
 (0)