[release-1.32] chore: add a github action to guard go module drifts #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| - 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 | |
| ) | |
| 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 |