Skip to content

Commit 92e7186

Browse files
committed
ci: validate golangci-default.yaml and trigger on its changes
1 parent 9159e85 commit 92e7186

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

‎.github/workflows/main.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
paths:
88
- ".github/actions/**"
99
- ".github/workflows/**"
10-
- ".github/semantic-release/**"
10+
- "golangci-default.yaml"
1111
- "README.md"
1212
workflow_dispatch:
1313

‎.github/workflows/pr.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
paths:
88
- ".github/actions/**"
99
- ".github/workflows/**"
10-
- ".github/semantic-release/**"
10+
- "golangci-default.yaml"
1111
- "README.md"
1212

1313
permissions:

‎.github/workflows/validate.yaml‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,48 @@ jobs:
5151
echo "- Review the job logs for details."
5252
} >> "$GITHUB_STEP_SUMMARY"
5353
fi
54+
55+
golangci-config:
56+
# go-lint.yaml fetches golangci-default.yaml from this repo at runtime for
57+
# every consumer without a local golangci config, so a malformed or invalid
58+
# edit here breaks lint across the estate. Validate the file on every change
59+
# (it's in this workflow's paths filter) with the same golangci-lint major
60+
# version consumers install via go-lint.yaml.
61+
name: golangci config verify
62+
runs-on: ${{ inputs.runs-on }}
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
66+
67+
- name: Set up Go
68+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
69+
with:
70+
cache: false
71+
go-version: "1.26.2"
72+
73+
- name: Install golangci-lint
74+
shell: bash
75+
run: |
76+
GOBIN="$RUNNER_TEMP/bin" go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
77+
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
78+
79+
- name: Verify golangci-default.yaml
80+
id: golangci-config
81+
run: golangci-lint config verify --config golangci-default.yaml
82+
83+
- name: golangci config summary
84+
if: always()
85+
run: |
86+
if [ "${{ steps.golangci-config.outcome }}" = "success" ]; then
87+
{
88+
echo "### golangci config verify"
89+
echo "golangci-default.yaml is valid."
90+
} >> "$GITHUB_STEP_SUMMARY"
91+
else
92+
{
93+
echo "### golangci config verify"
94+
echo "golangci-default.yaml failed validation."
95+
echo ""
96+
echo "- Review the job logs for details."
97+
} >> "$GITHUB_STEP_SUMMARY"
98+
fi

0 commit comments

Comments
 (0)