-
Notifications
You must be signed in to change notification settings - Fork 417
102 lines (95 loc) · 3.43 KB
/
node.js.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
# 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: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# Keep in sync with netlify.toml
node-version: 20.x
- name: Cache node_modules
uses: actions/cache@v4
id: cache
with:
# Caching node_modules isn't recommended because it can break across
# Node versions and won't work with npm ci (See https://github.com/actions/cache/blob/main/examples.md#node---npm )
# But we pin the node version, and we don't update it that often anyways. And
# we don't use `npm ci` specifically to try to get faster CI flows. So caching
# `node_modules` directly.
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- if: steps.cache.outputs.cache-hit != 'true'
run: npm install
build:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Load node_modules from cache
uses: actions/cache@v4
with:
# Use node_modules from previous jobs
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- name: Cache BookReader/
uses: actions/cache@v4
id: build-cache
with:
# Cache the build files so we don't have to build twice for e2e tests
path: 'BookReader'
key: ${{ runner.os }}-${{ github.sha }}
- if: steps.build-cache.outputs.cache-hit != 'true'
run: npm run build
tests:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Load node_modules from cache
uses: actions/cache@v4
with:
# Use node_modules from previous jobs
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- run: npm run lint
- run: npm run test
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
e2e-tests:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Load node_modules from cache
uses: actions/cache@v4
with:
# Use node_modules from previous jobs
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- name: Load BookReader/ from cache
uses: actions/cache@v4
with:
# Cache the build files so we don't have to build twice for e2e tests
path: 'BookReader'
key: ${{ runner.os }}-${{ github.sha }}
# Travis machines usually have 2 cores (see https://docs.travis-ci.com/user/reference/overview/#virtualisation-environment-vs-operating-system )
# Quarantine mode (sigh) to catch unstable tests (see https://devexpress.github.io/testcafe/documentation/guides/basic-guides/run-tests.html#quarantine-mode )
- run: npx testcafe --concurrency 2 --quarantine-mode