-
Notifications
You must be signed in to change notification settings - Fork 914
214 lines (199 loc) · 8.82 KB
/
test.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
postgres:
- '15'
- '14'
- '13'
- '12'
- '11'
- '10'
- '9.6'
go:
- '1.20'
- '1.19'
- '1.18'
- '1.17'
- '1.16'
- '1.15'
- '1.14'
steps:
- name: setup postgres pre-reqs
run: |
mkdir init
cat <<CONF > init/root.crt
-----BEGIN CERTIFICATE-----
MIIEBjCCAu6gAwIBAgIJAPizR+OD14YnMA0GCSqGSIb3DQEBCwUAMF4xCzAJBgNV
BAYTAlVTMQ8wDQYDVQQIDAZOZXZhZGExEjAQBgNVBAcMCUxhcyBWZWdhczEaMBgG
A1UECgwRZ2l0aHViLmNvbS9saWIvcHExDjAMBgNVBAMMBXBxIENBMB4XDTIxMDkw
MjAxNTUwMloXDTMxMDkwMzAxNTUwMlowXjELMAkGA1UEBhMCVVMxDzANBgNVBAgM
Bk5ldmFkYTESMBAGA1UEBwwJTGFzIFZlZ2FzMRowGAYDVQQKDBFnaXRodWIuY29t
L2xpYi9wcTEOMAwGA1UE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Aw
Kf42zIBWfbnMLVWYoeDiAOhtl9XAUAXn76xe6Rvo0qeAo67yejdbJfRq3HvGyw+q
4PS8r9gXYmLYIPQxSoLL5+rFoBCN3qFippfjLB1j32mp7+15KjRj8FF2r6xIN8fu
XatSRsaqmvCWYLDRv/rbHnxwkwKBgQDLkyfFLF7BtwtPWKdqrwOM7ip1UKh+oDBS
vkCQ08aEFRBU7T3jChsx5GbaW6zmsSBwBwcrHclpSkz7n3aq19DDWObJR2p80Fma
rsXeIcvtEpkvT3pVX268P5d+XGs1kxgFunqTysG9yChW+xzcs5MdKBzuMPPn7rL8
MKAzdar6PwKBgEypkzW8x3h/4Moa3k6MnwdyVs2NGaZheaRIc95yJ+jGZzxBjrMr
h+p2PbvU4BfO0AqOkpKRBtDVrlJqlggVVp04UHvEKE16QEW3Xhr0037f5cInX3j3
Lz6yXwRFLAsR2aTUzWjL6jTh8uvO2s/GzQuyRh3a16Ar/WBShY+K0+zjAoGATnLT
xZjWnyHRmu8X/PWakamJ9RFzDPDgDlLAgM8LVgTj+UY/LgnL9wsEU6s2UuP5ExKy
QXxGDGwUhHar/SQTj+Pnc7Mwpw6HKSOmnnY5po8fNusSwml3O9XppEkrC0c236Y/
7EobJO5IFVTJh4cv7vFxTJzSsRL8KFD4uzvh+nMCgYEAqY8NBYtIgNJA2B6C6hHF
+bG7v46434ZHFfGTmMQwzE4taVg7YRnzYESAlvK4bAP5ZXR90n7GRGFhrXzoMZ38
r0bw/q9rV+ReGda7/Bjf7ciCKiq0RODcHtf4IaskjPXCoQRGJtgCPLhWPfld6g9v
/HTvO96xv9e3eG/PKSPog94=
-----END PRIVATE KEY-----
CONF
cat <<CONF > init/hba.sh
cat <<EOF > /var/lib/postgresql/data/pg_hba.conf
local all all trust
host all postgres all trust
hostnossl all pqgossltest all reject
hostnossl all pqgosslcert all reject
hostssl all pqgossltest all trust
hostssl all pqgosslcert all cert
host all all all trust
EOF
CONF
sudo chown 999:999 ./init/*
sudo chmod 600 ./init/*
- name: start postgres
run: |
docker run -d \
--name pg \
-p 5432:5432 \
-v $(pwd)/init:/init \
-e POSTGRES_PASSWORD=unused \
-e POSTGRES_USER=postgres \
postgres:${{ matrix.postgres }} \
-c ssl=on \
-c ssl_ca_file=/init/root.crt \
-c ssl_cert_file=/init/server.crt \
-c ssl_key_file=/init/server.key
- name: configure postgres
run: |
n=0
until [ "$n" -ge 10 ]
do
docker exec pg pg_isready -h localhost && break
n=$((n+1))
echo waiting for postgres to be ready...
sleep 1
done
docker exec pg bash /init/hba.sh
n=0
until [ "$n" -ge 10 ]
do
docker exec pg su postgres -c '/usr/lib/postgresql/${{ matrix.postgres }}/bin/pg_ctl reload' && break
n=$((n+1))
echo waiting for postgres to reload...
sleep 1
done
- name: setup hosts
run: echo '127.0.0.1 postgres' | sudo tee -a /etc/hosts
- name: create db/roles
run: |
n=0
until [ "$n" -ge 10 ]
do
docker exec pg pg_isready -h localhost && break
n=$((n+1))
echo waiting for postgres to be ready...
sleep 1
done
docker exec pg createdb -h localhost -U postgres pqgotest
docker exec pg createuser -h localhost -U postgres -DRS pqgossltest
docker exec pg createuser -h localhost -U postgres -DRS pqgosslcert
- name: check out code into the Go module directory
uses: actions/checkout@v3
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
id: go
- name: set key perms
run: sudo chmod 600 certs/postgresql.key
- name: run tests
env:
PGUSER: postgres
PGHOST: localhost
PGPORT: 5432
PQGOSSLTESTS: 1
PQSSLCERTTEST_PATH: certs
run: |
PQTEST_BINARY_PARAMETERS=no go test -race -v ./...
PQTEST_BINARY_PARAMETERS=yes go test -race -v ./...
- name: install goimports
run: go get golang.org/x/tools/cmd/goimports
- name: install staticcheck
run: |
wget https://github.com/dominikh/go-tools/releases/latest/download/staticcheck_linux_amd64.tar.gz -O - | tar -xz staticcheck
- name: run goimports
run: |
goimports -d -e . | awk '{ print } END { exit NR == 0 ? 0 : 1 }'
- name: run staticcheck
run: ./staticcheck/staticcheck -go 1.13 ./...
- name: build
run: go build -v .