-
Notifications
You must be signed in to change notification settings - Fork 350
102 lines (90 loc) · 3.43 KB
/
node-ci-main.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
name: Node CI (landed on protected branch)
on:
push:
branches:
- main
- changeset-release/*
- feature/*
# Our jobs run like this to minimize wasting resource cycles:
# 1. Prime caches for primary configuration. This way subsequent jobs
# can run in parallel but rely on this primed cache.
# 2. Coverage
#
# For pushes directly to a branch, we assume a PR has been used with wider
# checks, this just makes sure our coverage data is up-to-date.
jobs:
prime_cache_primary:
name: Prime node_modules cache for primary configuration
runs-on: ${{ matrix.os }}
strategy:
# Use a matrix as it means we get the version info in the job name
# which is very helpful.
matrix:
os: [ubuntu-latest]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} & Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}
coverage:
needs: [prime_cache_primary]
name: Jest Coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} & Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}
- name: Jest with coverage
run: yarn coverage
- name: Upload Coverage
# We don't bother uploading a record of coverage for dependabot changes
if: ${{ github.actor != 'dependabot[bot]' }}
uses: coverallsapp/github-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: jest
parallel: true
cypress:
needs: [prime_cache_primary]
name: Cypress Coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
steps:
- name: Checking out latest commit
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} & Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}
- name: Run test with coverage
run: yarn cypress:ci
- name: Generate report
run: yarn nyc report --reporter=lcov
- name: Upload Coverage
# We don't bother uploading a record of coverage for dependabot changes
if: ${{ github.actor != 'dependabot[bot]' }}
uses: coverallsapp/github-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: cypress
parallel: true
finish_coverage:
needs: [cypress, coverage]
runs-on: ubuntu-latest
steps:
- name: Finish Coverage
uses: coverallsapp/github-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true