Skip to content

Commit 100943b

Browse files
committed
Harden JanusGraph release lookup
1 parent ab0ed6a commit 100943b

1 file changed

Lines changed: 42 additions & 7 deletions

File tree

.github/workflows/test-janusgraph.yml

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,38 @@ jobs:
140140
run: |
141141
set -euo pipefail
142142
export JANUSGRAPH_VERSION
143+
export GITHUB_TOKEN="${{ github.token }}"
143144
NEXT="$(
144145
python3 - <<'PY'
145146
import json
146147
import os
147148
import re
149+
import sys
148150
import urllib.request
149151
150152
current = os.environ.get("JANUSGRAPH_VERSION", "")
151153
if not re.fullmatch(r"\d+\.\d+\.\d+", current):
152154
print("")
153155
raise SystemExit(0)
154156
155-
releases = json.load(
156-
urllib.request.urlopen(
157-
"https://api.github.com/repos/JanusGraph/janusgraph/releases?per_page=100",
158-
timeout=20,
159-
)
157+
request = urllib.request.Request(
158+
"https://api.github.com/repos/JanusGraph/janusgraph/releases?per_page=100",
159+
headers={
160+
"Accept": "application/vnd.github+json",
161+
"User-Agent": "arm-smoke-tests",
162+
},
160163
)
164+
token = os.environ.get("GITHUB_TOKEN", "").strip()
165+
if token:
166+
request.add_header("Authorization", f"Bearer {token}")
167+
168+
try:
169+
releases = json.load(urllib.request.urlopen(request, timeout=20))
170+
except Exception as exc:
171+
print(f"JanusGraph release lookup unavailable: {exc}", file=sys.stderr)
172+
print("__LOOKUP_FAILED__")
173+
raise SystemExit(0)
174+
161175
versions = []
162176
for rel in releases:
163177
if rel.get("draft") or rel.get("prerelease"):
@@ -173,12 +187,19 @@ jobs:
173187
PY
174188
)"
175189
echo "version=${JANUSGRAPH_VERSION}" >> "$GITHUB_OUTPUT"
176-
if [ -n "${NEXT}" ]; then
190+
if [ "${NEXT}" = "__LOOKUP_FAILED__" ]; then
191+
echo "latest=unknown" >> "$GITHUB_OUTPUT"
192+
echo "next=" >> "$GITHUB_OUTPUT"
193+
echo "latest_lookup_status=failed" >> "$GITHUB_OUTPUT"
194+
elif [ -n "${NEXT}" ]; then
177195
echo "latest=${NEXT}" >> "$GITHUB_OUTPUT"
196+
echo "next=${NEXT}" >> "$GITHUB_OUTPUT"
197+
echo "latest_lookup_status=ok" >> "$GITHUB_OUTPUT"
178198
else
179199
echo "latest=${JANUSGRAPH_VERSION}" >> "$GITHUB_OUTPUT"
200+
echo "next=" >> "$GITHUB_OUTPUT"
201+
echo "latest_lookup_status=ok" >> "$GITHUB_OUTPUT"
180202
fi
181-
echo "next=${NEXT}" >> "$GITHUB_OUTPUT"
182203
183204
- name: Test 1 - Artifact Existence
184205
id: test1
@@ -270,13 +291,27 @@ jobs:
270291
CURRENT="${{ steps.version.outputs.version || 'unknown' }}"
271292
NEXT="${{ steps.version.outputs.next || '' }}"
272293
LATEST="${{ steps.version.outputs.latest || 'unknown' }}"
294+
LOOKUP_STATUS="${{ steps.version.outputs.latest_lookup_status || 'ok' }}"
273295
NEXT_URL="https://github.com/JanusGraph/janusgraph/releases/download/v${LATEST}/janusgraph-${LATEST}.zip"
274296
echo "current_version=$CURRENT" >> "$GITHUB_OUTPUT"
275297
echo "latest_version=$LATEST" >> "$GITHUB_OUTPUT"
276298
echo "=== Regression Validation (Next Version Install) ==="
277299
echo "Current version tested in Tests 1-5: $CURRENT"
278300
echo "Next version targeted for install validation: $LATEST"
279301
302+
if [ "$LOOKUP_STATUS" != "ok" ]; then
303+
echo "next_installed_version=not_installed" >> "$GITHUB_OUTPUT"
304+
echo "decision=next_lookup_deferred" >> "$GITHUB_OUTPUT"
305+
echo "regression_result=Next version lookup deferred on Arm64" >> "$GITHUB_OUTPUT"
306+
echo "comparison=Current pinned JanusGraph version $CURRENT passed smoke tests in this run, but the GitHub Releases API lookup was unavailable or rate-limited, so no honest next-version install claim is made." >> "$GITHUB_OUTPUT"
307+
echo "Next version installed on Arm64: not_installed"
308+
echo "Regression install result: Next version lookup deferred on Arm64"
309+
echo "status=skipped" >> "$GITHUB_OUTPUT"
310+
END_TIME=$(date +%s)
311+
echo "duration=$((END_TIME - START_TIME))" >> "$GITHUB_OUTPUT"
312+
exit 0
313+
fi
314+
280315
if [ -z "$NEXT" ]; then
281316
echo "next_installed_version=$CURRENT" >> "$GITHUB_OUTPUT"
282317
echo "decision=no_newer_stable_available" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)