-
Notifications
You must be signed in to change notification settings - Fork 74
112 lines (97 loc) · 3.48 KB
/
main.pr.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
103
104
105
106
107
108
109
110
111
112
name: Build pull request
on:
pull_request:
branches:
- "master"
jobs:
lint-pull-request:
name: Lint pull request
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
node: [18.x]
steps:
- name: Setup node v${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Checkout
uses: actions/checkout@v3
- name: Cache node_modules
uses: actions/cache@v2
with:
key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Check if source or test files changed
id: files_changed
uses: tj-actions/changed-files@v9.1
with:
files: |
src/**/*
spec/**/*
- name: Install dependencies
if: ${{ steps.files_changed.outputs.any_changed == 'true' || steps.files_changed.outputs.any_deleted == 'true' }}
run: |
yarn
- name: Lint files
if: ${{ steps.files_changed.outputs.any_changed == 'true' || steps.files_changed.outputs.any_deleted == 'true' }}
run: |
yarn lint:ci
build-and-test-pull-request:
needs:
- lint-pull-request
name: Build and test pull request
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
node: [14.x, 16.x, 18.x]
module: [cjs, esm, umd]
target: [es5, es2015, esnext]
exclude:
- {node: 14.x, target: esnext}
steps:
- name: Setup node v${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Checkout
uses: actions/checkout@v3
- name: Cache targets
uses: actions/cache@v2
with:
key: ${{ runner.os }}-targets-${{ matrix.node }}-${{ matrix.target }}-${{ matrix.module }}-${{ hashFiles('package.json') }}
path: |
targets
- name: Cache node_modules
uses: actions/cache@v2
with:
key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ matrix.target }}-${{ matrix.module }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Check if test files changed
id: test_files_changed
uses: tj-actions/changed-files@v9.1
with:
files: |
spec/**/*
- name: Check if source files changed
id: source_files_changed
uses: tj-actions/changed-files@v9.1
with:
files: |
src/**/*
- name: Install dependencies
if: ${{ steps.test_files_changed.outputs.any_changed == 'true' || steps.test_files_changed.outputs.any_deleted == 'true' || steps.source_files_changed.outputs.any_changed == 'true' || steps.source_files_changed.outputs.any_deleted == 'true' }}
run: |
yarn
- name: Build package
if: ${{ steps.source_files_changed.outputs.any_changed == 'true' || steps.source_files_changed.outputs.any_deleted == 'true' }}
run: |
yarn build -t ${{ matrix.target }} -m ${{ matrix.module }}
- name: Test package
if: ${{ steps.test_files_changed.outputs.any_changed == 'true' || steps.test_files_changed.outputs.any_deleted == 'true' || steps.source_files_changed.outputs.any_changed == 'true' || steps.source_files_changed.outputs.any_deleted == 'true' }}
run: |
yarn test -t ${{ matrix.target }} -m ${{ matrix.module }}