From 82accf3617aa1f59bbbd78a6290cbf578a85cb9e Mon Sep 17 00:00:00 2001 From: SuperQ Date: Sat, 10 Dec 2022 01:03:32 +0100 Subject: [PATCH] Add go mod version test Add a script to make sure go.mod Go versions stay in sync. Signed-off-by: SuperQ --- .circleci/config.yml | 1 + Makefile | 5 +++++ scripts/check-go-mod-version.sh | 12 ++++++++++++ 3 files changed, 18 insertions(+) create mode 100755 scripts/check-go-mod-version.sh 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