@@ -17,15 +17,32 @@ permissions:
1717 id-token : write
1818
1919jobs :
20- docs :
20+ build :
2121 runs-on : ubuntu-latest
2222 timeout-minutes : 1
2323 steps :
24+ - uses : actions/checkout@v4
25+ - name : NPM
26+ run : |
27+ set -ex
28+ npm i
29+ npm run prebuild
30+ npm run build:cjs
31+ npm run build:esm
32+ echo '{"type": "commonjs"}' > dist/commonjs/package.json
33+ echo '{"type": "module"}' > dist/module/package.json
34+ mkdir dest
35+ npm pack --pack-destination=dest
2436 - name : Docs
2537 run : npx typedoc
2638 - uses : actions/upload-pages-artifact@v2
2739 with :
2840 path : ./docs
41+ - name : Package artifact
42+ uses : actions/upload-artifact@v4
43+ with :
44+ name : pkg
45+ path : dest
2946 test :
3047 services :
3148 postgres :
@@ -42,11 +59,11 @@ jobs:
4259 --health-retries 5
4360 strategy :
4461 matrix :
45- environment :
46- - type : node
47- version : 18.x
48- - type : node
62+ version :
63+ - 18.x
64+ - 20.x
4965 runs-on : ubuntu-latest
66+ needs : [build]
5067 timeout-minutes : 3
5168 steps :
5269 - run : |
@@ -60,53 +77,43 @@ jobs:
6077 set full_page_writes off
6178 set synchronous_commit off
6279 docker kill --signal=SIGHUP ${{ job.services.postgres.id }}
63- - uses : actions/checkout@v4
64- - name : Use Node.js ${{ matrix.environment.version }}
65- if : matrix.environment.type == 'node'
80+ - name : Use Node.js ${{ matrix.version }}
6681 uses : actions/setup-node@v3
6782 with :
68- node-version : ${{ matrix.environment.version }}
83+ node-version : ${{ matrix.version }}
84+ - uses : actions/checkout@v4
6985 - name : Install dependencies
70- if : matrix.environment.type == 'node'
71- run : npm ci
86+ run : npm i
7287 - name : Run tests
73- run : |
74- case $ENVIRONMENT in
75- node)
76- npm run test:prod
77- ;;
78- esac
88+ run : npm run test:prod
7989 env :
80- ENVIRONMENT : ${{ matrix.environment.type }}
8190 PGSSLMODE : disable
8291 PGPORT : ${{ job.services.postgres.ports[5432] }}
8392 PGUSER : postgres
8493 PGPASSWORD : postgres
94+ - name : Extract SSL cert
95+ run : docker cp ${{ job.services.postgres.id }}:/etc/ssl/certs/ssl-cert-snakeoil.pem ./
8596 - name : Run tests (SSL)
97+ run : npm run test:prod
98+ env :
99+ NODE_EXTRA_CA_CERTS : ${{ github.workspace }}/ssl-cert-snakeoil.pem
100+ PGPORT : ${{ job.services.postgres.ports[5432] }}
101+ PGUSER : postgres
102+ PGPASSWORD : postgres
103+ - uses : actions/download-artifact@v4
104+ - name : " Example: Connect"
86105 run : |
87- docker cp ${{ job.services.postgres.id }}:/etc/ssl/certs/ssl-cert-snakeoil.pem ./
88- gen_code() {
89- cat <<- EOF
90- import { Client } from '$1';
91- const client = new Client();
92- const info = await client.connect();
93- console.log("Encrypted: " + info.encrypted);
94- await client.end();
95- EOF
96- }
106+ pkg_path=`ls $PWD/pkg/ts-postgres-*.tgz`
107+ cd examples/connect
108+ npm i . "$pkg_path"
97109 set -o pipefail
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
110+ PGSSLMODE=disable node main.cjs | tee /dev/stderr | grep -q false
111+ PGSSLMODE=require node main.cjs | tee /dev/stderr | grep -q true
112+ npx tsc
113+ PGSSLMODE=disable node main.mjs | tee /dev/stderr | grep -q false
114+ PGSSLMODE=require node main.mjs | tee /dev/stderr | grep -q true
106115 env :
107- ENVIRONMENT : ${{ matrix.environment.type }}
108- NODE_EXTRA_CA_CERTS : ssl-cert-snakeoil.pem
109- PGSSLMODE : require
116+ NODE_EXTRA_CA_CERTS : ${{ github.workspace }}/ssl-cert-snakeoil.pem
110117 PGPORT : ${{ job.services.postgres.ports[5432] }}
111118 PGUSER : postgres
112119 PGPASSWORD : postgres
@@ -116,7 +123,7 @@ jobs:
116123 environment :
117124 name : github-pages
118125 url : ${{ steps.deployment.outputs.page_url }}
119- needs : [test, docs ]
126+ needs : [build, test ]
120127 steps :
121128 - name : Deploy to GitHub Pages
122129 id : deployment
0 commit comments