Skip to content

Commit

Permalink
ci: use locally built image in the e2e tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
LucasRoesler committed Nov 6, 2021
1 parent 5dfd372 commit c65c9aa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build

on:
push:
branches: [ '*' ]
branches: ["*"]
pull_request:
branches: [ '*' ]
branches: ["*"]

jobs:
build:
Expand Down Expand Up @@ -48,17 +48,19 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
# Todo - load the image into Kind before running tests
# otherwise, this just tests the chart with images that
# have already been built and pushed in an earlier job
- name: get tools
run: ./contrib/get_tools.sh
- name: lint chart
run: ./contrib/lint_chart.sh
- name: create cluster
run: ./contrib/create_cluster.sh
- name: load CI image into kind
run: kind load docker-image ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
- name: deploy function
run: OPERATOR=0 ./contrib/deploy.sh
run: |
export OPERATOR=0
export IMAGE=ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
./contrib/deploy.sh
- name: run function
run: OPERATOR=0 ./contrib/run_function.sh
- name: stop dev cluster
Expand All @@ -67,12 +69,16 @@ jobs:
run: sleep 10
- name: create cluster
run: ./contrib/create_cluster.sh
- name: load CI image into kind
run: kind load docker-image ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
- name: deploy function
run: OPERATOR=1 ./contrib/deploy.sh
run: |
export OPERATOR=1
export IMAGE=ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/faas-netes:${{ github.sha }}
./contrib/deploy.sh
- name: run function
run: OPERATOR=1 ./contrib/run_function.sh
- name: stop dev cluster
run: ./contrib/stop_dev.sh

# The certifier should also be run here
#
45 changes: 30 additions & 15 deletions contrib/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e

DEVENV=${OF_DEV_ENV:-kind}
OPERATOR=${OPERATOR:-0}
IMAGE=${IMAGE:-""}

echo ""
echo "Applying namespaces"
Expand All @@ -20,15 +21,15 @@ fi

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

kubectl --context "kind-$DEVENV" -n openfaas create secret generic basic-auth \
--from-literal=basic-auth-user=admin \
--from-literal=basic-auth-password="$PASSWORD"
--from-literal=basic-auth-user=admin \
--from-literal=basic-auth-password="$PASSWORD"
else
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o=go-template='{{index .data "basic-auth-password"}}' | base64 --decode)
echo -n $PASSWORD > password.txt
echo -n $PASSWORD >password.txt
fi

CREATE_OPERATOR=false
Expand All @@ -39,20 +40,34 @@ fi
echo ""
echo "Waiting for helm install to complete."

helm upgrade \
--kube-context "kind-$DEVENV" \
--install \
openfaas \
./chart/openfaas \
--namespace openfaas \
--set basic_auth=true \
--set functionNamespace=openfaas-fn \
--set operator.create=$CREATE_OPERATOR
if [ "z${IMAGE}" == "z" ]; then
helm upgrade \
--kube-context "kind-$DEVENV" \
--install \
openfaas \
./chart/openfaas \
--namespace openfaas \
--set basic_auth=true \
--set functionNamespace=openfaas-fn \
--set operator.create=$CREATE_OPERATOR
else
helm upgrade \
--kube-context "kind-$DEVENV" \
--install \
openfaas \
./chart/openfaas \
--namespace openfaas \
--set basic_auth=true \
--set functionNamespace=openfaas-fn \
--set operator.create=$CREATE_OPERATOR \
--set operator.image=$IMAGE \
--set faasnetes.image=$IMAGE
fi

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

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

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

0 comments on commit c65c9aa

Please sign in to comment.