-
Notifications
You must be signed in to change notification settings - Fork 328
130 lines (123 loc) · 4.15 KB
/
check_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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Check PR
on: pull_request
jobs:
build:
if: github.repository_owner == 'pnp'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
node: [18]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org'
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
- name: Compress output (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -cvf build.tar --exclude node_modules ./
- name: Compress output (Windows)
if: matrix.os == 'windows-latest'
run: 7z a -ttar -xr!node_modules -r build.tar .
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.node }}
path: build.tar
test:
if: github.repository_owner == 'pnp'
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
# node versions to run tests on
nodeRun: [18]
# node versions on which code was built and should be tested
nodeBuild: [18]
include:
- os: ubuntu-latest
nodeRun: 16
nodeBuild: 18
- os: ubuntu-latest
nodeRun: 20
nodeBuild: 18
steps:
- name: Configure pagefile
if: matrix.os == 'windows-latest'
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- uses: actions/download-artifact@v3
with:
name: build-${{ matrix.os }}-${{ matrix.nodeBuild }}
- name: Unpack build artifact (non-Windows)
if: matrix.os != 'windows-latest'
run: tar -xvf build.tar && rm build.tar
- name: Unpack build artifact (Windows)
if: matrix.os == 'windows-latest'
run: 7z x build.tar && del build.tar
- name: Use Node.js ${{ matrix.nodeRun }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.nodeRun }}
registry-url: 'https://registry.npmjs.org'
- name: Cache node modules
id: cache
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ matrix.os }}-${{ matrix.nodeBuild }}-${{ hashFiles('**/npm-shrinkwrap.json') }}
- name: Restore dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Test with coverage
# we run coverage only on Node@18
if: matrix.nodeRun == 18
run: npm test
- name: Test without coverage
# we want to run tests on older Node versions to ensure that code works
if: matrix.nodeRun != 18
run: npm run test:test
- name: Compress output (non-Windows)
if: matrix.nodeRun == 18 && matrix.os != 'windows-latest' && always()
run: tar -cvf coverage.tar coverage
- name: Compress output (Windows)
if: matrix.nodeRun == 18 && matrix.os == 'windows-latest' && always()
run: 7z a -ttar -r coverage.tar coverage
- uses: actions/upload-artifact@v3
if: matrix.nodeRun == 18 && always()
with:
name: coverage-${{ matrix.os }}-${{ matrix.nodeRun }}
path: coverage.tar
test_docs:
if: github.repository_owner == 'pnp'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
working-directory: docs
- name: Build docs
run: npm run build
working-directory: docs