98 lines (89 loc) · 2.56 KB
/
ci.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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
prepare-npm-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/setup-node@v2.4.1
with:
node-version: 16.x
cache: npm
- name: Validate cache
run: npm ci
lint-and-typecheck:
name: build-lint
runs-on: ubuntu-latest
needs: prepare-npm-cache
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/setup-node@v2.4.1
with:
node-version: 16.x
cache: npm
- name: Install
run: npm ci
- name: Run eslint
run: npm run lint
- name: Run prettier
run: npm run lint-prettier-ci
test:
name: Node v${{ matrix.node-version }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
needs: prepare-npm-cache
steps:
- uses: actions/checkout@v2.4.0
- name: Get npm cache
id: npm-cache
run: echo "::set-output name=dir::$(npm config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-npm-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.4.1
with:
node-version: ${{ matrix.node-version }}
- name: Install and build
run: npm ci
- name: Run tests with coverage
run: npm run test-ci -- --coverage && cat ./coverage/lcov.info
env:
CI: true
- name: Coveralls parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.node-version }}
parallel: true
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
env:
CI: true