Skip to content

Intern defnk

Intern defnk #436

name: Tests
on:
push:
branches:
- "*"
paths-ignore:
- "*.adoc"
pull_request:
paths-ignore:
- "*.adoc"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install OpenFaaS CLI
run: curl -sSL https://cli.openfaas.com | sudo -E sh
- name: Build a Function for each language from scratch and invoke it
run: |
mkdir test
cd test
faas-cli template pull https://github.com/${{ github.repository_owner }}/faas-bb#${{ github.head_ref || github.ref_name }}
faas-cli new --lang bb my-bb-http-function --prefix ghcr.io/${{ github.repository_owner }}
faas-cli build -f my-bb-http-function.yml
(docker stop my-bb-http-function || exit 0)
(docker rm my-bb-http-function || exit 0)
docker run -d --name my-bb-http-function ghcr.io/${{ github.repository_owner }}/my-bb-http-function:latest bb --config ship.edn run-function
if [ "$(docker exec my-bb-http-function curl -X GET --retry 6 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082)" != "Hello OpenFaaS!" ]; then
docker logs my-bb-http-function
exit 1
fi
- name: Build provided Function examples and invoke them
env:
DOCKER_REGISTRY_IMG_ORG_PATH: ghcr.io/${{ github.repository_owner }}
run: |
git clone https://github.com/${{ github.repository_owner }}/faas-bb.git
cd faas-bb
git checkout ${{ github.head_ref || github.ref_name }}
cd examples
faas-cli template pull https://github.com/${{ github.repository_owner }}/faas-bb#${{ github.head_ref || github.ref_name }}
faas-cli build
(docker stop bb-http-hello || exit 0)
(docker rm bb-http-hello || exit 0)
docker run -d --name bb-http-hello ghcr.io/${{ github.repository_owner }}/bb-http-hello:latest bb --config ship.edn run-function
if [ "$(docker exec bb-http-hello curl -X GET --retry 3 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082)" != 'Hello OpenFaaS!' ]; then
docker logs bb-http-hello
exit 2
fi
(docker stop bb-http-map || exit 0)
(docker rm bb-http-map || exit 0)
docker run -d --name bb-http-map ghcr.io/${{ github.repository_owner }}/bb-http-map:latest bb --config ship.edn run-function
if [ "$(docker exec bb-http-map curl -X POST -d '{"foo": "bar", "spam": "eggs"}' -H 'content-type: application/json' --retry 3 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082)" != '[["foo","spam"],["bar","eggs"]]' ]; then
docker logs bb-http-map
exit 3
fi
(docker stop bb-http-map-context || exit 0)
(docker rm bb-http-map-context || exit 0)
docker run -d --name bb-http-map-context ghcr.io/${{ github.repository_owner }}/bb-http-map-context:latest bb --config ship.edn run-function
if [ "$(docker exec bb-http-map-context curl -X POST -d '{"foo": "bar", "spam": "eggs"}' -H 'content-type: application/json' --retry 3 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082)" != '[["foo","spam"],["bar","eggs"],"application/json","http://127.0.0.1:8082"]' ]; then
docker logs bb-http-map-context
exit 4
fi
(docker stop bb-routes || exit 0)
(docker rm bb-routes || exit 0)
docker run -d --name bb-routes ghcr.io/${{ github.repository_owner }}/bb-routes:latest bb --config ship.edn run-function
if [ "$(docker exec bb-routes curl -X GET --retry 3 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082/foo)" != 'foo' ]; then
docker logs bb-routes
exit 5
fi
(docker stop bb-routes-bell || exit 0)
(docker rm bb-routes-bell || exit 0)
docker run -d --name bb-routes-bell ghcr.io/${{ github.repository_owner }}/bb-routes-bell:latest bb --config ship.edn run-function
if [ "$(docker exec bb-routes-bell curl -X GET --retry 3 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082/foo/123)" != '[["id"],["123"]]' ]; then
docker logs bb-routes-bell
exit 6
fi
(docker stop bb-hiccup || exit 0)
(docker rm bb-hiccup || exit 0)
docker run -d --name bb-hiccup ghcr.io/${{ github.repository_owner }}/bb-hiccup:latest bb --config ship.edn run-function
bb_hiccup_output=$(docker exec bb-hiccup curl -X GET -d '{"item-list": ["foo","bar","spam"]}' --retry 3 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082)
if [[ "${bb_hiccup_output:0:5}" != "<html" ]]; then
docker logs bb-hiccup
exit 7
fi
(docker stop bb-potd || exit 0)
(docker rm bb-potd || exit 0)
docker run -d --name bb-potd ghcr.io/${{ github.repository_owner }}/bb-potd:latest bb --config ship.edn run-function
bb_potd=$(docker exec bb-potd curl -X GET --retry 3 --retry-delay 2 --retry-connrefused http://127.0.0.1:8082)
if [[ ${#bb_potd} -gt 31 ]]; then
docker logs bb-potd
exit 8
fi