-
-
Notifications
You must be signed in to change notification settings - Fork 572
105 lines (93 loc) · 3.52 KB
/
test-base.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
name: Base Test Workflow
on:
workflow_call:
inputs:
prepackPackages:
description:
List of packages to be prepacked given as {package-a,} the extra , is
important! or {package-A,package-B}
required: true
type: string
package:
description: Name of the package that should be tested
type: string
required: true
testcommand:
description: Command to execute, usually test or posttest
type: string
required: true
args:
description: Optional command arguments
type: string
default: ""
required: false
jobs:
build:
runs-on: ubuntu-latest
env:
CI: true
JEST_MAX_WORKERS: 4
PGUSER: postgres
PGPASSWORD: postgres
PGHOST: localhost
PGVERSION: ${{ matrix.postgres-version}}
TEST_SIMPLIFY_DATABASE_URL: postgres://postgres:postgres@localhost:5432/pg_simplify_inflectors
TERM: xterm
FORCE_COLOR: 1
NODE_OPTIONS: "--max-old-space-size=4096 --disable-proto=delete"
NODE_ENV: test
strategy:
fail-fast: false
matrix:
postgres-version: [12, 17] #, 11, 13, 14, 15]
node-version: [20.x] #, 18.x]
services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- "0.0.0.0:5432:5432"
# needed because the postgres container does not provide a healthcheck
options:
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
--health-retries 5 --name postgres
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Configure PostgreSQL
run: |
cat .github/workflows/ci/docker-entrypoint-initdb.d/010-enable_wal.sh | docker exec -i postgres bash
cat .github/workflows/ci/docker-entrypoint-initdb.d/020-wal2json.sh | docker exec -i postgres bash
cat .github/workflows/ci/docker-entrypoint-initdb.d/030-setup.sh | docker exec -i postgres bash
echo "cat /var/lib/postgresql/data/postgresql.conf" | docker exec -i postgres bash
docker restart postgres
- name: Install pg_dump
run: |
sudo mkdir -p /usr/share/keyrings
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /usr/share/keyrings/pgdg-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/pgdg-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list > /dev/null
sudo apt-get update
sudo apt-get -yqq install postgresql-client-${{ matrix.postgres-version }}
- run: yarn --immutable
- name: "Wait for postgres"
run: node .github/wait-for-postgres.js
- name: "Docker logs postgres"
run: docker logs "${{ job.services.postgres.id }}"
- name: "Typescript Build"
run: yarn tsc -b
- name: "Prepack"
run:
yarn workspaces foreach -vptR --from '${{ inputs.prepackPackages }}'
run prepack
- name: "Test Project"
run:
yarn run pretest && yarn workspaces foreach -vp --jobs 2 --from '${{
inputs.package }}' run ${{ inputs.testcommand }} ${{ inputs.args }}