Skip to content

Commit 9cf1e66

Browse files
authored
ci: check obi drift when submodule updated (grafana#2258)
1 parent 7c1ca0c commit 9cf1e66

File tree

6 files changed

+88
-6
lines changed

6 files changed

+88
-6
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: OBI Drift Check
2+
3+
on:
4+
push:
5+
branches: ["main", "release-*"]
6+
paths:
7+
- ".obi-src"
8+
pull_request:
9+
branches: ["main", "release-*"]
10+
paths:
11+
- ".obi-src"
12+
workflow_dispatch:
13+
14+
# Set restrictive permissions at workflow level
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
check-drift:
20+
runs-on: ubuntu-x64-small
21+
permissions:
22+
contents: read
23+
pull-requests: write # Needed for PR comments
24+
steps:
25+
- name: Checkout repo
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
27+
with:
28+
persist-credentials: false
29+
submodules: true # Initialize submodules to get .obi-src content
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
33+
with:
34+
go-version-file: "go.mod"
35+
cache: false # Disable caching to avoid extraction conflicts
36+
37+
- name: Check for OBI drift
38+
id: check-drift
39+
run: |
40+
if ! ./scripts/check-obi-drift.sh; then
41+
echo "drift_detected=true" >> $GITHUB_OUTPUT
42+
exit 1
43+
fi
44+
echo "drift_detected=false" >> $GITHUB_OUTPUT
45+
46+
- name: Comment on PR with instructions
47+
if: github.event_name == 'pull_request' && failure() && steps.check-drift.outputs.drift_detected == 'true'
48+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
49+
with:
50+
script: |
51+
const comment = `## ⚠️ OBI Drift Detected
52+
53+
The \`.obi-src\` submodule has been updated, but there are test functions that have drifted between Beyla and OBI.
54+
55+
### To fix this issue:
56+
57+
1. Run the sync script locally on your branch:
58+
\`\`\`bash
59+
make vendor-obi
60+
./scripts/check-obi-drift.sh --sync
61+
\`\`\`
62+
63+
2. Review the changes:
64+
\`\`\`bash
65+
git diff test/integration/
66+
\`\`\`
67+
68+
3. Commit and push the changes:
69+
\`\`\`bash
70+
git add test/integration/
71+
git commit -m "Sync tests from OBI"
72+
git push
73+
\`\`\`
74+
75+
This check will pass once the drift is resolved.`;
76+
77+
github.rest.issues.createComment({
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
issue_number: context.issue.number,
81+
body: comment
82+
});

.github/workflows/pull_request_integration_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Set up Go
5555
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
5656
with:
57-
go-version: "1.25"
57+
go-version-file: "go.mod"
5858
cache: false
5959

6060
- name: Generate files

.github/workflows/pull_request_k8s_integration_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
- name: Set up Go
5252
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
5353
with:
54-
go-version: "1.25"
54+
go-version-file: "go.mod"
5555
cache: false
5656

5757
- name: Generate files

.github/workflows/pull_request_oats_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Set up Go
5151
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
5252
with:
53-
go-version: "1.25"
53+
go-version-file: "go.mod"
5454
cache: false
5555

5656
- name: Run oats tests

.github/workflows/workflow_integration_tests_vm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
- name: Set up Go
6363
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
6464
with:
65-
go-version: "1.25"
65+
go-version-file: "go.mod"
6666
cache: false
6767

6868
- name: Generate files

scripts/check-obi-drift.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ main() {
163163
local drifted=0
164164

165165
for func in $common_funcs; do
166-
((total++))
166+
total=$((total + 1))
167167
if ! check_drift "$func"; then
168-
((drifted++))
168+
drifted=$((drifted + 1))
169169
fi
170170
done
171171

0 commit comments

Comments
 (0)