Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The workflows use a GitHub App token from the `sdk-bot` environment (secrets `SD
| `update-drift-issue.sh <report.md> [--dry-run]` | `core:drift-issue` | Create, update, or close the single `Core main drift` issue from a report. |
| `report-failure.sh <job> <run-url> [--dry-run]` | `core:report-failure` | Append a dated failure line to the drift issue. Called from `if: failure()` steps. |
| `drift-issue.sh` | | Shared helpers for the two drift issue scripts (sourced, not run). |
| `core-registry.sh` | | `core_registry <version>`: the registry that holds a core release's images, `quay.io/ai-openshell` for releases since the move and `ghcr.io/nvidia/openshell` for older ones. Sourced by `open-bump-pr.sh` and `e2e/start-gateway.sh`. |

| Workflow | Runs (mise tasks) |
|----------|------|
Expand Down
21 changes: 21 additions & 0 deletions scripts/core-sync/core-registry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# shellcheck shell=bash
# SPDX-License-Identifier: Apache-2.0

# core-registry.sh: sourced by e2e/start-gateway.sh and open-bump-pr.sh.
#
# core_registry <version> prints the registry that holds the core gateway
# image <version> (X.Y.Z or X.Y.Z-pre.N), or fails when neither has it yet.
# Releases since the move to Quay are on quay.io/ai-openshell; older ones stay
# on ghcr.io/nvidia/openshell for good.
core_registry() {
local accept='Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.oci.image.manifest.v1+json'
local token
if curl -fs -o /dev/null -H "$accept" "https://quay.io/v2/ai-openshell/gateway/manifests/$1"; then
echo quay.io/ai-openshell
return
fi
token=$(curl -fsS "https://ghcr.io/token?scope=repository:nvidia/openshell/gateway:pull" | jq -r .token) || return 1
curl -fs -o /dev/null -H "Authorization: Bearer $token" -H "$accept" \
"https://ghcr.io/v2/nvidia/openshell/gateway/manifests/$1" || return 1
echo ghcr.io/nvidia/openshell
}
7 changes: 5 additions & 2 deletions scripts/core-sync/open-bump-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ set -euo pipefail

core_repo=${CORE_REPO:-NVIDIA/OpenShell}
sdk_repo=${SDK_REPO:-ai-openshell/sdk-python}
image=ghcr.io/nvidia/openshell/gateway
diff_cap=400

tag=
Expand Down Expand Up @@ -167,8 +166,12 @@ fi
generated=$(git diff --stat "$base" "$branch" -- src/openshell/_proto | tail -1 | sed "s/^ *//")
fixtures=$(cat "$work/fixtures.txt")

# shellcheck source=scripts/core-sync/core-registry.sh
. "$here/core-registry.sh"
# A fresh tag's images may not be pushed yet; new releases go to Quay.
registry=$(core_registry "${tag#v}") || registry=quay.io/ai-openshell
body="$work/body.md"
OLD="$old" NEW="$tag" KIND="$kind" COMPARE_URL="$compare_url" IMAGE="$image:${tag#v}" \
OLD="$old" NEW="$tag" KIND="$kind" COMPARE_URL="$compare_url" IMAGE="$registry/gateway:${tag#v}" \
GENERATED="${generated:-no generated files changed}" FIXTURES="${fixtures:- - none changed}" \
PROTO_DIFF="$proto_section" \
awk '{
Expand Down
24 changes: 14 additions & 10 deletions scripts/e2e/start-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
set -euo pipefail

core_repo=${CORE_REPO:-NVIDIA/OpenShell}
registry=ghcr.io/nvidia/openshell
name=e2e
port=8080
health_port=8081
Expand All @@ -49,27 +48,32 @@ mkdir -p "$state"
echo "$tag" >"$state/core-version"

# Core pushes images after tagging; a proposal can be faster than that.
manifest_exists() {
local token
token=$(curl -fsS "https://ghcr.io/token?scope=repository:nvidia/openshell/gateway:pull" | jq -r .token) || return 1
curl -fsS -o /dev/null -H "Authorization: Bearer $token" \
-H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.oci.image.manifest.v1+json' \
"https://ghcr.io/v2/nvidia/openshell/gateway/manifests/$semver"
}
# shellcheck source=scripts/core-sync/core-registry.sh
. "$(dirname "${BASH_SOURCE[0]}")/../core-sync/core-registry.sh"
for i in $(seq 1 15); do
manifest_exists && break
registry=$(core_registry "$semver") && break
if [ "$i" -eq 15 ]; then
echo "ERROR: gateway image for $semver not published yet, re-run later" >&2
exit 1
fi
echo "Waiting for $registry/gateway:$semver ($i/15) ..."
echo "Waiting for the gateway image $semver ($i/15) ..."
sleep 60
done

# Core's deployment files at the tag.
base="https://raw.githubusercontent.com/$core_repo/$tag/deploy/docker"
curl -fsSL "$base/docker-compose.yml" -o "$state/docker-compose.yml"
curl -fsSL "$base/gateway.toml" -o "$state/gateway.toml"
# Use the registry that holds this version: tags cut shortly after the move
# still name GHCR in their deployment files while their images are on Quay.
for f in docker-compose.yml gateway.toml; do
sed -E -i.bak "s#(ghcr\.io/nvidia/openshell|quay\.io/ai-openshell)/#$registry/#g" "$state/$f" &&
rm -f "$state/$f.bak"
done
grep -q "$registry/gateway:" "$state/docker-compose.yml" || {
echo "ERROR: core's docker-compose.yml at $tag does not use $registry/gateway" >&2
exit 1
}
sed -i.bak \
-e "s#\"$registry/supervisor:latest\"#\"$registry/supervisor:$semver\"#" \
-e "s#\"$registry/sandbox:latest\"#\"$registry/sandbox:$semver\"#" \
Expand Down