-
Notifications
You must be signed in to change notification settings - Fork 243
build: run goMod in ci #2428
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
build: run goMod in ci #2428
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: Renovate Post-Update Tasks / Go | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, edited] | ||
| paths: | ||
| - '**/go.mod' | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| gomodtidy: | ||
| # Only run on Renovate PRs | ||
| if: startsWith(github.head_ref, 'renovate/') | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| ref: ${{ github.head_ref }} | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 | ||
| with: | ||
| go-version-file: collector/go.mod | ||
| - run: find . -name "go.mod" -execdir go mod tidy \; | ||
| - name: Check if go mod changed | ||
| id: check_changes | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| run: | | ||
| git fetch origin "$BASE_REF" | ||
| if git diff --name-only "origin/$BASE_REF" HEAD \ | ||
| | grep -E '^(.*/)?go\.(mod|sum)$' >/dev/null; then | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Commit and push changes | ||
| if: steps.check_changes.outputs.changed == 'true' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add collector/ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The go sample app is not included in this, if that was intended it's fine by me though.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good spot, i do however think sample-apps are ok as some updates are currently working. I am inclined to leave it as is given it unblocks ci & only add the additional path if we need it & we have a way to test it. |
||
| if git diff --staged --quiet; then | ||
| echo "No changes to commit" | ||
| else | ||
| git commit -m "chore: go mod tidy" | ||
| git push | ||
| fi | ||
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.
Not 100% sure, but isn't this dangerous? When
go mod tidyfails, the error would be swallowed? Or would we be able to see that failure in a later workflow that runs on the PR? (I think so, just checking to make sure...)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.
Yes it should be seen in the build workflow like we are seeing atm.