Skip to content

[release-1.32] chore: add a github action to guard go module drifts #10

[release-1.32] chore: add a github action to guard go module drifts

[release-1.32] chore: add a github action to guard go module drifts #10

name: Go Module Consistency
on:
push:
branches: [ master, 'release-**' ]
pull_request:
branches: [ master, 'release-**' ]
permissions:
contents: read
jobs:
go-mod-consistency:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v4.2.2
- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
check-latest: true
cache-dependency-path: |
go.sum
tests/go.sum
pkg/azclient/go.sum
pkg/azclient/cache/go.sum
pkg/azclient/configloader/go.sum
pkg/azclient/trace/go.sum
pkg/azclient/client-gen/go.sum
health-probe-proxy/go.sum
kubetest2-aks/go.sum
- name: Run go mod tidy and verify
run: |
set -euo pipefail
modules=(
.
tests
pkg/azclient
pkg/azclient/cache
pkg/azclient/configloader
pkg/azclient/trace
pkg/azclient/client-gen
health-probe-proxy
kubetest2-aks
)
for m in "${modules[@]}"; do
echo ">> go mod tidy (${m})"
(cd "${m}" && go mod tidy)
echo ">> go mod verify (${m})"
(cd "${m}" && go mod verify)
done
- name: Fail on uncommitted changes
run: |
git diff --stat
git diff --quiet