Skip to content

Commit 6b792b8

Browse files
author
Nathan Gillett
committed
Add SOURCE_REF and CI check for tuple bookkeeping
Fail CI when HEAD diverges from SOURCE_REF so spec pins/matrix can record the SDK commit in the ecosystem tuple.
1 parent 4ef01d2 commit 6b792b8

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
with:
4242
go-version-file: go.mod
4343

44+
- name: Verify SOURCE_REF matches this commit
45+
run: bash scripts/check-source-ref.sh
46+
4447
- name: go build
4548
run: go build ./...
4649

SOURCE_REF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4ef01d2cc3d3dfc8f531d97b8cdae67adfe3a68e

scripts/check-source-ref.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
# Fail when SOURCE_REF does not match the current commit (tuple bookkeeping).
3+
set -euo pipefail
4+
5+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6+
cd "$ROOT"
7+
8+
if [[ ! -f SOURCE_REF ]]; then
9+
echo "Missing SOURCE_REF in repository root" >&2
10+
exit 2
11+
fi
12+
13+
HEAD="$(git rev-parse HEAD)"
14+
REF="$(tr -d '[:space:]' < SOURCE_REF)"
15+
if ! echo "$REF" | grep -qE '^[0-9a-f]{40}$'; then
16+
echo "Invalid SOURCE_REF: must be a 40-character lowercase git SHA" >&2
17+
exit 1
18+
fi
19+
20+
if [[ "$HEAD" != "$REF" ]]; then
21+
echo "FAIL: SOURCE_REF ($REF) does not match HEAD ($HEAD)" >&2
22+
echo "Update SOURCE_REF and bump spec matrix/pins after merging SDK changes." >&2
23+
exit 1
24+
fi
25+
26+
echo "PASS: SOURCE_REF matches HEAD ($HEAD)."

0 commit comments

Comments
 (0)