-
Notifications
You must be signed in to change notification settings - Fork 226
Add script and Github workflow for ensuring version in sync #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
a-hilaly
merged 3 commits into
aws-controllers-k8s:main
from
RedbackThomson:makefile-version-sync
Jul 21, 2021
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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=$(cat go.mod | grep $RUNTIME_DEPENDENCY_VERSION | cut -d ' ' -f2) | ||
|
|
||
| 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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can also use
go listto get the versionack/runtimemodule. Some thing similar to:go list -m -f '{{ .Version }}' github.com/aws-controllers-k8s/runtimeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh super cool! Thanks!