Skip to content

Commit 186e03b

Browse files
committed
feat: upgrade test
1 parent 1c9f8c4 commit 186e03b

1 file changed

Lines changed: 129 additions & 0 deletions

File tree

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Upgrade Test Workflow
2+
3+
# triggered on workflow dispatch
4+
5+
permissions:
6+
contents: read
7+
packages: write
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
source:
13+
description: "Source version"
14+
required: true
15+
default: "v0.3.0"
16+
target:
17+
description: "Target version"
18+
required: false
19+
20+
jobs:
21+
# if the target is not set, we want to take the latest git commit of the branch and build the image with that.
22+
build-test-version:
23+
if: ${{ github.event.inputs.target == '' }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Setup Docker Buildx
27+
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0
28+
with:
29+
version: v0.15.1
30+
install: true
31+
- name: Checkout code
32+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
33+
with:
34+
submodules: true
35+
- name: Fetch History
36+
run: git fetch --prune --unshallow
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
40+
with:
41+
go-version: "1.21"
42+
43+
- name: Vendor Dependencies
44+
run: make vendor vendor.check
45+
46+
- name: Set up Version
47+
run: |
48+
echo "BUILD_IMAGE_VERSION=v0.0.0-draft-${{ github.sha }}" >> $GITHUB_ENV
49+
echo "version is $BUILD_IMAGE_VERSION"
50+
- name: Build Images
51+
run: make build VERSION=$BUILD_IMAGE_VERSION
52+
env:
53+
# We're using docker buildx, which doesn't actually load the images it
54+
# builds by default. Specifying --load does so.
55+
BUILD_ARGS: "--load"
56+
DOCKER_REGISTRY: ${{ vars.REGISTRY_URL }}
57+
BUILD_REGISTRY: ${{ vars.REGISTRY_URL }}
58+
59+
- name: Login to Container Registry
60+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
61+
with:
62+
registry: ${{ vars.REGISTRY_URL }}
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
- name: Publish Artifacts to DockerHub
66+
run: make publish BRANCH_NAME=${GITHUB_REF##*/} VERSION=$BUILD_IMAGE_VERSION
67+
env:
68+
DOCKER_REGISTRY: ${{ vars.REGISTRY_URL }}
69+
BUILD_REGISTRY: ${{ vars.REGISTRY_URL }}
70+
71+
upgrade-test:
72+
needs: [build-test-version]
73+
runs-on: ubuntu-latest
74+
if: always() # would also run if build-test-version fails but we just fail too
75+
steps:
76+
# if the target is not set, use the version built in the build-test-version job
77+
# if triggered with source and target we just use these to versions for the test
78+
- name: Set TARGET_IMAGE_VERSION
79+
run: |
80+
if [ -z "${{ github.event.inputs.target }}" ]; then
81+
echo "TARGET_IMAGE_VERSION=$BUILD_IMAGE_VERSION" >> $GITHUB_ENV
82+
else
83+
echo "TARGET_IMAGE_VERSION=${{ github.event.inputs.target }}" >> $GITHUB_ENV
84+
fi
85+
86+
- name: Clone provider-upgrade-test repo
87+
run: |
88+
git clone https://github.com/openmcp-project/provider-upgrade-test.git
89+
echo "Repository provider-upgrade-test cloned successfully."
90+
91+
- name: Install CLI Tools
92+
run: |
93+
echo "Installing Kind..."
94+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
95+
chmod +x ./kind
96+
sudo mv ./kind /usr/local/bin/kind
97+
98+
echo "Installing Kubectl..."
99+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
100+
chmod +x kubectl
101+
sudo mv kubectl /usr/local/bin/
102+
103+
echo "Installing Chainsaw..."
104+
curl -LO https://github.com/kyverno/chainsaw/releases/download/v0.2.12/chainsaw_linux_amd64.tar.gz && \
105+
tar -xzvf chainsaw_linux_amd64.tar.gz && \
106+
chmod +x chainsaw && \
107+
sudo mv chainsaw /usr/local/bin/chainsaw && \
108+
chainsaw version
109+
110+
echo "Installing sed..."
111+
sudo apt-get update && sudo apt-get install -y sed
112+
113+
echo "Installing jq..."
114+
sudo apt-get install -y jq
115+
116+
echo "Installing yq..."
117+
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
118+
sudo chmod +x /usr/bin/yq
119+
120+
echo "All tools installed successfully."
121+
- name: Run upgrade test
122+
if: github.event_name == 'workflow_dispatch'
123+
run: |
124+
cd provider-upgrade-test
125+
echo "Running upgrade test..."
126+
REGISTRY=ghcr.io/sap/crossplane-provider-cloudfoundry/crossplane/provider-cloudfoundry && ./provider-test.sh upgrade-test --source "${REGISTRY}:${{ github.event.inputs.source }}" --target ${REGISTRY}:${TARGET_IMAGE_VERSION} --provider provider-cloudfoundry
127+
env:
128+
CF_CREDENTIALS: ${{ secrets.CF_CREDENTIALS }}
129+
CF_ENVIRONMENT: ${{ secrets.CF_ENVIRONMENT }}

0 commit comments

Comments
 (0)