-
Notifications
You must be signed in to change notification settings - Fork 24
154 lines (137 loc) · 4.97 KB
/
test_new_core_pkg.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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Run test against new Core Pkg
on:
workflow_dispatch:
inputs:
core_pkg_version:
description: 'Core pkg version'
required: true
jobs:
build-test-env:
name: Build test env
runs-on: ubuntu-latest
steps:
- env:
EVENT_CONTEXT: ${{ toJSON(github.event) }}
run: |
echo $EVENT_CONTEXT
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/install
with:
core_pkg_version: ${{ inputs.core_pkg_version }}
- name: Build app
uses: ./.github/actions/build
with:
REACT_APP_APP_ENV: 'test'
test-compile:
name: Typecheck apps
runs-on: ubuntu-latest
needs: build-test-env
strategy:
max-parallel: 6
fail-fast: false
matrix:
include:
- test_name: 'Typecheck webapp'
test_command: 'npm run typecheck'
- test_name: 'Typecheck cron'
test_command: 'npm run typecheck -w apps/cron'
- test_name: 'Typecheck websockets'
test_command: 'npm run typecheck -w apps/websockets'
steps:
- uses: actions/checkout@v4
- name: Restore dependencies from cache
uses: ./.github/actions/install
with:
core_pkg_version: ${{ inputs.core_pkg_version }}
- name: Restore app from cache
uses: ./.github/actions/build
with:
REACT_APP_APP_ENV: 'test'
- name: Run ${{matrix.test_name}}
run: ${{matrix.test_command}}
integration-test:
name: Tests
runs-on: ubuntu-latest
needs: build-test-env
# Postgres setup copied from https://gist.github.com/2color/537f8ef13ecec80059abb007839a6878
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--hostname postgres
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
strategy:
max-parallel: 6
fail-fast: false
matrix:
include:
- test_name: 'Basic tests #1'
test_command: 'npm run test:ci -- --config="./lib/jest.config.ts" --shard 1/3'
- test_name: 'Basic tests #2'
test_command: 'npm run test:ci -- --config="./lib/jest.config.ts" --shard 2/3'
- test_name: 'Basic tests #3'
test_command: 'npm run test:ci -- --config="./lib/jest.config.ts" --shard 3/3'
steps:
- uses: actions/checkout@v4
- name: Restore dependencies from cache
uses: ./.github/actions/install
with:
core_pkg_version: ${{ inputs.core_pkg_version }}
- name: Setup test database
run: npx dotenv -e .env.test.local -- npm run prisma:reset
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
mask-aws-account-id: 'no'
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Run permissions api docker image
id: run_permissions_api
run: |
docker inspect postgres
docker network ls
cat /etc/hosts
echo "network ${{ job.services.postgres.network }}"
docker run -d --name permissions-api \
-h permissions-api \
-p "3001:3001" \
-e HOST=0.0.0.0 \
-e PORT=3001 \
-v $PWD/nodes_modules/@charmverse/core:/apps/node_modules/@charmverse/core \
--network "${{ job.services.postgres.network }}" \
-e DATABASE_URL=postgres://postgres:postgres@postgres:5432/charmversetest \
${{ steps.login-ecr.outputs.registry }}/charmverse-permissions-api:latest \
node --experimental-specifier-resolution=node ./dist/main.js
for i in {1..10}; do
docker ps
docker logs permissions-api
docker inspect permissions-api
curl localhost:3001/api/health && {
echo "permission api container is up..."
break
}
echo "permission api not up...sleeping"
sleep 10
done
- name: Restore app from cache
uses: ./.github/actions/build
with:
REACT_APP_APP_ENV: 'test'
- name: Run ${{matrix.test_name}}
run: ${{matrix.test_command}}