Skip to content

Commit bdeddfc

Browse files
committed
ci: use locally built image in the e2e tests
Load the just built image into the kind cluster before running the e2e tests. This ensure we are testing the changes on the branch before we publish them. Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
1 parent 5dfd372 commit bdeddfc

File tree

2 files changed

+45
-23
lines changed

2 files changed

+45
-23
lines changed

.github/workflows/build.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: build
22

33
on:
44
push:
5-
branches: [ '*' ]
5+
branches: ["*"]
66
pull_request:
7-
branches: [ '*' ]
7+
branches: ["*"]
88

99
jobs:
1010
build:
@@ -48,17 +48,19 @@ jobs:
4848
platforms: linux/amd64,linux/arm/v7,linux/arm64
4949
tags: |
5050
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
51-
# Todo - load the image into Kind before running tests
52-
# otherwise, this just tests the chart with images that
53-
# have already been built and pushed in an earlier job
5451
- name: get tools
5552
run: ./contrib/get_tools.sh
5653
- name: lint chart
5754
run: ./contrib/lint_chart.sh
5855
- name: create cluster
5956
run: ./contrib/create_cluster.sh
57+
- name: load CI image into kind
58+
run: kind load docker-image ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
6059
- name: deploy function
61-
run: OPERATOR=0 ./contrib/deploy.sh
60+
run: |
61+
export OPERATOR=0
62+
export IMAGE=ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
63+
./contrib/deploy.sh
6264
- name: run function
6365
run: OPERATOR=0 ./contrib/run_function.sh
6466
- name: stop dev cluster
@@ -67,12 +69,16 @@ jobs:
6769
run: sleep 10
6870
- name: create cluster
6971
run: ./contrib/create_cluster.sh
72+
- name: load CI image into kind
73+
run: kind load docker-image ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
7074
- name: deploy function
71-
run: OPERATOR=1 ./contrib/deploy.sh
75+
run: |
76+
export OPERATOR=1
77+
export IMAGE=ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
78+
./contrib/deploy.sh
7279
- name: run function
7380
run: OPERATOR=1 ./contrib/run_function.sh
7481
- name: stop dev cluster
7582
run: ./contrib/stop_dev.sh
76-
7783
# The certifier should also be run here
7884
#

contrib/deploy.sh

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44

55
DEVENV=${OF_DEV_ENV:-kind}
66
OPERATOR=${OPERATOR:-0}
7+
IMAGE=${IMAGE:-""}
78

89
echo ""
910
echo "Applying namespaces"
@@ -20,15 +21,15 @@ fi
2021

2122
PASSWORD_EXISTS=$(kubectl get secret -n openfaas basic-auth | wc -c)
2223
if [ $PASSWORD_EXISTS -eq 0 ]; then
23-
PASSWORD=$(head -c 16 /dev/urandom| $sha_cmd | cut -d " " -f 1)
24-
echo -n $PASSWORD > password.txt
24+
PASSWORD=$(head -c 16 /dev/urandom | $sha_cmd | cut -d " " -f 1)
25+
echo -n $PASSWORD >password.txt
2526

2627
kubectl --context "kind-$DEVENV" -n openfaas create secret generic basic-auth \
27-
--from-literal=basic-auth-user=admin \
28-
--from-literal=basic-auth-password="$PASSWORD"
28+
--from-literal=basic-auth-user=admin \
29+
--from-literal=basic-auth-password="$PASSWORD"
2930
else
3031
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o=go-template='{{index .data "basic-auth-password"}}' | base64 --decode)
31-
echo -n $PASSWORD > password.txt
32+
echo -n $PASSWORD >password.txt
3233
fi
3334

3435
CREATE_OPERATOR=false
@@ -39,20 +40,35 @@ fi
3940
echo ""
4041
echo "Waiting for helm install to complete."
4142

42-
helm upgrade \
43-
--kube-context "kind-$DEVENV" \
44-
--install \
45-
openfaas \
46-
./chart/openfaas \
47-
--namespace openfaas \
48-
--set basic_auth=true \
49-
--set functionNamespace=openfaas-fn \
50-
--set operator.create=$CREATE_OPERATOR
43+
if [ "z${IMAGE}" == "z" ]; then
44+
helm upgrade \
45+
--kube-context "kind-$DEVENV" \
46+
--install \
47+
openfaas \
48+
./chart/openfaas \
49+
--namespace openfaas \
50+
--set basic_auth=true \
51+
--set functionNamespace=openfaas-fn \
52+
--set operator.create=$CREATE_OPERATOR
53+
else
54+
helm upgrade \
55+
--kube-context "kind-$DEVENV" \
56+
--install \
57+
openfaas \
58+
./chart/openfaas \
59+
--namespace openfaas \
60+
--set basic_auth=true \
61+
--set functionNamespace=openfaas-fn \
62+
--set openfaasImagePullPolicy=IfNotPresent \
63+
--set operator.create=$CREATE_OPERATOR \
64+
--set operator.image=$IMAGE \
65+
--set faasnetes.image=$IMAGE
66+
fi
5167

5268
if [ "${OPERATOR}" == "1" ]; then
5369

5470
kubectl --context "kind-$DEVENV" patch -n openfaas deploy/gateway \
55-
-p='[{"op": "add", "path": "/spec/template/spec/containers/1/command", "value": ["./faas-netes", "-operator=true"]} ]' --type=json
71+
-p='[{"op": "add", "path": "/spec/template/spec/containers/1/command", "value": ["./faas-netes", "-operator=true"]} ]' --type=json
5672
fi
5773

5874
kubectl --context "kind-$DEVENV" rollout status deploy/prometheus -n openfaas

0 commit comments

Comments
 (0)