Skip to content

Commit a31e2e5

Browse files
committed
CI: Verify "go mod tidy" in every go module
We create a simple helper script, and call it from the github action.
1 parent aae728e commit a31e2e5

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
4848
- uses: actions/checkout@v2
4949

50-
- run: go mod tidy
50+
- run: dev/format-gomod
5151

5252
- run: |
5353
changes=$(git status --porcelain)

dev/format-gomod

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Copyright 2022 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# CI script to run all the test commands
19+
20+
set -o errexit
21+
set -o nounset
22+
set -o pipefail
23+
24+
# cd to the repo root
25+
REPO_ROOT=$(git rev-parse --show-toplevel)
26+
cd "${REPO_ROOT}"
27+
28+
# Run go mod tidy in each go module
29+
for module in $(find . -name "go.mod"); do
30+
dir="$(dirname ${module})"
31+
pushd "${dir}"
32+
go mod tidy
33+
popd
34+
done

0 commit comments

Comments
 (0)