Skip to content

Commit 6544972

Browse files
authored
chore: add a post-submit check that regenerating doesn't change anything (googleapis#16941)
This is a post-submit as it takes a while (~25 minutes). We could *potentially* make it a pre-submit and only generate packages which have changed, but that would be more fiddly. It would be nice not to specify the protoc or pandoc version here, but that will require improvements in librarian (tracked in googleapis/librarian#5818). Fixes googleapis/librarian#4800
1 parent b2885ad commit 6544972

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Regenerate all packages after merging to main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
12+
jobs:
13+
regenerate:
14+
runs-on: ubuntu-latest
15+
env:
16+
PANDOC_VERSION: 3.8.2
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v6
21+
22+
- name: Install Go
23+
uses: actions/setup-go@v6
24+
with:
25+
go-version: '1.26.x'
26+
27+
- name: Install protoc
28+
uses: arduino/setup-protoc@v3
29+
with:
30+
version: "25.3"
31+
32+
- name: Install pandoc
33+
run: |
34+
mkdir /tmp/pandoc
35+
curl -fsSL --retry 5 --retry-delay 15 -o /tmp/pandoc.tar.gz \
36+
https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz
37+
tar -xvf /tmp/pandoc.tar.gz -C /tmp/pandoc --strip-components=1
38+
39+
- name: Install Python packages for Librarian
40+
run: |
41+
version=$(sed -n 's/^version: *//p' librarian.yaml)
42+
go run "github.com/googleapis/librarian/cmd/librarian@${version}" install
43+
44+
- name: Regenerate
45+
run: |
46+
version=$(sed -n 's/^version: *//p' librarian.yaml)
47+
PATH=$PATH:/tmp/pandoc/bin
48+
go run "github.com/googleapis/librarian/cmd/librarian@${version}" generate -all -v
49+
50+
- name: Create issue on diff
51+
if: failure()
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
if [ -n "$(git status --porcelain)" ]; then
56+
TITLE="Regeneration check found diff"
57+
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
58+
DIFF_STAT=$(git diff --stat)
59+
BODY="The post-submit [regeneration check]($RUN_URL) found a diff.
60+
61+
Diff summary:
62+
\`\`\`
63+
$DIFF_STAT
64+
\`\`\`"
65+
66+
EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number')
67+
if [ -z "$EXISTING_ISSUE" ]; then
68+
gh issue create --title "$TITLE" --body "$BODY"
69+
else
70+
echo "Issue #$EXISTING_ISSUE already exists, adding a comment."
71+
gh issue comment "$EXISTING_ISSUE" --body "Another failure with diff occurred: $RUN_URL"
72+
fi
73+
fi

0 commit comments

Comments
 (0)