Skip to content

Commit bc19798

Browse files
committed
ci(core): propose core release bumps and track drift on core main
Ports sdk-go's core sync automation into scripts/: - core-watch.yml (hourly) runs core-tags.sh and opens one bump PR per new core tag with open-bump-pr.sh: it moves OPENSHELL_CORE_REF, regenerates the bindings with `mise run proto:gen`, refreshes the files copied from core, and puts the proto diff in the body. Every stable tag gets a PR, plus the newest pre-release; a newer pre-release closes the older proposal. - core-drift.yml (nightly) runs drift-check.sh: buf breaking between the pin and core main for the protos the SDK generates, the unit tests against bindings regenerated from main, and the RPCs the SDK doesn't call. update-drift-issue.sh keeps one "Core main drift" issue current. - report-failure.sh records failed runs in that issue. Both workflows use the sdk-bot App token, so bump PRs get CI, including E2E against the proposed core version. The files copied from core are listed once, in scripts/vendored-core-files.txt, which conformance:check and the bump script both read. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent 959584e commit bc19798

13 files changed

Lines changed: 781 additions & 6 deletions

‎.github/workflows/core-drift.yml‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# Nightly comparison of core main with the pinned core tag; keeps the single
4+
# "Core main drift" issue current (scripts/drift-check.sh).
5+
name: core-drift
6+
7+
on:
8+
schedule:
9+
- cron: "41 4 * * *"
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
concurrency:
16+
group: core-drift
17+
cancel-in-progress: false
18+
19+
jobs:
20+
drift:
21+
name: drift
22+
# The bot secrets live in the sdk-bot environment, which only main can
23+
# deploy to, so a pushed branch can't mint a bot token.
24+
environment: sdk-bot
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 20
27+
steps:
28+
- id: app-token
29+
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
30+
with:
31+
client-id: ${{ secrets.SDK_BOT_CLIENT_ID }}
32+
private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }}
33+
permission-issues: write
34+
35+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
36+
with:
37+
persist-credentials: false
38+
39+
- uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0
40+
41+
# Exit 1 with a report means drift; the issue records it. No report
42+
# means the check itself broke, which the failure step records.
43+
- name: Check drift against core main
44+
run: |
45+
scripts/drift-check.sh --out drift-report.md || true
46+
test -s drift-report.md
47+
cat drift-report.md >>"$GITHUB_STEP_SUMMARY"
48+
49+
- name: Update the drift issue
50+
env:
51+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
52+
run: scripts/update-drift-issue.sh drift-report.md
53+
54+
- name: Report failure
55+
if: failure()
56+
env:
57+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
58+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
59+
run: scripts/report-failure.sh core-drift "$RUN_URL"

‎.github/workflows/core-watch.yml‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# Opens one update proposal per new core release tag (scripts/open-bump-pr.sh).
4+
name: core-watch
5+
6+
on:
7+
schedule:
8+
- cron: "17 * * * *"
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: Core tag to propose (vX.Y.Z or vX.Y.Z-pre.N); empty proposes every new tag
13+
required: false
14+
default: ""
15+
16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: core-watch
21+
cancel-in-progress: false
22+
23+
jobs:
24+
watch:
25+
name: watch
26+
# The bot secrets live in the sdk-bot environment, which only main can
27+
# deploy to, so a pushed branch can't mint a bot token.
28+
environment: sdk-bot
29+
runs-on: ubuntu-latest
30+
timeout-minutes: 20
31+
steps:
32+
- id: app-token
33+
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
34+
with:
35+
client-id: ${{ secrets.SDK_BOT_CLIENT_ID }}
36+
private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }}
37+
permission-contents: write
38+
permission-pull-requests: write
39+
permission-issues: write
40+
41+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
42+
with:
43+
fetch-depth: 0
44+
token: ${{ steps.app-token.outputs.token }}
45+
persist-credentials: true
46+
47+
- uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0
48+
49+
- name: Set the bot identity
50+
env:
51+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
52+
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
53+
run: |
54+
set -euo pipefail
55+
id=$(gh api "users/${APP_SLUG}[bot]" --jq .id)
56+
git config user.name "${APP_SLUG}[bot]"
57+
git config user.email "${id}+${APP_SLUG}[bot]@users.noreply.github.com"
58+
59+
- name: Propose new core tags
60+
env:
61+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
62+
INPUT_TAG: ${{ inputs.tag }}
63+
run: |
64+
set -euo pipefail
65+
if [ -n "$INPUT_TAG" ]; then
66+
tags=$INPUT_TAG
67+
else
68+
tags=$(scripts/core-tags.sh)
69+
fi
70+
if [ -z "$tags" ]; then
71+
echo "No core tags newer than $(mise run --quiet core:version)."
72+
exit 0
73+
fi
74+
for t in $tags; do
75+
scripts/open-bump-pr.sh "$t"
76+
done
77+
78+
- name: Report failure
79+
if: failure()
80+
env:
81+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
82+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
83+
run: scripts/report-failure.sh core-watch "$RUN_URL"

‎README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ reads them, and `grpcio-tools` generates the bindings:
4040
pinned protos, and `mise run conformance:check` does the same for the
4141
vendored test fixtures and `tests/e2e/Dockerfile.workload`.
4242

43+
## Keeping up with core
44+
45+
`core-watch.yml` checks core's release tags hourly and opens a PR,
46+
`chore(core): track <tag>`, that moves the pin, regenerates the bindings and
47+
refreshes the files copied from core. It does that for each new stable tag and
48+
for the newest pre-release. `core-drift.yml` compares core `main` with the pin
49+
nightly and keeps one `Core main drift` issue up to date. Both run scripts you
50+
can also run locally; see [scripts/README.md](scripts/README.md).
51+
52+
```shell
53+
mise run core:tags # core tags newer than the pin
54+
mise run core:bump -- v0.1.8 --dry-run # build the bump PR locally
55+
mise run core:drift -- --out drift-report.md # compare core main with the pin
56+
```
57+
4358
## E2E tests
4459

4560
`tests/e2e` runs against a real gateway; `mise run test` skips it. CI runs it

‎mise.toml‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,18 @@ fi
6565
"""
6666

6767
[tasks."conformance:check"]
68-
description = "Fail if vendored fixtures or the E2E workload Dockerfile differ from core at the pinned ref"
68+
description = "Fail if a file copied from core (scripts/vendored-core-files.txt) differs from core at the pinned ref"
6969
run = """
7070
#!/usr/bin/env bash
7171
set -euo pipefail
7272
core=$(mktemp -d)
7373
trap 'rm -rf "$core"' EXIT
74-
scripts/fetch-core.sh "$OPENSHELL_CORE_REF" "$core" sdk/conformance e2e/python/Dockerfile.workload
75-
for fixture in oauth-client-credentials.json oauth-client-credentials.json.license; do
76-
diff -u "$core/sdk/conformance/$fixture" "tests/fixtures/$fixture"
77-
done
78-
diff -u "$core/e2e/python/Dockerfile.workload" tests/e2e/Dockerfile.workload
74+
files=$(grep -v '^#' scripts/vendored-core-files.txt)
75+
# shellcheck disable=SC2046 # one argument per core path
76+
scripts/fetch-core.sh "$OPENSHELL_CORE_REF" "$core" $(awk '{ print $1 }' <<<"$files")
77+
while read -r src dst; do
78+
diff -u "$core/$src" "$dst"
79+
done <<<"$files"
7980
"""
8081

8182
[tasks.lint]
@@ -143,3 +144,15 @@ done
143144
[tasks.ci]
144145
description = "Run the full CI pipeline"
145146
depends = ["check", "test", "build"]
147+
148+
[tasks."core:tags"]
149+
description = "List core release tags newer than the pin (newest pre-release only, --all for every tag)"
150+
run = "scripts/core-tags.sh"
151+
152+
[tasks."core:bump"]
153+
description = "Open the update proposal for a core tag: mise run core:bump -- <tag> [--dry-run]"
154+
run = "scripts/open-bump-pr.sh"
155+
156+
[tasks."core:drift"]
157+
description = "Compare core main with the pin: mise run core:drift -- --out <report.md>"
158+
run = "scripts/drift-check.sh"

‎scripts/README.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Scripts
2+
3+
The workflows under `.github/workflows/` run these scripts, most through a mise task, so each job can be run locally first. Scripts that write to GitHub take `--dry-run` and print what they would do instead.
4+
5+
The core sync workflows use a GitHub App token from the `sdk-bot` environment (secrets `SDK_BOT_CLIENT_ID` and `SDK_BOT_PRIVATE_KEY`), which only `main` can deploy to. They never use `GITHUB_TOKEN`, because pushes and PRs made with it don't trigger CI.
6+
7+
| File | mise task | Purpose |
8+
|------|-----------|---------|
9+
| `core-tags.sh [--all]` | `core:tags` | List NVIDIA/OpenShell release tags newer than the pin (`OPENSHELL_CORE_REF` in `mise.toml`): every stable tag, plus the newest pre-release when it is newer than all of them. |
10+
| `open-bump-pr.sh <tag> [--dry-run]` | `core:bump` | Open the update proposal for one core tag: branch `core/<tag>`, pin change, regenerated bindings, refreshed copies of core files, proto diff in the body, labels `core-bump` plus `stable` or `prerelease`. Closes older pre-release proposals. |
11+
| `bump-pr-body.md` | | PR body template for `open-bump-pr.sh`. |
12+
| `drift-check.sh --out <file>` | `core:drift` | Compare core `main` with the pin: `buf breaking`, regenerate and run the unit tests, list the RPCs the SDK doesn't call. Writes the markdown report. |
13+
| `update-drift-issue.sh <report.md> [--dry-run]` | | Create, update, or close the single `Core main drift` issue from a report. |
14+
| `report-failure.sh <job> <run-url> [--dry-run]` | | Append a dated failure line to the drift issue. Called from `if: failure()` steps. |
15+
| `drift-issue.sh` | | Shared helpers for the two drift issue scripts (sourced, not run). |
16+
| `vendored-core-files.txt` | `conformance:check` | Files copied from core. `conformance:check` compares them with core at the pin; `open-bump-pr.sh` refreshes them. |
17+
| `fetch-core.sh <ref> <dir> <path>...` | | Copy files from core at a ref, for `conformance:check`. |
18+
| `start-gateway.sh <core-version>`, `stop-gateway.sh` | | Run the published gateway of a core version with the Docker driver for the E2E lane, then stop it and collect its log. |
19+
| `generate_python_proto.py` | `proto:gen` | Generate `src/openshell/_proto` from `proto/`. |
20+
| `verify-python-wheel.py` | `build` | Check the wheel's contents and version. |
21+
22+
| Workflow | Runs |
23+
|----------|------|
24+
| `core-watch.yml` (hourly) | `core-tags.sh`, then `open-bump-pr.sh` per tag |
25+
| `core-drift.yml` (nightly) | `drift-check.sh`, then `update-drift-issue.sh` |
26+
| `e2e.yml` (reusable) | `start-gateway.sh`, `mise run e2e`, `stop-gateway.sh` |
27+
| `ci.yml` | `mise run check`, `test`, `build`, and `e2e.yml` |
28+
29+
Bump PRs run E2E against their own pin, because `e2e.yml` defaults to `OPENSHELL_CORE_REF` on the PR branch.

‎scripts/bump-pr-body.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Move the core pin from `{{OLD}}` to `{{NEW}}` ({{KIND}}).
2+
3+
- Core changes: [{{OLD}}...{{NEW}}]({{COMPARE_URL}})
4+
- Regenerated bindings: {{GENERATED}}
5+
- E2E runs against `{{IMAGE}}`
6+
- Files copied from core:
7+
{{FIXTURES}}
8+
9+
## Proto changes
10+
11+
{{PROTO_DIFF}}
12+
13+
## Before merging
14+
15+
- CI and E2E must pass. If the SDK needs changes for this core version, push them to this branch.
16+
- Pre-release pins are not released; a newer pre-release proposal replaces this one.

‎scripts/core-tags.sh‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# core-tags.sh: print NVIDIA/OpenShell release tags newer than the pin,
5+
# oldest first.
6+
#
7+
# Usage: core-tags.sh [--all] [--pin <tag>]
8+
#
9+
# Release tags are vX.Y.Z and vX.Y.Z-pre.N; a pre-release sorts below its
10+
# stable version. By default every newer stable tag is printed, plus the
11+
# newest pre-release when it is newer than all of them: one proposal for the
12+
# current release train instead of one per pre-release. --all prints every
13+
# newer tag. --pin overrides the pin, OPENSHELL_CORE_REF in mise.toml.
14+
set -euo pipefail
15+
16+
repo=${CORE_REPO:-NVIDIA/OpenShell}
17+
all=0
18+
pin=
19+
20+
while [ $# -gt 0 ]; do
21+
case $1 in
22+
--all) all=1; shift ;;
23+
--pin) pin=${2:?--pin needs a tag}; shift 2 ;;
24+
*) echo "usage: $0 [--all] [--pin <tag>]" >&2; exit 2 ;;
25+
esac
26+
done
27+
28+
[ -n "$pin" ] || pin=$(sed -n 's/^OPENSHELL_CORE_REF = "\(.*\)"$/\1/p' mise.toml)
29+
[ -n "$pin" ] || { echo "ERROR: no OPENSHELL_CORE_REF in mise.toml" >&2; exit 1; }
30+
31+
# key <tag>: "major minor patch rank pre" with rank 1 for stable, 0 for pre.
32+
key() {
33+
awk -v t="$1" 'BEGIN {
34+
s = t; sub(/^v/, "", s)
35+
pre = ""; rank = 1
36+
if (index(s, "-pre.")) { pre = substr(s, index(s, "-pre.") + 5); s = substr(s, 1, index(s, "-pre.") - 1); rank = 0 }
37+
split(s, v, ".")
38+
printf "%d %d %d %d %d\n", v[1], v[2], v[3], rank, (pre == "" ? 0 : pre)
39+
}'
40+
}
41+
42+
newer=$(
43+
gh api --paginate "repos/$repo/git/matching-refs/tags/v" --jq '.[].ref' |
44+
sed 's#^refs/tags/##' |
45+
{ grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$' || true; } |
46+
while read -r t; do echo "$(key "$t") $t"; done |
47+
awk -v p="$(key "$pin")" '
48+
BEGIN { split(p, k, " ") }
49+
{
50+
for (i = 1; i <= 5; i++) {
51+
if ($i + 0 > k[i] + 0) { print; next }
52+
if ($i + 0 < k[i] + 0) next
53+
}
54+
}' |
55+
sort -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 |
56+
awk '{ print $6 }'
57+
)
58+
59+
[ -n "$newer" ] || exit 0
60+
if [ "$all" -eq 1 ]; then
61+
echo "$newer"
62+
exit 0
63+
fi
64+
65+
# Stable tags, then the last tag if it is a pre-release (newer than every stable).
66+
grep -v -- '-pre\.' <<<"$newer" || true
67+
last=$(tail -1 <<<"$newer")
68+
case $last in *-pre.*) echo "$last" ;; esac

0 commit comments

Comments
 (0)