diff --git a/.circleci/config.yml b/.circleci/config.yml index 1cf997d5..fdad55cf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -76,6 +76,7 @@ jobs: - run: make style - run: make -C sigv4 style - run: make -C assets style + - run: make check-go-mod-version - when: condition: << parameters.use_gomod_cache >> steps: diff --git a/Makefile b/Makefile index 2ff51d19..b23a6b70 100644 --- a/Makefile +++ b/Makefile @@ -19,3 +19,8 @@ test:: deps check_license unused common-test lint .PHONY: generate-testdata generate-testdata: @cd config && go run generate.go + +.PHONY: check-go-mod-version +check-go-mod-version: + @echo ">> checking go.mod version matching" + @./scripts/check-go-mod-version.sh diff --git a/scripts/check-go-mod-version.sh b/scripts/check-go-mod-version.sh new file mode 100755 index 00000000..d651a620 --- /dev/null +++ b/scripts/check-go-mod-version.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +readarray -t mod_files < <(find . -type f -name go.mod) + +echo "Checking files ${mod_files[@]}" + +matches=$(awk '$1 == "go" {print $2}' "${mod_files[@]}" | sort -u | wc -l) + +if [[ "${matches}" -ne 1 ]]; then + echo 'Not all go.mod files have matching go versions' + exit 1 +fi