Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/version-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: version-check
on:
pull_request:
branches:
- main
paths:
- Makefile
- go.mod

jobs:
version-check:
name: runtime version in-sync
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.15'
- name: make check-versions
run: make check-versions
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ local-build-controller-image: export LOCAL_MODULES = true
local-build-controller-image: ## Build container image for SERVICE allowing local modules
@./scripts/build-controller-image.sh $(AWS_SERVICE)

check-versions: ## Checks the code-generator version matches the runtime dependency version
@./scripts/check-versions.sh $(VERSION)

test: ## Run code tests
go test ${GO_TAGS} ./...

Expand Down
41 changes: 41 additions & 0 deletions scripts/check-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

# A script that ensures the code-generator binary version matches its associated
# runtime version

set -eo pipefail

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="$SCRIPTS_DIR/.."

DEFAULT_GO_MOD_PATH="$ROOT_DIR/go.mod"
GO_MOD_PATH=${GO_MOD_PATH:-$DEFAULT_GO_MOD_PATH}

USAGE="
Usage:
$(basename "$0") <Makefile version>

Checks that the code-generator version located in the Makefile matches the
runtime version pinned in go.mod

Environment variables:
GO_MOD_PATH: Overrides the path to the go.mod file containing the
pinned runtime version.
Default: $DEFAULT_GO_MOD_PATH
"

if [ $# -ne 1 ]; then
echo "ERROR: $(basename "$0") only accepts a single parameter" 1>&2
echo "$USAGE"
exit 1
fi

RUNTIME_DEPENDENCY_VERSION="aws-controllers-k8s/runtime"
GO_MOD_VERSION=$(go list -m -f '{{ .Version }}' github.com/aws-controllers-k8s/runtime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GO_MOD_PATH is not used, you can add another flag to specify the go.mod file: -modfile $GO_MOD_PATH


if [[ "$1" != "$GO_MOD_VERSION" ]]; then
echo "Code-generator version in Makefile $1 does not match $RUNTIME_DEPENDENCY_VERSION version $GO_MOD_VERSION"
exit 1
fi

exit 0