-
Notifications
You must be signed in to change notification settings - Fork 2.7k
179 lines (150 loc) · 5.14 KB
/
build-test-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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Run CI
# Runs CI on Pull Requests for libraries affected by PR
on:
pull_request:
paths:
- 'lib/**/*'
- 'extensions/msal-node-extensions/**/*'
- '!**.md'
- '.github/workflows/build-test-pr.yml'
concurrency:
group: ci-${{github.ref}}
cancel-in-progress: true
permissions:
contents: read
jobs:
pre-check:
permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files
pull-requests: read # for dorny/paths-filter to read pull requests
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'packages' output variable
packages: ${{ steps.lib-filter.outputs.changes }}
extensions: ${{ steps.extensions-filter.outputs.node-extensions }}
steps:
- uses: dorny/paths-filter@v2
id: lib-filter
with:
# &common and &browser are YAML anchors
# *common and *browser references previously defined anchor
# browser/node filter will match any path under common as well as their own
# angular/react filter will match any path under common and browser as well as their own
filters: |
msal-core:
- 'lib/msal-core/**/**.!(md)'
- '.github/workflows/build-test-pr.yml'
msal-common: &common
- 'lib/msal-common/**/**.!(md)'
- '.github/workflows/build-test-pr.yml'
msal-browser: &browser
- *common
- 'lib/msal-browser/**/**.!(md)'
msal-node:
- *common
- 'lib/msal-node/**/**.!(md)'
msal-angular:
- *browser
- 'lib/msal-angular/**/**.!(md)'
msal-react:
- *browser
- 'lib/msal-react/**/**.!(md)'
node-token-validation:
- *common
- 'lib/node-token-validation/**/**.!(md)'
- uses: dorny/paths-filter@v2
id: extensions-filter
with:
filters: |
node-extensions:
- 'lib/msal-common/**/**.!(md)'
- '.github/workflows/build-test-pr.yml'
- 'extensions/msal-node-extensions/**/**.!(md)'
lib-build-test:
needs: pre-check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['package1', 'package2'] if both package folders contains changes
library: ${{ fromJSON(needs.pre-check.outputs.packages) }}
name: ${{ matrix.library }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Restore node_modules
uses: actions/cache@v3
id: cache
with:
path: |
node_modules
lib/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('package-lock.json', 'lib/*/package-lock.json') }}
- name: Clean Install
if: steps.cache.outputs.cache-hit != 'true'
env:
RUNNING_NODE_CI: 1
run: npm ci
- name: Upload npm logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm_logs_${{ matrix.library }}
path: ~/.npm/_logs/**/*
retention-days: 2
- name: Build packages
working-directory: lib/${{ matrix.library }}
run: npm run build:all
- name: Lint
working-directory: lib/${{ matrix.library }}
run: npm run lint
- name: Unit Tests with coverage
working-directory: lib/${{ matrix.library }}
run: npm run test:coverage
- name: Upload Test Coverage to CodeCov
if: success()
uses: codecov/codecov-action@v3
with:
files: lib/${{matrix.library}}/coverage/lcov.info
flags: ${{ matrix.library }}
extensions-build-test:
needs: pre-check
runs-on: windows-2019
if: needs.pre-check.outputs.extensions == 'true'
name: msal-node-extensions
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- name: Clean Install
env:
RUNNING_NODE_CI: 1
run: npm ci
- name: Upload npm logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: npm_logs_msal-node-extensions
path: ~/npm/cache/_logs/**/*
retention-days: 2
- name: Build packages
working-directory: extensions/msal-node-extensions
run: npm run build:all
- name: Lint
working-directory: extensions/msal-node-extensions
run: npm run lint
- name: Unit Tests with coverage
working-directory: extensions/msal-node-extensions
run: npm run test:coverage
- name: Upload Test Coverage to CodeCov
if: success()
uses: codecov/codecov-action@v3
with:
files: extensions/msal-node-extensions/coverage/lcov.info
flags: msal-node-extensions