Skip to content

Commit 3d54be7

Browse files
authored
Merge pull request #139 from github/edburns/fix-gap-with-package_json
Unify @github/copilot version tracking and rename sync workflow
2 parents 5419ac8 + 478d829 commit 3d54be7

13 files changed

Lines changed: 147 additions & 70 deletions

File tree

.github/actions/setup-copilot/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ runs:
2121
# implementation pinned in .lastmerge by
2222
# .github/scripts/reference-impl-sync/sync-cli-version-from-reference-impl.sh.
2323
run: |
24-
PROP="readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-weekly-reference-impl-sync"
24+
PROP="readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync"
2525
VERSION=$(sed -n "s|.*<${PROP}>\(.*\)</${PROP}>.*|\1|p" pom.xml | head -n 1 | tr -d '[:space:]')
2626
if [[ -z "$VERSION" || "$VERSION" == "PRIMER_TO_REPLACE" ]]; then
2727
echo "::error::Could not read pinned @github/copilot version from pom.xml property <${PROP}>" >&2

.github/dependabot.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "npm"
4-
directory: "/scripts/codegen"
5-
schedule:
6-
interval: "daily"
7-
open-pull-requests-limit: 1
8-
allow:
9-
- dependency-name: "@github/copilot"
10-
113
- package-ecosystem: "github-actions"
124
directory: "/"
135
schedule:

.github/prompts/coding-agent-merge-reference-impl-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<!-- Custom instructions for the Copilot coding agent when triggered by the weekly reference implementation sync workflow. -->
2-
<!-- This file is read by .github/workflows/weekly-reference-impl-sync.yml and passed as custom_instructions. -->
1+
<!-- Custom instructions for the Copilot coding agent when triggered by the reference implementation sync workflow. -->
2+
<!-- This file is read by .github/workflows/reference-impl-sync.yml and passed as custom_instructions. -->
33

44
Follow the agentic-merge-reference-impl prompt at .github/prompts/agentic-merge-reference-impl.prompt.md
55
to port reference implementation changes to the Java SDK.

.github/scripts/reference-impl-sync/merge-reference-impl-finish.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
# 2. Updates .lastmerge to reference implementation HEAD
88
# 3. Syncs the @github/copilot version property in pom.xml from the
99
# cloned reference implementation's nodejs/package.json
10-
# 4. Commits the .lastmerge + pom.xml updates
11-
# 5. Pushes the branch to origin
10+
# 4. Syncs scripts/codegen/package.json to the same @github/copilot
11+
# version so the code generator uses matching schemas
12+
# 5. Commits the .lastmerge + pom.xml + codegen package updates
13+
# 6. Pushes the branch to origin
1214
#
1315
# Usage: ./.github/scripts/reference-impl-sync/merge-reference-impl-finish.sh
1416
# ./.github/scripts/reference-impl-sync/merge-reference-impl-finish.sh --skip-tests
@@ -56,8 +58,16 @@ echo "$NEW_COMMIT" > "$ROOT_DIR/.lastmerge"
5658
echo "▸ Syncing @github/copilot version in pom.xml from reference implementation…"
5759
"$ROOT_DIR/.github/scripts/reference-impl-sync/sync-cli-version-from-reference-impl.sh" "$REFERENCE_IMPL_DIR"
5860

59-
git add .lastmerge pom.xml
60-
git commit -m "Update .lastmerge to $NEW_COMMIT and sync pom.xml CLI version"
61+
# ── 2c. Sync scripts/codegen @github/copilot version ─────────
62+
# Keeps scripts/codegen/package.json in lockstep so the code generator
63+
# uses schemas from the same CLI version that the tests run against.
64+
# This eliminates the gap where Dependabot could race ahead of the
65+
# reference implementation sync.
66+
echo "▸ Syncing @github/copilot version in scripts/codegen/package.json…"
67+
"$ROOT_DIR/.github/scripts/reference-impl-sync/sync-codegen-version.sh" "$REFERENCE_IMPL_DIR"
68+
69+
git add .lastmerge pom.xml scripts/codegen/package.json scripts/codegen/package-lock.json
70+
git commit -m "Update .lastmerge to $NEW_COMMIT, sync pom.xml CLI version, and update scripts/codegen @github/copilot version"
6171

6272
# ── 3. Push branch ───────────────────────────────────────────
6373
echo "▸ Pushing branch $BRANCH_NAME to origin…"

.github/scripts/reference-impl-sync/sync-cli-version-from-reference-impl.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# reference implementation's nodejs/package.json, and updates the
77
# corresponding property in pom.xml:
88
#
9-
# <readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-weekly-reference-impl-sync>
9+
# <readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>
1010
#
1111
# This keeps the canonical Copilot CLI version (declared in pom.xml)
1212
# in sync with whatever the reference implementation pinned in
@@ -65,7 +65,7 @@ if [[ -z "$CLI_VERSION" ]]; then
6565
fi
6666

6767
POM="$ROOT_DIR/pom.xml"
68-
PROP="readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-weekly-reference-impl-sync"
68+
PROP="readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync"
6969

7070
if ! grep -q "<${PROP}>" "$POM"; then
7171
echo "❌ Property <${PROP}> not found in $POM" >&2
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
# ──────────────────────────────────────────────────────────────
3+
# sync-codegen-version.sh
4+
#
5+
# Updates the @github/copilot dependency in scripts/codegen/package.json
6+
# to match the version used by the reference implementation. This keeps
7+
# the code generator schemas in lockstep with the CLI version used for
8+
# testing, eliminating the gap where Dependabot could race ahead.
9+
#
10+
# Usage:
11+
# ./sync-codegen-version.sh <reference-impl-dir>
12+
#
13+
# Or, when invoked from merge-reference-impl-finish.sh, the directory
14+
# is passed as $1.
15+
# ──────────────────────────────────────────────────────────────
16+
set -euo pipefail
17+
18+
# Locate the repo root by walking up from this script until we find a pom.xml.
19+
find_repo_root() {
20+
local dir
21+
dir="$(cd "$(dirname "$0")" && pwd)"
22+
while [[ "$dir" != "/" ]]; do
23+
if [[ -f "$dir/pom.xml" ]]; then
24+
echo "$dir"
25+
return 0
26+
fi
27+
dir="$(dirname "$dir")"
28+
done
29+
echo "❌ Could not locate repo root (no pom.xml found above $(dirname "$0"))" >&2
30+
return 1
31+
}
32+
ROOT_DIR="$(find_repo_root)"
33+
34+
REFERENCE_IMPL_DIR="${1:-${REFERENCE_IMPL_DIR:-}}"
35+
if [[ -z "$REFERENCE_IMPL_DIR" ]]; then
36+
echo "❌ Usage: $0 <reference-impl-dir>" >&2
37+
echo " or set REFERENCE_IMPL_DIR in the environment." >&2
38+
exit 1
39+
fi
40+
41+
PKG_JSON="$REFERENCE_IMPL_DIR/nodejs/package.json"
42+
if [[ ! -f "$PKG_JSON" ]]; then
43+
echo "❌ Cannot find $PKG_JSON" >&2
44+
exit 1
45+
fi
46+
47+
# Extract the @github/copilot version from the reference implementation.
48+
CLI_VERSION=$(node -e \
49+
"const fs=require('fs');const p=JSON.parse(fs.readFileSync(process.argv[1],'utf8'));const v=(p.dependencies&&p.dependencies['@github/copilot'])||(p.devDependencies&&p.devDependencies['@github/copilot']);process.stdout.write(v||'');" \
50+
"$PKG_JSON")
51+
52+
if [[ -z "$CLI_VERSION" ]]; then
53+
echo "❌ Could not extract @github/copilot version from $PKG_JSON" >&2
54+
exit 1
55+
fi
56+
57+
CODEGEN_DIR="$ROOT_DIR/scripts/codegen"
58+
CODEGEN_PKG="$CODEGEN_DIR/package.json"
59+
60+
if [[ ! -f "$CODEGEN_PKG" ]]; then
61+
echo "❌ Cannot find $CODEGEN_PKG" >&2
62+
exit 1
63+
fi
64+
65+
# Update scripts/codegen/package.json with the new version and regenerate the lock file.
66+
# Intentionally omit --save-exact to preserve the version specifier used by the reference
67+
# implementation (e.g. a caret range like '^1.0.36-0' rather than an exact pin '1.0.36-0').
68+
echo "▸ Updating scripts/codegen/package.json: @github/copilot → ${CLI_VERSION}"
69+
cd "$CODEGEN_DIR"
70+
npm install "@github/copilot@${CLI_VERSION}"
71+
echo "▸ Updated scripts/codegen to @github/copilot@${CLI_VERSION}"

0 commit comments

Comments
 (0)