Skip to content

Commit c876663

Browse files
Add script and Github workflow for ensuring version in sync (#130)
Adds a script that compares the `aws-controllers-k8s/runtime` version listed in the `go.mod` is identical to the `VERSION` variable in the `Makefile`. This way we can ensure the generation metadata is kept in line with the version of the runtime it was built against.
1 parent c13e5fe commit c876663

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.github/workflows/version-check.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: version-check
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
paths:
7+
- Makefile
8+
- go.mod
9+
10+
jobs:
11+
version-check:
12+
name: runtime version in-sync
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: checkout code
16+
uses: actions/checkout@v2
17+
- uses: actions/setup-go@v2
18+
with:
19+
go-version: '1.15'
20+
- name: make check-versions
21+
run: make check-versions

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ local-build-controller-image: export LOCAL_MODULES = true
4040
local-build-controller-image: ## Build container image for SERVICE allowing local modules
4141
@./scripts/build-controller-image.sh $(AWS_SERVICE)
4242

43+
check-versions: ## Checks the code-generator version matches the runtime dependency version
44+
@./scripts/check-versions.sh $(VERSION)
45+
4346
test: ## Run code tests
4447
go test ${GO_TAGS} ./...
4548

scripts/check-versions.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# A script that ensures the code-generator binary version matches its associated
4+
# runtime version
5+
6+
set -eo pipefail
7+
8+
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9+
ROOT_DIR="$SCRIPTS_DIR/.."
10+
11+
USAGE="
12+
Usage:
13+
$(basename "$0") <Makefile version>
14+
15+
Checks that the code-generator version located in the Makefile matches the
16+
runtime version pinned in go.mod
17+
"
18+
19+
if [ $# -ne 1 ]; then
20+
echo "ERROR: $(basename "$0") only accepts a single parameter" 1>&2
21+
echo "$USAGE"
22+
exit 1
23+
fi
24+
25+
RUNTIME_DEPENDENCY_VERSION="aws-controllers-k8s/runtime"
26+
GO_MOD_VERSION=$(go list -m -f '{{ .Version }}' github.com/aws-controllers-k8s/runtime)
27+
28+
if [[ "$1" != "$GO_MOD_VERSION" ]]; then
29+
echo "Code-generator version in Makefile $1 does not match $RUNTIME_DEPENDENCY_VERSION version $GO_MOD_VERSION"
30+
exit 1
31+
fi
32+
33+
exit 0

0 commit comments

Comments
 (0)