Skip to content
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

Verify various version related assumptions during CI #20

Merged
merged 32 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6538b8e
verify operator version assumptions in CI
Aug 1, 2024
7a7e285
comment out other jobs and print target branch
Aug 1, 2024
9e87402
change variable name
Aug 1, 2024
b71abe8
check for operator changes
Aug 1, 2024
78931ab
call function
Aug 1, 2024
e8448d1
use origin for remote branch
Aug 1, 2024
589e963
add -- to git diff command
Aug 1, 2024
4604218
fetch main
Aug 1, 2024
b1328f7
add else
Aug 1, 2024
99a384a
try to display git tag
Aug 1, 2024
01eade5
test outputs
Aug 1, 2024
e33e4c0
verify operator version bump
Aug 1, 2024
0d3cbed
split version check into separate script
Aug 5, 2024
da6f994
add verify version bump for each artifact
Aug 8, 2024
aefddbd
always run verify-versions and release requires it
Aug 9, 2024
4dc5d38
see if git tag prefix is an env
Aug 9, 2024
1f72508
have workflow use correct script
Aug 9, 2024
ba3a397
update operator to use minimal app latest tag
Aug 9, 2024
626009c
update minimal-app to grab correct version from pom
Aug 9, 2024
4fe3215
increment all 3 versions
Aug 9, 2024
21690ab
improve error message of operator not using latest webhook img
Aug 9, 2024
55895b8
update operator to use latest webhook img
Aug 9, 2024
f1ba07e
uncomment build jobs
Aug 9, 2024
0567545
uncomment webhook build job
Aug 9, 2024
bb81faa
test release jobs
Aug 9, 2024
0a89a81
update webhook release to use correct image name
Aug 9, 2024
4b2d3e1
remove VERSION variable no longer used
Aug 9, 2024
66375aa
release jobs go back to only running on main
Aug 9, 2024
d1bba92
remove references to get-version
Aug 9, 2024
3ba2a08
remove unused version variable
Aug 9, 2024
56710a2
trigger release job for testing
Aug 9, 2024
f278f92
Revert "trigger release job for testing"
Aug 9, 2024
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
8 changes: 7 additions & 1 deletion .github/workflows/minimal-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ env:
GIT_TAG_PREFIX: minimal-app_v

jobs:
verify-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sh .github/workflows/scripts/verify_minimal_app_releasable.sh
name: Verify minimal app is in a state to be released on merge
build:
name: build image
if: github.ref != 'refs/heads/main'
Expand All @@ -38,6 +44,7 @@ jobs:

release:
if: github.ref == 'refs/heads/main'
needs: verify-versions
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -52,7 +59,6 @@ jobs:
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
REGISTRY=$(mvn help:evaluate -Dexpression=docker.registry -q -DforceStdout)
IMAGE_NAME=$(mvn help:evaluate -Dexpression=image-name -q -DforceStdout)
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "REGISTRY=$REGISTRY" >> "$GITHUB_OUTPUT"
echo "TAG_NAME=${{ env.GIT_TAG_PREFIX }}$VERSION" >> "$GITHUB_OUTPUT"
echo "IMAGE_NAME=$REGISTRY/$IMAGE_NAME:$VERSION" >> "$GITHUB_OUTPUT"
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ on:

env:
WORKING_DIR: ./operator
GIT_TAG_PREFIX: operator_v

jobs:
verify-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sh .github/workflows/scripts/verify_operator_releasable.sh
name: Verify operator is in a state to be released on merge

build:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
Expand All @@ -32,6 +38,7 @@ jobs:

release:
if: github.ref == 'refs/heads/main'
needs: verify-versions
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -40,10 +47,10 @@ jobs:
steps:
- uses: actions/checkout@v4

# set variables used by multiple steps in the job
- run: |
VERSION=$(make get-version)
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "TAG_NAME=${{ env.GIT_TAG_PREFIX }}$VERSION" >> "$GITHUB_OUTPUT"
TAG_NAME=$(make get-tag)
echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_OUTPUT"
cat $GITHUB_OUTPUT
id: naming-selector
name: generate names for artifacts
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/scripts/verify_changes_update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Verifies changes to directory have an updated version

if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: sh $0 [potential_git_tag] <path_to_directory>"
exit 1
fi

set -eux

POTENTIAL_GIT_TAG=$1
DIRECTORY=$2

main() {
# github actions job does not fetch other git objects by default
git fetch origin $GITHUB_BASE_REF
git fetch --tags

changes_in_pr=$(git diff origin/$GITHUB_BASE_REF -- $DIRECTORY)
if [ -n "$changes_in_pr" ]; then
echo "Found changes between current branch and $GITHUB_BASE_REF"
if git tag | grep -x "$POTENTIAL_GIT_TAG"; then
echo "$POTENTIAL_GIT_TAG was already released. Please increment the version if changes were made to $DIRECTORY."
exit 1
fi
fi
}

main
11 changes: 11 additions & 0 deletions .github/workflows/scripts/verify_minimal_app_releasable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -eux

MINIMAL_APP_DIR=minimal-app

verify_version_bump() {
version=$(mvn -f minimal-app/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
potential_tag="${GIT_TAG_PREFIX}${version}"
sh .github/workflows/scripts/verify_changes_update_version.sh $potential_tag $MINIMAL_APP_DIR
}

verify_version_bump
22 changes: 22 additions & 0 deletions .github/workflows/scripts/verify_operator_releasable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set -eux

OPERATOR_DIR=operator
OPERATOR_CONTROLLER_YAML=$OPERATOR_DIR/controller/integrationroute-controller.yaml

verify_current_webhook_img() {
current_webhook_img=$(make --no-print-directory -C operator/webhook get-image-name)
webhook_image_used=$(yq eval '.spec.template.spec.containers[].image' $OPERATOR_CONTROLLER_YAML)
jhunzik marked this conversation as resolved.
Show resolved Hide resolved

test -n "$current_webhook_img"
test -n "$webhook_image_used"

test "$webhook_image_used" = "$current_webhook_img" || (echo "Operator is not using current version of webhook image" && exit 1)
}

verify_version_bump() {
potential_tag=$(make --no-print-directory -C $OPERATOR_DIR get-tag)
sh .github/workflows/scripts/verify_changes_update_version.sh $potential_tag $OPERATOR_DIR
}

verify_current_webhook_img
verify_version_bump
10 changes: 10 additions & 0 deletions .github/workflows/scripts/verify_webhook_releasable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set -eux

WEBHOOK_DIR=operator/webhook

verify_version_bump() {
potential_tag=$(make --no-print-directory -C $WEBHOOK_DIR get-tag)
sh .github/workflows/scripts/verify_changes_update_version.sh $potential_tag $WEBHOOK_DIR
}

verify_version_bump
16 changes: 10 additions & 6 deletions .github/workflows/webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ on:

env:
WORKING_DIR: ./operator/webhook
GIT_TAG_PREFIX: webhook_v

jobs:
verify-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sh .github/workflows/scripts/verify_webhook_releasable.sh
name: Verify webhook is in a state to be released on merge
test:
name: unit test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -50,7 +55,7 @@ jobs:
push: false

release:
needs: test
needs: [test, verify-versions]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
defaults:
Expand All @@ -63,13 +68,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: |
VERSION=$(make get-version)
REGISTRY=$(make get-registry)
IMAGE_NAME=$(make get-image-name)
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
GIT_TAG=$(make get-tag)
echo "REGISTRY=$REGISTRY" >> "$GITHUB_OUTPUT"
echo "TAG_NAME=${{ env.GIT_TAG_PREFIX }}$VERSION" >> "$GITHUB_OUTPUT"
echo "FULL_IMAGE_NAME=$REGISTRY/$IMAGE_NAME:$VERSION" >> "$GITHUB_OUTPUT"
echo "TAG_NAME=$GIT_TAG" >> "$GITHUB_OUTPUT"
echo "FULL_IMAGE_NAME=$IMAGE_NAME" >> "$GITHUB_OUTPUT"
cat $GITHUB_OUTPUT
id: naming-selector
name: generate names for artifacts
Expand Down
3 changes: 2 additions & 1 deletion minimal-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.octo.keip</groupId>
<artifactId>minimal-app</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>

<properties>
<docker.registry>ghcr.io/octoconsulting</docker.registry>
Expand Down Expand Up @@ -118,6 +118,7 @@
<to>
<image>${docker.registry}/${image-name}</image>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</to>
Expand Down
11 changes: 6 additions & 5 deletions operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VERSION ?= 0.3.1
KEIP_INTEGRATION_IMAGE ?= ghcr.io/octoconsulting/keip/minimal-app:0.0.2
VERSION ?= 0.3.2
GIT_TAG := operator_v$(VERSION)
KEIP_INTEGRATION_IMAGE ?= ghcr.io/octoconsulting/keip/minimal-app:latest

KUBECTL := kubectl
KUBECTL_DELETE := $(KUBECTL) delete --ignore-not-found
Expand All @@ -11,9 +12,9 @@ all: metacontroller/deploy controller/deploy
.PHONY: clean
clean: controller/undeploy metacontroller/undeploy

.PHONY: get-version
get-version:
@echo $(VERSION)
.PHONY: get-tag
get-tag:
@echo $(GIT_TAG)

prep-release:
rm -rf output
Expand Down
2 changes: 1 addition & 1 deletion operator/controller/integrationroute-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
spec:
containers:
- name: webhook
image: ghcr.io/octoconsulting/keip/route-webhook:0.6.1
image: ghcr.io/octoconsulting/keip/route-webhook:0.6.2
ports:
- containerPort: 7080
name: webhook-http
Expand Down
11 changes: 6 additions & 5 deletions operator/webhook/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VERSION ?= 0.6.1
VERSION ?= 0.6.2
HOST_PORT ?= 7080
GIT_TAG := webhook_v$(VERSION)

IMG_REGISTRY := ghcr.io/octoconsulting
IMG_NAME := keip/route-webhook
Expand All @@ -9,17 +10,17 @@ PYTHON := python3
TEST_COVERAGE_DIR := .test_coverage
TEST_COVERAGE_FILE := $(TEST_COVERAGE_DIR)/.coverage

.PHONY: get-version
get-version:
@echo $(VERSION)
.PHONY: get-tag
get-tag:
@echo $(GIT_TAG)

.PHONY: get-registry
get-registry:
@echo $(IMG_REGISTRY)

.PHONY: get-image-name
get-image-name:
@echo $(IMG_NAME)
@echo $(FULL_IMAGE_NAME)

.PHONY: start-dev
start-dev-server:
Expand Down
Loading