Skip to content

Commit 1f98983

Browse files
committed
Add GH workflow to check go mod tidy
We've had a couple occurrences of unused dependencies being merged. Ensure this doesn't happen. Signed-off-by: Adam Cmiel <acmiel@redhat.com>
1 parent 32f2b24 commit 1f98983

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/workflows/gomod-tidy.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: go mod tidy
2+
3+
"on":
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
gomod-tidy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
18+
with:
19+
go-version-file: go.mod
20+
21+
- name: Check if dependencies are tidy
22+
run: |
23+
#!/bin/bash
24+
set -o errexit -o nounset -o pipefail
25+
26+
go mod tidy
27+
28+
if ! git diff --quiet; then
29+
git diff --color
30+
echo "::error::go mod tidy made changes"
31+
echo "Please run 'go mod tidy' and commit the changes."
32+
exit 1
33+
fi

renovate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
4-
"config:recommended"
4+
"config:recommended",
5+
"helpers:pinGitHubActionDigestsToSemver"
56
],
67
"packageRules": [
78
{

0 commit comments

Comments
 (0)