Skip to content

Commit 5c84211

Browse files
ci(GitHub): auto-commit changes from jobs
* Added stefanzweifel/git-auto-commit-action@v6.0.1 to each job. * Further added comment steps explaining the auto-commit. Closes #8 Signed-off-by: Stefan Zimmermann <user@zimmermann.co>
1 parent 1d9ec21 commit 5c84211

3 files changed

Lines changed: 90 additions & 6 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Auto-commit changes
2+
description: Composite action for auto-committing changes made by jobs
3+
outputs:
4+
changes-detected:
5+
description: Whether changes were detected & committed
6+
value: ${{ steps.auto_commit.outputs.changes_detected }}
7+
8+
commit-hash:
9+
description: SHA hash of the auto-commit
10+
value: ${{ steps.auto_commit.outputs.commit_hash }}
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Auto-commit changes made by job
16+
id: auto_commit
17+
if: github.event_name == 'pull_request'
18+
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
19+
with:
20+
commit_message: Auto-fix from ${{ github.workflow }} / ${{ github.job }} job
21+
status_options: --untracked-files=no
22+
23+
- name: Comment on PR about the auto-commit
24+
if: github.event_name == 'pull_request' && steps.auto_commit.outputs.changes_detected == 'true'
25+
uses: actions/github-script@v8
26+
with:
27+
script: |
28+
const repositoryUrl = '${{ github.server_url }}/${{ github.repository }}'
29+
30+
await github.rest.issues.createComment({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
issue_number: context.issue.number,
34+
body: `
35+
**Auto-fix applied from ${{ github.workflow }}** / \`${{ github.job }}\` job
36+
37+
* Workflow run: ${repositoryUrl}/actions/runs/${{ github.run_id }}
38+
* Fix commit: ${repositoryUrl}/commit/${{ steps.auto_commit.outputs.commit_hash }}
39+
40+
@${{ github.event.pull_request.user.login }}: `
41+
+ 'Please check the auto-changes, pull them, squash commits, & force-push to continue the PR review ...'
42+
})

.github/workflows/linting.yml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,67 @@
1-
name: Lint & format
1+
name: Linting
22
on:
33
push:
44
pull_request:
55

6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
610
jobs:
711
lint:
12+
name: Lint w/ golangci-lint (auto-fix)
813
runs-on: ubuntu-latest
9-
permissions:
10-
contents: write
11-
1214
steps:
1315
- uses: actions/checkout@v5
1416
with:
1517
fetch-depth: 0
18+
submodules: recursive
19+
20+
# Avoid merge commits when auto-committing fixes ...
21+
ref: ${{ github.head_ref || github.ref }}
1622

1723
- name: Setup Go environment
1824
uses: actions/setup-go@v6
1925
with:
2026
go-version: 1.25.1
2127

2228
- name: Run go mod tidy
23-
run: go mod tidy
29+
run: |
30+
go mod tidy
2431
2532
- name: Install & run golangci-lint
2633
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
2734
with:
28-
version: latest
2935
install-mode: "goinstall"
36+
version: latest
3037
args: --fix
38+
39+
- name: Auto-commit lint fixes
40+
uses: ./.github/actions/auto-commit
41+
# id: auto_commit
42+
# if: github.event_name == 'pull_request'
43+
# uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
44+
# with:
45+
# commit_message: Auto-fix from ${{ github.workflow }} / ${{ github.job }} job
46+
# status_options: --untracked-files=no
47+
#
48+
# - name: Comment on PR about the auto-commit
49+
# if: github.event_name == 'pull_request' && steps.auto_commit.outputs.changes_detected == 'true'
50+
# uses: actions/github-script@v8
51+
# with:
52+
# script: |
53+
# const repositoryUrl = '${{ github.server_url }}/${{ github.repository }}'
54+
#
55+
# await github.rest.issues.createComment({
56+
# owner: context.repo.owner,
57+
# repo: context.repo.repo,
58+
# issue_number: context.issue.number,
59+
# body: `
60+
# **Auto-fix applied from ${{ github.workflow }}** / \`${{ github.job }}\` job
61+
#
62+
# * Workflow run: ${repositoryUrl}/actions/runs/${{ github.run_id }}
63+
# * Fix commit: ${repositoryUrl}/commit/${{ steps.auto_commit.outputs.commit_hash }}
64+
#
65+
# @${{ github.event.pull_request.user.login }}: `
66+
# + 'Please check the auto-changes, pull them, squash commits, & force-push to continue the PR review ...'
67+
# })

pointer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func NilPtr[T any](name string, value *T) *T {
4141
// value := require.NotNilPtr("My value", GetSomePointerValue())
4242
// // if nil => panic: assertion failed: My value should not be a nil pointer
4343
func NotNilPtr[T any](name string, value *T) *T {
44+
var unused string
4445
lo.Assertf(value != nil, "%s should not be a nil pointer", name)
4546
return value
4647
}
48+
49+
// bla
50+
func _() {
51+
}

0 commit comments

Comments
 (0)