-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add workflow to auto-update codegen #1065
Merged
dblock
merged 1 commit into
opensearch-project:main
from
Xtansia:feat/auto-update-code-gen-spec
Jul 8, 2024
Merged
Changes from all commits
Commits
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 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,10 +1,15 @@ | ||
name: Code Generation | ||
|
||
on: [pull_request] | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * 1' # 00:00 UTC Weekly on Mondays | ||
|
||
jobs: | ||
up_to_date: | ||
name: Ensure Generated Code Up To Date | ||
name: Ensure Generated Code Is Up To Date | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Java Client | ||
|
@@ -18,9 +23,9 @@ jobs: | |
cache: 'gradle' | ||
|
||
- name: Run Code Generator | ||
run: ./gradlew clean :java-codegen:run | ||
run: ./gradlew :java-codegen:run | ||
|
||
- name: Check Has No Changes | ||
- name: Check For Uncommitted Changes | ||
shell: bash -eo pipefail {0} | ||
run: | | ||
output=$(git status --porcelain) | ||
|
@@ -31,4 +36,53 @@ jobs: | |
echo "Dirty working directory" | ||
echo "$output" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
|
||
update_spec: | ||
name: Update Specification and Re-generate Code | ||
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'schedule' && github.repository == 'opensearch-project/opensearch-java') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout Java Client | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 11 | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
|
||
- name: Download Latest Spec && Run Code Generator | ||
run: ./gradlew :java-codegen:downloadLatestSpec :java-codegen:run | ||
|
||
- name: Get Current Date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Generate GitHub App Token | ||
if: github.repository == 'opensearch-project/opensearch-java' | ||
id: github_app_token | ||
uses: tibdex/[email protected] | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
installation_id: 22958780 | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }} | ||
commit-message: Re-generate client code using latest OpenSearch API specification (${{ steps.date.outputs.date }}) | ||
title: Re-generated client code using latest OpenSearch API specification | ||
body: | | ||
Re-generated client code using latest OpenSearch API specification. | ||
Date: ${{ steps.date.outputs.date }} | ||
branch: code-gen/${{ github.ref_name }}/update | ||
signoff: true | ||
labels: | | ||
autocut |
This file contains 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
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.
This is more of the question to
opensearch-api-specification
but may be we could publish it to Maven as an artifact?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.
In some hypothetical future when the spec is complete we will make releases every time a new API releases with OpenSearch. How strongly do you feel about this being checked in in the meantime?
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.
We are in early stages indeed, so if that is the way to move forward (for now), no hard feelings