-
Notifications
You must be signed in to change notification settings - Fork 3
Add classical code generation workflow for Java SDK and migrate to generated event types #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
6
commits into
main
Choose a base branch
from
copilot/add-classical-code-gen-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6561490
Initial plan
Copilot 3ef1b22
Add Java code generation from JSON schemas
Copilot 6e3c50c
Add comment explaining npm install before npm ci in update workflow
Copilot 75e5dba
Improve Java code generator: sealed hierarchy, records, Long for inte…
Copilot e9c0bf7
Add @JsonInclude(NON_NULL) to all generated event classes and warn on…
edburns da9ec9c
Migrate events package to auto-generated SessionEvent types
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| .github/workflows/*.lock.yml linguist-generated=true merge=ours | ||
| .github/workflows/*.lock.yml linguist-generated=true merge=ours | ||
| src/generated/java/** eol=lf linguist-generated=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: "Codegen Check" | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| paths: | ||
| - 'scripts/codegen/**' | ||
| - 'src/generated/java/**' | ||
| - '.github/workflows/codegen-check.yml' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| check: | ||
| name: "Verify generated files are up-to-date" | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Install codegen dependencies | ||
| working-directory: ./scripts/codegen | ||
| run: npm ci | ||
|
|
||
| - name: Run codegen | ||
| working-directory: ./scripts/codegen | ||
| run: npm run generate | ||
|
|
||
| - 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| name: "Update @github/copilot Dependency" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Target version of @github/copilot (e.g. 1.0.24)' | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update: | ||
| name: "Update @github/copilot to ${{ inputs.version }}" | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Validate version input | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._-]+)?$ ]]; then | ||
| echo "::error::Invalid version format '$VERSION'. Expected semver (e.g. 1.0.24)." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Update @github/copilot in scripts/codegen | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| working-directory: ./scripts/codegen | ||
| # npm install updates package.json and package-lock.json to the new | ||
| # version; npm ci (below) then does a clean, reproducible install from | ||
| # the updated lock file. Both steps are required: npm install alone | ||
| # leaves leftover packages, while npm ci alone cannot change the pinned | ||
| # version in the lock file. | ||
| run: npm install "@github/copilot@$VERSION" | ||
|
|
||
| - name: Install codegen dependencies | ||
| working-directory: ./scripts/codegen | ||
| run: npm ci | ||
|
|
||
| - name: Run codegen | ||
| working-directory: ./scripts/codegen | ||
| run: npm run generate | ||
|
|
||
| - name: Create pull request | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| BRANCH="update-copilot-$VERSION" | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| if git rev-parse --verify "origin/$BRANCH" >/dev/null 2>&1; then | ||
| git checkout "$BRANCH" | ||
| git reset --hard HEAD | ||
| else | ||
| git checkout -b "$BRANCH" | ||
| fi | ||
|
|
||
| git add -A | ||
|
|
||
| if git diff --cached --quiet; then | ||
| echo "No changes detected; skipping commit and PR creation." | ||
| exit 0 | ||
| fi | ||
|
|
||
| git commit -m "Update @github/copilot to $VERSION | ||
|
|
||
| - Updated @github/copilot in scripts/codegen | ||
| - Re-ran Java code generator" | ||
| git push origin "$BRANCH" --force-with-lease | ||
|
|
||
| if gh pr view "$BRANCH" >/dev/null 2>&1; then | ||
| echo "Pull request for branch '$BRANCH' already exists; updated branch only." | ||
| else | ||
| gh pr create \ | ||
| --title "Update @github/copilot to $VERSION" \ | ||
| --body "Automated update of \`@github/copilot\` to version \`$VERSION\`. | ||
|
|
||
| ### Changes | ||
| - Updated \`@github/copilot\` in \`scripts/codegen/package.json\` | ||
| - Re-ran Java code generator (\`scripts/codegen\`) | ||
|
|
||
| > Created by the **Update @github/copilot Dependency** workflow." \ | ||
| --base main \ | ||
| --head "$BRANCH" | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules/ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot add a comment explaining the necessity of the unusual step of running
npm installbeforenpm ciThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment in 6e3c50c explaining the two-step approach:
npm installupdatespackage.jsonandpackage-lock.jsonto pin the new version, thennpm cidoes a clean reproducible install from the updated lock file. Runningnpm cialone would fail because it cannot change a pinned version, andnpm installalone leaves behind stale packages.