-
-
Notifications
You must be signed in to change notification settings - Fork 38
75 lines (57 loc) · 1.95 KB
/
test.yaml
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
name: Test
on:
push:
branches: [saga]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn
- name: Run unit tests
run: yarn test
- name: Start dev server
run: |
nohup yarn dev > server.log 2>&1 & echo $! > run.pid
echo "DEVSERVER_PID=`cat run.pid`" >> $GITHUB_ENV
- name: Wait for dev server to be up
run: until nc -w 10 127.0.0.1 8000; do tail -n 20 server.log; sleep 10; done
timeout-minutes: 5
- name: Kill dev server
run: kill ${{ env.DEVSERVER_PID }}
- name: Build
run: yarn build
- uses: actions/upload-artifact@v3
with:
name: build-${{ github.sha }}
path: public
- name: Start prod sever
run: |
nohup yarn run serve > prod-server.log 2>&1 & echo $! > run.pid
echo "PRODSERVER_PID=`cat run.pid`" >> $GITHUB_ENV
- name: Install playwright
run: npx playwright install
- name: Wait for prod server to be up
run: until nc -w 10 127.0.0.1 9000; do tail -n 20 prod-server.log; sleep 10; done
timeout-minutes: 5
- name: Run end-to-end tests
env:
PORT: 9000
run: npx playwright test --project=chrome
- name: Kill prod server
run: kill ${{ env.PRODSERVER_PID }}