-
Notifications
You must be signed in to change notification settings - Fork 19
129 lines (116 loc) · 3.65 KB
/
test.yaml
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Test GatewayD
on:
push:
branches:
- main
tags:
- v*
pull_request:
jobs:
test:
name: Test GatewayD
runs-on: ubuntu-latest
# Timeout after 3 minutes, to avoid hanging tests
timeout-minutes: 3
services:
postgres:
image: postgres
env:
POSTGRES_HOST: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go 🧑💻
uses: actions/setup-go@v3
with:
go-version: "1.21"
- name: Lint code issues 🚨
uses: golangci/golangci-lint-action@v3
with:
skip-pkg-cache: true
- name: Run Go tests 🔬
run: go test -cover -covermode atomic -coverprofile=profile.cov -v ./...
- name: Report coverage to coveralls 📈
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
test-plugin:
name: Test GatewayD Plugins
runs-on: ubuntu-latest
needs: test
services:
postgres:
image: postgres
env:
POSTGRES_HOST: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go 🧑💻
uses: actions/setup-go@v3
with:
go-version: "1.21"
- name: Checkout test plugin 🛎️
uses: actions/checkout@v3
with:
repository: gatewayd-io/plugin-template-go
path: plugin-template-go
- name: Build template plugin 🏗️
run: |
# Build GatewayD
make build-dev
# Build template plugin
cd plugin-template-go && make build && cp plugin-template-go ../ptg && cd ..
export SHA256SUM=$(sha256sum ptg | awk '{print $1}')
cat <<EOF > gatewayd_plugins.yaml
verificationPolicy: "passdown"
compatibilityPolicy: "strict"
acceptancePolicy: "accept"
terminationPolicy: "stop"
metricsMergerPeriod: 1s
healthCheckPeriod: 1s
reloadOnCrash: true
timeout: 30s
plugins:
- name: plugin-template-go
enabled: True
localPath: ./ptg
args: ["--log-level", "debug"]
env:
- MAGIC_COOKIE_KEY=GATEWAYD_PLUGIN
- MAGIC_COOKIE_VALUE=5712b87aa5d7e9f9e9ab643e6603181c5b796015cb1c09d6f5ada882bf2a1872
checksum: ${SHA256SUM}
EOF
- name: Run GatewayD with template plugin 🚀
run: GATEWAYD_LOGGERS_DEFAULT_LEVEL=debug ./gatewayd run &
- name: Run a test with PSQL 🧪
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
psql ${PGURL} -c "CREATE TABLE test_table (id serial PRIMARY KEY, name varchar(255));" | grep CREATE || exit 1
psql ${PGURL} -c "INSERT INTO test_table (name) VALUES ('test');" | grep INSERT || exit 1
psql ${PGURL} -c "SELECT * FROM test_table;" | grep test || exit 1
env:
PGURL: postgres://postgres:postgres@localhost:15432/postgres