-
Notifications
You must be signed in to change notification settings - Fork 95
85 lines (82 loc) · 2.79 KB
/
ci-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
name: Build and test JavaScript
on:
push:
branches: [ main, stable, oldstable ]
pull_request:
branches: [ main, stable, oldstable ]
jobs:
testing:
env:
REPORT_DIR: reports
name: Testing and upload coverage
runs-on: 'ubuntu-latest'
strategy:
matrix:
# 14.x is recommended by https://nodejs.org/en/
node-version: [14.x]
steps:
- uses: actions/checkout@v3
- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# See: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Use Yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
# `--prefer-offline` gives cache priority
- name: Install dependencies
run: yarn install --prefer-offline
- name: Run JavaScript tests
env:
JEST_JUNIT_OUTPUT_DIR: ${{ env.REPORT_DIR }}
run: yarn test:coverage --reporters=default --reporters=jest-junit
- name: Load Lint Results
uses: actions/download-artifact@v3
with:
name: linting-report
path: ${{ env.REPORT_DIR }}
- name: Submit test coverage to codecov.io
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
linting:
env:
REPORT_FILE: linting-report.xml
name: Linting
runs-on: 'ubuntu-latest'
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v3
- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# See: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Use Yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
# `--prefer-offline` gives cache priority
- name: Install dependencies
run: yarn install --prefer-offline
- name: Lint JavaScript files
run: yarn lint --format junit -o ${{ env.REPORT_FILE }}
- name: Store Lint Results
uses: actions/upload-artifact@v3
with:
name: linting-report
path: ${{ env.REPORT_FILE }}