Skip to content

Commit c3dd3d7

Browse files
chore: create workflow to check showcase commit (#13305)
A workflow to make sure the showcase commit is the same as what is in librarian. If the workflow fails, or there is a mismatch, an issue will be created. Fixes googleapis/librarian#6200 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 5efbb46 commit c3dd3d7

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Showcase Version Check
16+
17+
on:
18+
schedule:
19+
- cron: '30 3 * * *' # Run daily at 3:30 AM UTC
20+
workflow_dispatch: # Allow manual trigger
21+
pull_request:
22+
paths:
23+
- 'librarian.yaml'
24+
- 'java-showcase/gapic-showcase/pom.xml'
25+
- '.github/workflows/showcase-version-check.yaml'
26+
27+
jobs:
28+
check-version:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
issues: write
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Extract showcase version from pom.xml
35+
id: extract_version
36+
shell: bash
37+
run: |
38+
version=$(awk -F'[<>]' '/gapic-showcase.version/{print $3; exit}' java-showcase/gapic-showcase/pom.xml)
39+
echo "version=$version" >> "$GITHUB_OUTPUT"
40+
- name: Set up Go
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version: '1.24'
44+
- name: Extract showcase commit from librarian.yaml
45+
id: extract_commit
46+
shell: bash
47+
run: |
48+
version=$(go run github.com/googleapis/librarian/cmd/librarian@latest config get version)
49+
commit=$(go run "github.com/googleapis/librarian/cmd/librarian@${version}" config get sources.showcase.commit)
50+
echo "commit=$commit" >> "$GITHUB_OUTPUT"
51+
- name: Verify showcase version and commit match
52+
shell: bash
53+
run: |
54+
# 1. Query the remote repository for the specific version tag
55+
REMOTE_URL="https://github.com/googleapis/gapic-showcase.git"
56+
TAG_NAME="v${{ steps.extract_version.outputs.version }}"
57+
58+
OUTPUT=$(git ls-remote "$REMOTE_URL" "refs/tags/$TAG_NAME")
59+
60+
if [ -z "$OUTPUT" ]; then
61+
echo "Error: Tag $TAG_NAME not found on remote $REMOTE_URL"
62+
exit 1
63+
fi
64+
65+
# 2. Grab the commit hash from the very last line of the output
66+
EXPECTED_COMMIT=$(echo "$OUTPUT" | tail -n 1 | awk '{print $1}')
67+
68+
echo "Expected commit for tag $TAG_NAME: $EXPECTED_COMMIT"
69+
echo "Current librarian commit: ${{ steps.extract_commit.outputs.commit }}"
70+
71+
# 3. Cross-reference with librarian.yaml
72+
if [ "${{ steps.extract_commit.outputs.commit }}" != "$EXPECTED_COMMIT" ]; then
73+
echo "Mismatch: librarian.yaml has commit '${{ steps.extract_commit.outputs.commit }}', but tag '$TAG_NAME' is at commit '$EXPECTED_COMMIT'"
74+
echo "MISMATCH=true" >> "$GITHUB_ENV"
75+
exit 2
76+
fi
77+
78+
echo "Showcase version and commit are in sync!"
79+
- name: Create issue on mismatch
80+
if: failure() && env.MISMATCH == 'true'
81+
env:
82+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
run: |
84+
gh issue create \
85+
-R "${{ github.repository }}" \
86+
-t "Showcase Version Mismatch: librarian.yaml and pom.xml out of sync" \
87+
-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 }}"
88+
- name: Create issue on workflow failure
89+
if: failure() && env.MISMATCH != 'true'
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: |
93+
gh issue create \
94+
-R "${{ github.repository }}" \
95+
-t "Showcase Version Check Workflow Failure" \
96+
-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."

0 commit comments

Comments
 (0)