Skip to content

Commit

Permalink
ci: ensure that generated files have been regenerated as part of prer…
Browse files Browse the repository at this point in the history
…elease checks (#1312)

This adds a job to the prerelease checks workflow to make sure that
generated code is up-to-date at time of release - currently the only
code we actually generate is the static list of `spdx` licenses which
are sourced from
https://raw.githubusercontent.com/spdx/license-list-data/main/json/licenses.json

To verify this job works and showcase it's output, I've included a
commit adding it to the pr checks workflow - when we're happy with this,
I'll drop that commit before taking this out of draft

Also, here's an image of the annotation both on the file and in the
action log:


![image](https://github.com/user-attachments/assets/36a168d6-3f60-4efc-835e-842892d2530b)

![image](https://github.com/user-attachments/assets/d1b30f7f-19cd-4f98-8324-61b24abd0f8f)

Co-authored-by: Xueqin Cui <72771658+cuixq@users.noreply.github.com>
  • Loading branch information
G-Rath and cuixq authored Oct 21, 2024
1 parent 37559ac commit e054385
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/prerelease-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ jobs:
uses: ./.github/workflows/test-action
with:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
generators:
permissions:
contents: read # to fetch code (actions/checkout)
name: (re)generate code
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
persist-credentials: false
ref: ${{ inputs.commit }}
- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: stable
check-latest: true
- name: Run generators
run: go generate ./...
- run: |
git diff --name-only \
| xargs -I '{}' bash -c \
'echo "::error file={}::This needs to be regenerated by running \`go generate ./...\`" && false'
release-helper:
permissions:
contents: read # to fetch code (actions/checkout)
Expand Down

0 comments on commit e054385

Please sign in to comment.