Skip to content
Snippets Groups Projects
Unverified Commit d95c019e authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

feat: add go mod tidy check

parent ac46a9d4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -346,3 +346,29 @@ include:
ref: v1.11.0 # renovate:managed
file: go-unittests.yml
```
### [`go-mod-tidy`](./go-mod-tidy.yml)
Ensures that [`go mod tidy`](https://go.dev/ref/mod) is up-to-date and `go.mod` and `go.sum` are tidy.
1. Ensure that the `GL_ASDF_GOLANG_VERSION` version for Go is configured.
```yaml
stages:
- validate
# Not needed if .gitlab-ci-asdf-versions.yml is included...
variables:
GL_ASDF_GOLANG_VERSION: ...
include:
# Not required, but recommended
- local: .gitlab-ci-asdf-versions.yml
# Perform `go mod tidy` and ensure that go.mod and go.sum are tidy.
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#go-mod-tidy
- project: 'gitlab-com/gl-infra/common-ci-tasks'
ref: v1.12.0 # renovate:managed
file: go-mod-tidy.yml
```
go_mod_tidy:
image: golang:${GL_ASDF_GOLANG_VERSION}
stage: validate
needs: []
script:
- go mod tidy
- git diff --exit-code || {
echo "running 'go mod tidy' produced changes.";
echo "please run 'go mod tidy' and commit the changes.";
exit 1;
}
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment