Skip to content

Commit 061d770

Browse files
edburnsCopilot
andcommitted
Revert codegen-check.yml; create standalone java-codegen-check.yml
Reverts codegen-check.yml to its composition on main (no Java paths). Creates java-codegen-check.yml adapted from the standalone repo's codegen-check.yml with monorepo paths (java/ prefix, working-directory). Updates java-codegen-fix.md to reference java-codegen-check workflow. The java-codegen-fix.lock.yml could not be re-compiled because gh aw is not responsive in this environment. Run 'gh aw compile java-codegen-fix' to regenerate it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5b7d7bf commit 061d770

3 files changed

Lines changed: 199 additions & 113 deletions

File tree

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1 @@
1-
name: "Codegen Check"
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
types: [opened, synchronize, reopened, ready_for_review]
9-
paths:
10-
- 'scripts/codegen/**'
11-
- 'nodejs/src/generated/**'
12-
- 'dotnet/src/Generated/**'
13-
- 'python/copilot/generated/**'
14-
- 'go/generated_*.go'
15-
- 'go/rpc/**'
16-
- 'rust/src/generated/**'
17-
- 'java/scripts/codegen/**'
18-
- 'java/src/generated/**'
19-
- '.github/workflows/codegen-check.yml'
20-
workflow_dispatch:
21-
22-
permissions:
23-
contents: read
24-
25-
jobs:
26-
check:
27-
name: "Verify generated files are up-to-date"
28-
if: github.event.repository.fork == false
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@v4
32-
33-
- uses: actions/setup-node@v4
34-
with:
35-
node-version: 22
36-
37-
- uses: actions/setup-go@v5
38-
with:
39-
go-version: '1.22'
40-
41-
# Rust generator runs `cargo fmt` on the output, so we need a toolchain with rustfmt.
42-
- name: Install Rust toolchain
43-
uses: dtolnay/rust-toolchain@stable
44-
with:
45-
toolchain: "1.94.0"
46-
components: rustfmt
47-
48-
# Nightly rustfmt for unstable format options (group_imports,
49-
# imports_granularity, reorder_impl_items) — pinned in
50-
# `rust/.rustfmt.nightly.toml`. The Rust generator emits unconsolidated
51-
# imports under stable rustfmt; nightly fmt consolidates them to match
52-
# the canonical committed form.
53-
- name: Install nightly rustfmt
54-
uses: dtolnay/rust-toolchain@master
55-
with:
56-
toolchain: nightly-2026-04-14
57-
components: rustfmt
58-
59-
- name: Install nodejs SDK dependencies
60-
working-directory: ./nodejs
61-
run: npm ci
62-
63-
- name: Install codegen dependencies
64-
working-directory: ./scripts/codegen
65-
run: npm ci
66-
67-
- name: Run codegen
68-
working-directory: ./scripts/codegen
69-
run: npm run generate
70-
71-
- name: Apply nightly rustfmt to generated Rust output
72-
working-directory: ./rust
73-
run: cargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml
74-
75-
- name: Check for uncommitted changes
76-
run: |
77-
if [ -n "$(git status --porcelain)" ]; then
78-
echo "::error::Generated files are out of date. Run 'cd scripts/codegen && npm run generate' and commit the changes."
79-
git diff --stat
80-
git diff
81-
exit 1
82-
fi
83-
echo "✅ Generated files are up-to-date"
84-
85-
java-codegen:
86-
name: "Verify Java generated files are up-to-date"
87-
if: github.event.repository.fork == false
88-
runs-on: ubuntu-latest
89-
steps:
90-
- uses: actions/checkout@v4
91-
92-
- uses: actions/setup-node@v4
93-
with:
94-
node-version: 22
95-
96-
- name: Install Java codegen dependencies
97-
working-directory: ./java/scripts/codegen
98-
run: npm ci
99-
100-
- name: Run Java codegen
101-
working-directory: ./java/scripts/codegen
102-
run: npx tsx java.ts
103-
104-
- name: Check for uncommitted changes
105-
run: |
106-
if [ -n "$(git diff --name-only java/src/generated/)" ]; then
107-
echo "::error::Java generated files are out of date. Run 'cd java/scripts/codegen && npx tsx java.ts' and commit the changes."
108-
git diff --stat java/src/generated/
109-
git diff java/src/generated/
110-
exit 1
111-
fi
112-
echo "✅ Java generated files are up-to-date"
1+
name: "Codegen Check"on: push: branches: - main pull_request: types: [opened, synchronize, reopened, ready_for_review] paths: - 'scripts/codegen/**' - 'nodejs/src/generated/**' - 'dotnet/src/Generated/**' - 'python/copilot/generated/**' - 'go/generated_*.go' - 'go/rpc/**' - 'rust/src/generated/**' - '.github/workflows/codegen-check.yml' workflow_dispatch:permissions: contents: readjobs: check: name: "Verify generated files are up-to-date" if: github.event.repository.fork == false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 - uses: actions/setup-go@v5 with: go-version: '1.22' # Rust generator runs `cargo fmt` on the output, so we need a toolchain with rustfmt. - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: toolchain: "1.94.0" components: rustfmt # Nightly rustfmt for unstable format options (group_imports, # imports_granularity, reorder_impl_items) — pinned in # `rust/.rustfmt.nightly.toml`. The Rust generator emits unconsolidated # imports under stable rustfmt; nightly fmt consolidates them to match # the canonical committed form. - name: Install nightly rustfmt uses: dtolnay/rust-toolchain@master with: toolchain: nightly-2026-04-14 components: rustfmt - name: Install nodejs SDK dependencies working-directory: ./nodejs run: npm ci - name: Install codegen dependencies working-directory: ./scripts/codegen run: npm ci - name: Run codegen working-directory: ./scripts/codegen run: npm run generate - name: Apply nightly rustfmt to generated Rust output working-directory: ./rust run: cargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml - name: Check for uncommitted changes run: | if [ -n "$(git status --porcelain)" ]; then echo "::error::Generated files are out of date. Run 'cd scripts/codegen && npm run generate' and commit the changes." git diff --stat git diff exit 1 fi echo "✅ Generated files are up-to-date"
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: "Java Codegen Check"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'java/scripts/codegen/**'
9+
- 'java/src/generated/**'
10+
- '.github/workflows/java-codegen-check.yml'
11+
pull_request:
12+
paths:
13+
- 'java/scripts/codegen/**'
14+
- 'java/src/generated/**'
15+
- '.github/workflows/java-codegen-check.yml'
16+
workflow_dispatch:
17+
18+
# Permissions: contents: write and pull-requests: write are needed to push
19+
# regenerated files back to PR branches. actions: write is needed to trigger
20+
# the agentic fix workflow via gh workflow run.
21+
#
22+
# Dependabot PR caveat: Workflows triggered by pull_request from Dependabot
23+
# run with a read-only GITHUB_TOKEN regardless of declared permissions.
24+
# The push step uses continue-on-error to handle this gracefully — if the
25+
# push fails (Dependabot), the agentic fix workflow will handle pushing
26+
# via its own push-to-pull-request-branch safe-output.
27+
permissions:
28+
contents: write
29+
pull-requests: write
30+
actions: write
31+
32+
jobs:
33+
check:
34+
name: "Verify Java generated files are up-to-date"
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
38+
with:
39+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
40+
# For PRs, check out the PR head so we can push back to it
41+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
42+
43+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
44+
with:
45+
node-version: 22
46+
47+
- name: Install codegen dependencies
48+
working-directory: ./java/scripts/codegen
49+
run: npm ci
50+
51+
- name: Run codegen
52+
working-directory: ./java/scripts/codegen
53+
run: npx tsx java.ts
54+
55+
- name: Check for uncommitted changes
56+
id: check-changes
57+
run: |
58+
if [ -n "$(git status --porcelain)" ]; then
59+
echo "changed=true" >> "$GITHUB_OUTPUT"
60+
echo "Generated files are out of date."
61+
git diff --stat
62+
else
63+
echo "changed=false" >> "$GITHUB_OUTPUT"
64+
echo "✅ Generated files are up-to-date"
65+
fi
66+
67+
# --- On push to main: fail if generated files are stale (existing behavior) ---
68+
- name: Fail on stale generated files (push to main)
69+
if: steps.check-changes.outputs.changed == 'true' && github.event_name != 'pull_request'
70+
run: |
71+
echo "::error::Generated files are out of date. Run 'cd java/scripts/codegen && npx tsx java.ts' and commit the changes."
72+
git diff
73+
exit 1
74+
75+
# --- On PR: commit regenerated files back and verify build ---
76+
- name: Commit and push regenerated files to PR branch
77+
id: push-regen
78+
if: steps.check-changes.outputs.changed == 'true' && github.event_name == 'pull_request'
79+
continue-on-error: true
80+
env:
81+
GH_TOKEN: ${{ github.token }}
82+
HEAD_REF: ${{ github.head_ref }}
83+
run: |
84+
git config user.name "github-actions[bot]"
85+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
86+
git add -A
87+
git commit -m "Regenerate Java codegen output
88+
89+
Auto-committed by java-codegen-check workflow."
90+
git push origin "HEAD:$HEAD_REF"
91+
92+
- name: Fail if regenerated files could not be pushed
93+
if: steps.push-regen.outcome == 'failure'
94+
run: |
95+
echo "::error::Could not push regenerated files to the PR branch. This is expected for Dependabot PRs (read-only token) and fork PRs."
96+
echo "To fix: check out this PR branch locally, run 'cd java/scripts/codegen && npx tsx java.ts', commit, and push."
97+
exit 1
98+
99+
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
100+
if: steps.push-regen.outcome == 'success'
101+
with:
102+
java-version: "17"
103+
distribution: "microsoft"
104+
cache: "maven"
105+
106+
- name: Run mvn verify
107+
id: mvn-verify
108+
if: steps.push-regen.outcome == 'success'
109+
continue-on-error: true
110+
working-directory: ./java
111+
env:
112+
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
113+
run: |
114+
set -o pipefail
115+
mvn verify 2>&1 | tee /tmp/mvn-verify-output.txt
116+
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
117+
118+
- name: Capture error summary
119+
id: error-summary
120+
if: steps.mvn-verify.outcome == 'failure'
121+
run: |
122+
SUMMARY=$(tail -80 /tmp/mvn-verify-output.txt)
123+
echo "$SUMMARY" > /tmp/error-summary.txt
124+
echo "has_errors=true" >> "$GITHUB_OUTPUT"
125+
126+
- name: Trigger agentic fix workflow
127+
id: trigger-fix
128+
if: steps.error-summary.outputs.has_errors == 'true' && steps.push-regen.outcome == 'success'
129+
env:
130+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
PR_NUMBER: ${{ github.event.pull_request.number }}
132+
BRANCH: ${{ github.head_ref }}
133+
run: |
134+
ERROR_SUMMARY=$(cat /tmp/error-summary.txt)
135+
136+
# Ensure PR has dependencies label (required by java-codegen-fix safe-output)
137+
gh pr edit "$PR_NUMBER" --add-label dependencies
138+
139+
gh workflow run java-codegen-fix.lock.yml \
140+
-f branch="$BRANCH" \
141+
-f pr_number="$PR_NUMBER" \
142+
-f error_summary="$ERROR_SUMMARY"
143+
echo "Triggered java-codegen-fix workflow on branch $BRANCH for PR #$PR_NUMBER"
144+
145+
- name: Wait for agentic fix to complete
146+
if: steps.trigger-fix.outcome == 'success'
147+
env:
148+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
BRANCH: ${{ github.head_ref }}
150+
run: |
151+
echo "Waiting for agentic fix workflow to start..."
152+
sleep 30
153+
154+
for i in $(seq 1 60); do
155+
RUN_ID=$(gh run list \
156+
--workflow=java-codegen-fix.lock.yml \
157+
--branch="$BRANCH" \
158+
--limit=1 \
159+
--json databaseId,status \
160+
--jq '.[0].databaseId')
161+
162+
STATUS=$(gh run list \
163+
--workflow=java-codegen-fix.lock.yml \
164+
--branch="$BRANCH" \
165+
--limit=1 \
166+
--json databaseId,status \
167+
--jq '.[0].status')
168+
169+
if [ "$STATUS" = "completed" ]; then
170+
echo "Agentic fix workflow run $RUN_ID completed."
171+
CONCLUSION=$(gh run view "$RUN_ID" --json conclusion --jq .conclusion)
172+
echo "Conclusion: $CONCLUSION"
173+
break
174+
fi
175+
176+
echo "Run $RUN_ID status: $STATUS (attempt $i/60)"
177+
sleep 30
178+
done
179+
180+
if [ "$STATUS" != "completed" ]; then
181+
echo "::warning::Agentic fix workflow did not complete within 30 minutes."
182+
fi
183+
184+
- name: Fetch latest changes after agentic fix
185+
if: steps.trigger-fix.outcome == 'success'
186+
env:
187+
HEAD_REF: ${{ github.head_ref }}
188+
run: |
189+
git fetch origin "$HEAD_REF"
190+
git reset --hard "origin/$HEAD_REF"
191+
192+
- name: Final mvn verify after agentic fix
193+
if: steps.trigger-fix.outcome == 'success'
194+
working-directory: ./java
195+
env:
196+
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
197+
run: mvn verify

.github/workflows/java-codegen-fix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ You are an automation agent that fixes Java compilation and test failures caused
5050

5151
## Context
5252

53-
A Dependabot PR bumped the `@github/copilot` npm dependency in `java/scripts/codegen/package.json`. The `codegen-check` workflow ran the code generator (`java/scripts/codegen/java.ts`) against the new schemas and `mvn verify` subsequently failed. Your job is to fix **both** the code generator script (if needed) and the handwritten SDK/test source code so the build passes.
53+
A Dependabot PR bumped the `@github/copilot` npm dependency in `java/scripts/codegen/package.json`. The `java-codegen-check` workflow ran the code generator (`java/scripts/codegen/java.ts`) against the new schemas and `mvn verify` subsequently failed. Your job is to fix **both** the code generator script (if needed) and the handwritten SDK/test source code so the build passes.
5454

5555
**❌❌❌ YOU MUST NEVER EDIT any of the java source code in `java/src/generated/` directly.** ✅✅Rather, the way to affect changes in these files is to change the code generator script and re-generate the classes in `java/src/generated`.
5656

0 commit comments

Comments
 (0)