@@ -17,9 +17,16 @@ permissions:
17
17
id-token : write
18
18
19
19
jobs :
20
- build :
20
+ docs :
21
21
runs-on : ubuntu-latest
22
- timeout-minutes : 3
22
+ timeout-minutes : 1
23
+ steps :
24
+ - name : Docs
25
+ run : npx typedoc
26
+ - uses : actions/upload-pages-artifact@v2
27
+ with :
28
+ path : ./docs
29
+ test :
23
30
services :
24
31
postgres :
25
32
image : postgres
35
42
--health-retries 5
36
43
strategy :
37
44
matrix :
38
- node-version : ['18.x', '20.x']
45
+ environment :
46
+ - type : node
47
+ version : 18.x
48
+ - type : node
49
+ runs-on : ubuntu-latest
50
+ timeout-minutes : 3
39
51
steps :
40
52
- run : |
41
53
function set() {
@@ -49,46 +61,62 @@ jobs:
49
61
set synchronous_commit off
50
62
docker kill --signal=SIGHUP ${{ job.services.postgres.id }}
51
63
- uses : actions/checkout@v4
64
+ - name : Use Node.js ${{ matrix.environment.version }}
65
+ if : matrix.environment.type == 'node'
66
+ uses : actions/setup-node@v3
67
+ with :
68
+ node-version : ${{ matrix.environment.version }}
52
69
- name : Install dependencies
70
+ if : matrix.environment.type == 'node'
53
71
run : npm ci
54
72
- name : Run tests
55
- run : npm run test:prod
73
+ run : |
74
+ case $ENVIRONMENT in
75
+ node)
76
+ npm run test:prod
77
+ ;;
78
+ esac
56
79
env :
80
+ ENVIRONMENT : ${{ matrix.environment.type }}
57
81
PGSSLMODE : disable
58
82
PGPORT : ${{ job.services.postgres.ports[5432] }}
59
83
PGUSER : postgres
60
84
PGPASSWORD : postgres
61
85
- name : Run tests (SSL)
62
86
run : |
63
87
docker cp ${{ job.services.postgres.id }}:/etc/ssl/certs/ssl-cert-snakeoil.pem ./
64
- npm run test:prod || exit 1
65
- npm run build
66
- cat <<- EOF > test.mjs
67
- import { Client } from './dist/src/index.js';
68
- const client = new Client();
69
- const secured = await client.connect();
70
- console.log(secured);
71
- await client.end();
88
+ gen_code() {
89
+ cat <<- EOF
90
+ import { Client } from '$1';
91
+ const client = new Client();
92
+ const secured = await client.connect();
93
+ console.log(secured);
94
+ await client.end();
72
95
EOF
96
+ }
73
97
set -o pipefail
74
- node test.mjs | tee /dev/stderr | grep -q true
98
+ case $ENVIRONMENT in
99
+ node)
100
+ npm run test:prod || exit 1
101
+ npm run build
102
+ gen_code ./dist/src/index.js > test.mjs
103
+ node test.mjs | tee /dev/stderr | grep -q true
104
+ ;;
105
+ esac
75
106
env :
107
+ ENVIRONMENT : ${{ matrix.environment.type }}
76
108
NODE_EXTRA_CA_CERTS : ssl-cert-snakeoil.pem
77
109
PGSSLMODE : require
78
110
PGPORT : ${{ job.services.postgres.ports[5432] }}
79
111
PGUSER : postgres
80
112
PGPASSWORD : postgres
81
- - name : Docs
82
- run : npx typedoc
83
- - uses : actions/upload-pages-artifact@v2
84
- with :
85
- path : ./docs
86
113
deploy :
114
+ if : github.ref_name == 'master'
87
115
runs-on : ubuntu-latest
88
116
environment :
89
117
name : github-pages
90
118
url : ${{ steps.deployment.outputs.page_url }}
91
- needs : build
119
+ needs : [test, docs]
92
120
steps :
93
121
- name : Deploy to GitHub Pages
94
122
id : deployment
0 commit comments