-
Notifications
You must be signed in to change notification settings - Fork 514
79 lines (63 loc) · 2.37 KB
/
testing.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
# 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: Testing Yari
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: "12"
cache: "yarn"
- name: Cache node_modules
uses: actions/[email protected]
id: cached-node_modules
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}-${{ hashFiles('.github/workflows/testing.yml') }}
- name: Install all yarn packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
run: |
yarn --frozen-lockfile
- name: Lint prettier
run: yarn prettier-check
- name: Lint ESLint
run: yarn eslint
- name: Unit testing client
run: yarn test:client
- name: Build and start server
env:
ENV_FILE: testing/.env
run: |
# because `yarn prepare-build` is a wrapper for `yarn build:client` and
# `yarn build:client` can't respect the `$ENV_FILE` environment variable,
# because it has to build from the `./client/` directory, we have to
# manually copy the `testing/.env` file into `client/` so that when
# `yarn build:client` runs, it gets the same environment variables
# as you'd get when doing `yarn build:ssr`.
cp testing/.env client/
yarn prepare-build
yarn build
yarn start:static-server > /tmp/stdout.log 2> /tmp/stderr.log &
sleep 1
curl --fail --retry-connrefused --retry 5 http://localhost:5000 > /dev/null
- name: Functional testing
run: |
yarn test:testing
yarn test:headless
- name: Debug server's stdout and stderr if tests failed
if: failure()
run: |
echo "STDOUT..................................................."
cat /tmp/stdout.log
echo ""
echo "STDERR..................................................."
cat /tmp/stderr.log