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

ci: use locally built image in the e2e tests #871

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
#
46 changes: 31 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,35 @@ 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 openfaasImagePullPolicy=IfNotPresent \
--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