Skip to content

Commit 41995f9

Browse files
committed
ci: Add check-oci-references.sh
1 parent e2b7b24 commit 41995f9

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

.github/workflows/check.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,20 @@ jobs:
114114
git diff
115115
exit 1
116116
fi
117+
118+
check-oci-references:
119+
runs-on: ubuntu-24.04
120+
steps:
121+
- uses: actions/checkout@v4
122+
123+
- uses: nixbuild/nix-quick-install-action@v30
124+
with:
125+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
126+
nix_conf: |
127+
extra-substituters = https://cache.garnix.io
128+
extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g
129+
- name: Populate the nix store
130+
run: |
131+
nix develop --command echo
132+
133+
- run: nix develop --command ./scripts/ci/check-oci-references.sh

scripts/ci/check-oci-references.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
3+
set -exuo pipefail
4+
cd "$(dirname "$0")/../.."
5+
6+
# Configuration
7+
SOURCE_FILE="obelisk-external.toml"
8+
TARGET_FILES=("obelisk-local-postgres.toml" "obelisk-local.toml" "obelisk-oci.toml")
9+
10+
# Initialize fail flag
11+
EXIT_CODE=0
12+
13+
# Check if source file exists
14+
if [ ! -f "$SOURCE_FILE" ]; then
15+
echo "Error: Source file '$SOURCE_FILE' not found."
16+
exit 1
17+
fi
18+
19+
echo "Reading references from $SOURCE_FILE..."
20+
21+
# Extract OCI values using grep and awk
22+
# 1. grep 'location.oci': gets the relevant lines
23+
# 2. awk -F'"': splits by quote and prints the 2nd column (the content inside quotes)
24+
REFERENCES=$(grep 'location.oci' "$SOURCE_FILE" | awk -F'"' '{print $2}')
25+
26+
# Check if we found any references
27+
if [ -z "$REFERENCES" ]; then
28+
echo "No 'location.oci' entries found in source file."
29+
exit 0
30+
fi
31+
32+
# Iterate over each OCI reference found in the external config
33+
for OCI_REF in $REFERENCES; do
34+
echo "---------------------------------------------------"
35+
echo "Checking: $OCI_REF"
36+
37+
for TARGET in "${TARGET_FILES[@]}"; do
38+
if [ ! -f "$TARGET" ]; then
39+
echo " [ERROR] File missing: $TARGET"
40+
EXIT_CODE=1
41+
continue
42+
fi
43+
44+
# grep -F: Matches fixed strings (prevents issues with dots/colons in URLs)
45+
# -q: Quiet mode (exit 0 if found, 1 if not)
46+
if grep -Fq "$OCI_REF" "$TARGET"; then
47+
echo " [OK] Found in $TARGET"
48+
else
49+
echo " [FAIL] MISSING in $TARGET"
50+
EXIT_CODE=1
51+
fi
52+
done
53+
done
54+
55+
echo "---------------------------------------------------"
56+
57+
if [ $EXIT_CODE -eq 0 ]; then
58+
echo "SUCCESS: All external OCI references are present in target files."
59+
exit 0
60+
else
61+
echo "FAILURE: Some OCI references are missing."
62+
exit 1
63+
fi
64+

0 commit comments

Comments
 (0)