-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (91 loc) · 5.07 KB
/
faas_fn_build_invoke.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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