diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9b15e274e..b694359c5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,9 +2,9 @@ name: build on: push: - branches: [ '*' ] + branches: ["*"] pull_request: - branches: [ '*' ] + branches: ["*"] jobs: build: @@ -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 @@ -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 # diff --git a/contrib/deploy.sh b/contrib/deploy.sh index 11b82ddcb..9cfc60e17 100755 --- a/contrib/deploy.sh +++ b/contrib/deploy.sh @@ -4,6 +4,7 @@ set -e DEVENV=${OF_DEV_ENV:-kind} OPERATOR=${OPERATOR:-0} +IMAGE=${IMAGE:-""} echo "" echo "Applying namespaces" @@ -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 @@ -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