-
Notifications
You must be signed in to change notification settings - Fork 8
175 lines (171 loc) · 5.35 KB
/
main.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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
PGDATADIR: /var/lib/postgresql/data
permissions:
contents: read
pages: write
id-token: write
jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Prettier
run: |
npm i -D
set +e
npx prettier --experimental-ternaries --check
code=$?
npx prettier --experimental-ternaries --log-level warn --write
git diff
exit "$code"
build:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
- name: NPM
run: |
set -ex
npm i
npm run prebuild
npm run build:cjs
npm run build:esm
echo '{"type": "commonjs"}' > dist/commonjs/package.json
echo '{"type": "module"}' > dist/module/package.json
mkdir dest
npm pack --pack-destination=dest
- name: Typedoc
run: npx typedoc
- name: Redirects
run: |
ref=${GITHUB_BASE_REF:-master}
url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/$ref
set +H
find examples -mindepth 1 -maxdepth 1 -exec sh -c "
mkdir -p docs/{}
cat << EOF > docs/{}/index.html
<!DOCTYPE html>
<meta charset='utf-8'>
<title>Redirecting to $url/{}</title>
<meta http-equiv='refresh' content='0; URL=$url/{}'>
<link rel='canonical' href='$url/{}'>
EOF
" \;
- uses: actions/upload-pages-artifact@v2
with:
path: ./docs
- name: Package artifact
uses: actions/upload-artifact@v4
with:
name: pkg
path: dest
test:
services:
postgres:
image: postgres
ports:
- 5432/tcp
env:
POSTGRES_PASSWORD: postgres
options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
version:
- 18
- 20
runs-on: ubuntu-latest
needs: [build]
timeout-minutes: 3
steps:
- run: |
function set() {
docker exec ${{ job.services.postgres.id }} sh -c "echo $1=\'$2\' >> $PGDATADIR/postgresql.conf"
}
set ssl on
set ssl_cert_file /etc/ssl/certs/ssl-cert-snakeoil.pem
set ssl_key_file /etc/ssl/private/ssl-cert-snakeoil.key
set fsync off
set full_page_writes off
set synchronous_commit off
docker kill --signal=SIGHUP ${{ job.services.postgres.id }}
- name: Use Node.js ${{ matrix.version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
- uses: actions/checkout@v4
- name: Install dependencies
run: npm i
- name: Run tests
run: npm run test:prod
env:
PGSSLMODE: disable
PGPORT: ${{ job.services.postgres.ports[5432] }}
PGUSER: postgres
PGPASSWORD: postgres
- name: Extract SSL cert
run: docker cp ${{ job.services.postgres.id }}:/etc/ssl/certs/ssl-cert-snakeoil.pem ./
- name: Run tests (SSL)
run: npm run test:prod
env:
NODE_EXTRA_CA_CERTS: ${{ github.workspace }}/ssl-cert-snakeoil.pem
PGPORT: ${{ job.services.postgres.ports[5432] }}
PGUSER: postgres
PGPASSWORD: postgres
- uses: actions/download-artifact@v4
- name: 'Example: Connect'
run: |
pkg_path=`ls $PWD/pkg/ts-postgres-*.tgz`
cd examples/connect
npm i . "$pkg_path"
set -o pipefail
PGSSLMODE=disable node main.cjs | tee /dev/stderr | grep -q false
PGSSLMODE=require node main.cjs | tee /dev/stderr | grep -q true
[[ -d v$NODE_VERSION ]] && cd v$NODE_VERSION
npx tsc
PGSSLMODE=disable node main.mjs | tee /dev/stderr | grep -q false
PGSSLMODE=require node main.mjs | tee /dev/stderr | grep -q true
env:
NODE_VERSION: ${{ matrix.version }}
NODE_EXTRA_CA_CERTS: ${{ github.workspace }}/ssl-cert-snakeoil.pem
PGPORT: ${{ job.services.postgres.ports[5432] }}
PGUSER: postgres
PGPASSWORD: postgres
- name: 'Example: Generic Pool'
run: |
pkg_path=`ls $PWD/pkg/ts-postgres-*.tgz`
cd examples/generic-pool
npm i . "$pkg_path"
set -o pipefail
npx tsc
PGSSLMODE=disable node main.mjs | tee /dev/stderr | grep -q false
PGSSLMODE=require node main.mjs | tee /dev/stderr | grep -q true
env:
NODE_EXTRA_CA_CERTS: ${{ github.workspace }}/ssl-cert-snakeoil.pem
PGPORT: ${{ job.services.postgres.ports[5432] }}
PGUSER: postgres
PGPASSWORD: postgres
deploy:
if: github.ref_name == 'master'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: [style, build, test]
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2