-
Notifications
You must be signed in to change notification settings - Fork 19
180 lines (163 loc) · 5.4 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Test GatewayD
on:
push:
branches:
- main
tags:
- v*
paths-ignore:
- "README.md"
- "LICENSE"
- "CONTRIBUTING.md"
- "CODE_OF_CONDUCT.md"
- ".gitignore"
- ".gitattributes"
pull_request:
paths-ignore:
- "README.md"
- "LICENSE"
- "CONTRIBUTING.md"
- "CODE_OF_CONDUCT.md"
- ".gitignore"
- ".gitattributes"
jobs:
test:
name: Test GatewayD
runs-on: ubuntu-latest
# Timeout after 5 minutes, to avoid hanging tests
timeout-minutes: 5
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
postgres2:
image: postgres
env:
POSTGRES_HOST: postgres2
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go 🧑💻
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Lint code with golangci-lint 🚨
uses: golangci/golangci-lint-action@v6
with:
version: "latest"
install-mode: "goinstall"
- name: Lint Bash script with shellcheck 🚨
uses: ludeeus/action-shellcheck@master
- name: Lint Dockerfile with hadolint 🚨
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
- name: Run Go tests 🔬
run: go test -tags embed_plugin_template -p 1 -cover -covermode atomic -coverprofile=profile.cov -v ./...
env:
GITHUB_AUTH_TOKEN: ${{ secrets.INTEGRATION }}
- name: Report coverage to coveralls 📈
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
ignore: "api/v1/*,usagereport/*"
test-plugin:
name: Test GatewayD Plugins
runs-on: ubuntu-latest
needs: test
timeout-minutes: 5
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@v4
with:
fetch-depth: 0
- name: Install Go 🧑💻
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Checkout test plugin 🛎️
uses: actions/checkout@v4
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
compatibilityPolicy: "strict"
metricsMergerPeriod: 1s
healthCheckPeriod: 1s
reloadOnCrash: true
timeout: 30s
plugins:
- name: plugin-template-go
enabled: True
url: github.com/gatewayd-io/plugin-template-go
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 run -c testdata/gatewayd_tls.yaml &
- name: Install PSQL 🧑💻
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
- name: Run a test with PSQL over plaintext connection 🧪
run: |
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
psql ${PGURL} -c "DROP TABLE test_table;" | grep DROP || exit 1
env:
PGURL: postgres://postgres:postgres@localhost:15432/postgres?sslmode=disable
- name: Run a test with PSQL over TLS connection 🧪
run: |
psql ${PGURL_TLS} -c "CREATE TABLE test_table (id serial PRIMARY KEY, name varchar(255));" | grep CREATE || exit 1
psql ${PGURL_TLS} -c "INSERT INTO test_table (name) VALUES ('test');" | grep INSERT || exit 1
psql ${PGURL_TLS} -c "SELECT * FROM test_table;" | grep test || exit 1
psql ${PGURL_TLS} -c "DROP TABLE test_table;" | grep DROP || exit 1
env:
PGURL_TLS: postgres://postgres:postgres@localhost:15432/postgres?sslmode=require