-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: create workflow to check showcase commit #13305
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b8bbf1a
ci: add showcase version check workflow
sofisl fbb5889
small changes
sofisl f5fd9e5
ci: add showcase version check workflow
sofisl a8a9233
chore: delete extra files
sofisl 8c99d6d
ci: use underscores for script name and restore fallback checks
sofisl 9aac985
chore: create checking mismatch
sofisl 87be2fa
Update .github/scripts/verify_showcase_version.go
sofisl 2d7e146
chore: fix mvn command
sofisl d0a81c6
chore: add showcase step
sofisl 750eff6
test inline changes
sofisl d5c10d8
fix: filter mvn help:evaluate output in showcase-version-check.yaml
sofisl bda6edf
fix: restore awk version extraction in showcase-version-check.yaml
sofisl f017d2f
Merge branch 'main' into showcase-version-check-workflow
sofisl 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 |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "strings" | ||
| ) | ||
|
|
||
| func main() { | ||
| showcaseVersion := flag.String("version", "", "The showcase version from pom.xml (e.g. 0.39.0)") | ||
| showcaseCommit := flag.String("commit", "", "The showcase commit from librarian.yaml (e.g. 328bec...)") | ||
| flag.Parse() | ||
|
|
||
| if *showcaseVersion == "" || *showcaseCommit == "" { | ||
| fmt.Fprintf(os.Stderr, "Error: Both -version and -commit flags must be provided\n") | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| tagName := "v" + *showcaseVersion | ||
| remoteUrl := "https://github.com/googleapis/gapic-showcase.git" | ||
|
|
||
| fmt.Printf("Showcase version: %s\n", *showcaseVersion) | ||
| fmt.Printf("Showcase commit: %s\n", *showcaseCommit) | ||
|
|
||
| // Query the remote gapic-showcase repository for the commit hash of the tag v{version}. | ||
| gitCommand := exec.Command("git", "ls-remote", remoteUrl, "refs/tags/"+tagName) | ||
| outputBytes, err := gitCommand.Output() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "Error running git ls-remote: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| var expectedCommit string | ||
| for _, line := range strings.Split(strings.TrimSpace(string(outputBytes)), "\n") { | ||
| fields := strings.Fields(line) | ||
| if len(fields) < 2 { | ||
| continue | ||
| } | ||
| if fields[1] == "refs/tags/"+tagName+"^{}" { | ||
| expectedCommit = fields[0] | ||
| break | ||
| } | ||
| if fields[1] == "refs/tags/"+tagName { | ||
| expectedCommit = fields[0] | ||
| } | ||
| } | ||
|
|
||
| if expectedCommit == "" { | ||
| fmt.Fprintf(os.Stderr, "Error: Tag %s not found on remote %s\n", tagName, remoteUrl) | ||
| os.Exit(1) | ||
| } | ||
| fmt.Printf("Expected commit for tag %s: %s\n", tagName, expectedCommit) | ||
|
|
||
| if *showcaseCommit != expectedCommit { | ||
| fmt.Fprintf(os.Stderr, "Mismatch: librarian.yaml has commit %q, but tag %q is at commit %q\n", *showcaseCommit, tagName, expectedCommit) | ||
| os.Exit(2) | ||
| } | ||
|
|
||
| fmt.Println("Showcase version and commit are in sync!") | ||
| } | ||
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,88 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| name: Showcase Version Check | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '30 3 * * *' # Run daily at 3:30 AM UTC | ||
| workflow_dispatch: # Allow manual trigger | ||
| pull_request: | ||
| paths: | ||
| - 'librarian.yaml' | ||
| - 'java-showcase/gapic-showcase/pom.xml' | ||
| - '.github/workflows/showcase-version-check.yaml' | ||
| - '.github/scripts/verify_showcase_version.go' | ||
|
|
||
| jobs: | ||
| check-version: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| issues: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Extract showcase version from pom.xml | ||
| id: extract_version | ||
| shell: bash | ||
| run: | | ||
| version=$(awk -F'[<>]' '/gapic-showcase.version/{print $3; exit}' java-showcase/gapic-showcase/pom.xml) | ||
|
sofisl marked this conversation as resolved.
|
||
| echo "version=$version" >> "$GITHUB_OUTPUT" | ||
| - name: Extract showcase commit from librarian.yaml | ||
| id: extract_commit | ||
| shell: bash | ||
| run: | | ||
| commit=$(grep -A 1 "showcase:" librarian.yaml | grep "commit:" | awk '{print $2}') | ||
|
zhumin8 marked this conversation as resolved.
Outdated
|
||
| echo "commit=$commit" >> "$GITHUB_OUTPUT" | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.24' | ||
| - name: Verify showcase version and commit match | ||
| shell: bash | ||
| run: | | ||
| set +e | ||
| go run .github/scripts/verify_showcase_version.go \ | ||
| -version "${{ steps.extract_version.outputs.version }}" \ | ||
| -commit "${{ steps.extract_commit.outputs.commit }}" | ||
| exit_code=$? | ||
| set -e | ||
| if [ $exit_code -eq 0 ]; then | ||
| echo "Verification successful!" | ||
| exit 0 | ||
| elif [ $exit_code -eq 2 ]; then | ||
| echo "MISMATCH=true" >> "$GITHUB_ENV" | ||
| echo "Error: Showcase version mismatch detected." | ||
| exit 2 | ||
| else | ||
| echo "Error: Unexpected verification failure (exit code $exit_code)." | ||
| exit 1 | ||
| fi | ||
| - name: Create issue on mismatch | ||
| if: failure() && env.MISMATCH == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh issue create \ | ||
| -R "${{ github.repository }}" \ | ||
| -t "Showcase Version Mismatch: librarian.yaml and pom.xml out of sync" \ | ||
| -b "The Showcase version in java-showcase/gapic-showcase/pom.xml and the commit in librarian.yaml do not match. Please update them to match. See logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
| - name: Create issue on workflow failure | ||
| if: failure() && env.MISMATCH != 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh issue create \ | ||
| -R "${{ github.repository }}" \ | ||
| -t "Showcase Version Check Workflow Failure" \ | ||
| -b "The Showcase Version Check workflow has failed due to an unexpected execution error. Please check the logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} for details." | ||
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.
Uh oh!
There was an error while loading. Please reload this page.