11name : Route Sync
22
3- # Pulls the canonical v2 route manifest from the backend and opens a PR when it
4- # drifts from the vendored copy. The PR then fails test_route_coverage until the
5- # matching SDK methods + `# v2:covers` comments are added. Configure the repo
6- # variable BACKEND_MANIFEST_URL (raw URL of compute/pkg/platform/v2/routes.manifest.json)
7- # and, if the source is private, the BACKEND_REPO_TOKEN secret.
3+ # Opens a PR when the backend's canonical v2 route manifest drifts from the
4+ # vendored copy; the PR then fails test_route_coverage until the matching SDK
5+ # methods + `# v2:covers` comments are added. demo2 is private, so fetching its
6+ # manifest needs a token with Contents:read on it — store it as the
7+ # BACKEND_REPO_TOKEN secret (fine-grained PAT scoped to demo2, or a GitHub App
8+ # installation token).
89
910on :
1011 schedule :
@@ -18,31 +19,34 @@ permissions:
1819jobs :
1920 sync :
2021 runs-on : ubuntu-latest
22+ env :
23+ GH_TOKEN : ${{ secrets.BACKEND_REPO_TOKEN }}
24+ BACKEND_REPO : ${{ vars.BACKEND_REPO || 'TextQLLabs/demo2' }}
25+ MANIFEST_PATH : ${{ vars.BACKEND_MANIFEST_PATH || 'compute/pkg/platform/v2/routes.manifest.json' }}
26+ MANIFEST_REF : ${{ vars.BACKEND_MANIFEST_REF || 'main' }}
2127 steps :
2228 - uses : actions/checkout@v4
2329 - name : Fetch upstream manifest
2430 id : fetch
25- env :
26- BACKEND_MANIFEST_URL : ${{ vars.BACKEND_MANIFEST_URL }}
27- BACKEND_REPO_TOKEN : ${{ secrets.BACKEND_REPO_TOKEN }}
2831 run : |
29- if [ -z "$BACKEND_MANIFEST_URL" ]; then
30- echo "BACKEND_MANIFEST_URL not set; skipping"
32+ set -euo pipefail
33+ if [ -z "${GH_TOKEN:-}" ]; then
34+ echo "BACKEND_REPO_TOKEN not set; skipping"
3135 echo "changed=false" >> "$GITHUB_OUTPUT"
3236 exit 0
3337 fi
34- auth=()
35- if [ -n "$BACKEND_REPO_TOKEN" ]; then auth=(-H "Authorization: Bearer $BACKEND_REPO_TOKEN"); fi
36- curl -fsSL "${auth[@]}" "$BACKEND_MANIFEST_URL" -o upstream.json
37- changed=$(python -c "import json,sys; a=set(json.load(open('upstream.json'))); b=set(json.load(open('tests/routes.manifest.json'))); print('true' if a!=b else 'false')")
38- if [ "$changed" = "true" ]; then
39- python -c "import json; json.dump(sorted(json.load(open('upstream.json'))), open('tests/routes.manifest.json','w'), indent=2); open('tests/routes.manifest.json','a').write('\n')"
40- fi
38+ gh api "repos/${BACKEND_REPO}/contents/${MANIFEST_PATH}?ref=${MANIFEST_REF}" \
39+ -H "Accept: application/vnd.github.raw" > upstream.json
40+ changed=$(python3 -c "import json; a=set(json.load(open('upstream.json'))); b=set(json.load(open('tests/routes.manifest.json'))); print('true' if a!=b else 'false')")
41+ if [ "$changed" = "true" ]; then cp upstream.json tests/routes.manifest.json; fi
4142 echo "changed=$changed" >> "$GITHUB_OUTPUT"
4243 - name : Open PR
4344 if : steps.fetch.outputs.changed == 'true'
4445 uses : peter-evans/create-pull-request@v6
4546 with :
47+ # Default GITHUB_TOKEN-created PRs do NOT trigger CI; pass a PAT/App
48+ # token here if you want test_route_coverage to run automatically.
49+ token : ${{ secrets.ROUTE_SYNC_PR_TOKEN || secrets.GITHUB_TOKEN }}
4650 branch : route-sync
4751 add-paths : tests/routes.manifest.json
4852 commit-message : " chore: sync v2 route manifest from backend"
0 commit comments