-
Notifications
You must be signed in to change notification settings - Fork 1
190 lines (161 loc) · 5.23 KB
/
test.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
180
181
182
183
184
185
186
187
188
189
190
name: Unit Tests
on:
pull_request:
paths:
- 'packages/auth0-acul-js/**'
- 'packages/ul-react-component/**'
- 'packages/ul-react/**'
push:
branches:
- master
paths:
- 'packages/auth0-acul-js/**'
- 'packages/ul-react-component/**'
- 'packages/ul-react/**'
permissions:
contents: read
pull-requests: read
concurrency:
group: “${{ github.workflow }}-${{ github.ref }}”
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
NODE_VERSION: 18
jobs:
determine-package:
name: Determine modified files
runs-on: ubuntu-latest
outputs:
auth0-acul-js-changed: ${{ steps.determine_package.outputs.auth0-acul-js-changed }}
ul-react-component-changed: ${{ steps.determine_package.outputs.ul-react-component-changed }}
ul-react-changed: ${{ steps.determine_package.outputs.ul-react-changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Determine affected packages
id: determine_package
shell: bash
run: |
auth0_acul_js_changed=false
ul_react_component_changed=false
ul_react_changed=false
if [ ${{ github.event.pull_request.changed_files }} -ne 0 ]; then
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"${{ github.event.pull_request.url }}/files" \
> files.json
cat files.json
jq -r '.[].filename' files.json > changed_files.txt
cat changed_files.txt
if grep -q "packages/auth0-acul-js/" changed_files.txt; then
auth0_acul_js_changed=true
fi
if grep -q "packages/ul-react-component/" changed_files.txt; then
ul_react_component_changed=true
fi
if grep -q "packages/ul-react/" changed_files.txt; then
ul_react_changed=true
fi
fi
echo "auth0-acul-js-changed=$auth0_acul_js_changed" >> $GITHUB_OUTPUT
echo "ul-react-component-changed=$ul_react_component_changed" >> $GITHUB_OUTPUT
echo "ul-react-changed=$ul_react_changed" >> $GITHUB_OUTPUT
auth0-acul-js-build:
needs: determine-package
if: ${{ needs.determine-package.outputs.auth0-acul-js-changed == 'true' }}
name: Build and Test auth0-acul-js
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url : "https://registry.npmjs.org"
- name: Install dependencies
shell: bash
working-directory: packages/auth0-acul-js
run: |
npm install --include=dev
continue-on-error: true
- name: Build package
shell: bash
working-directory: packages/auth0-acul-js
run: |
npm run build
- name: Run tests
shell: bash
working-directory: packages/auth0-acul-js
run: |
npm run test
ul-react-component-build:
needs: determine-package
if: ${{ needs.determine-package.outputs.ul-react-component-changed == 'true' }}
name: Build and Test ul-react-component
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url : "https://registry.npmjs.org"
- name: Install dependencies
shell: bash
working-directory: packages/ul-react-component
run: |
npm install --include=dev
- name: Build package
shell: bash
working-directory: packages/ul-react-component
run: |
npm run build
- name: Run tests
shell: bash
working-directory: packages/ul-react-component
run: |
npm run test
ul-react-build:
needs: determine-package
if: ${{ needs.determine-package.outputs.ul-react-changed == 'true' }}
name: Build and Test ul-react
runs-on: ubuntu-22.04-2cpu-8ram-75ssd
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url : "https://registry.npmjs.org"
- name: Install dependencies
shell: bash
working-directory: packages/ul-react
run: |
npm install --include=dev
- name: Build package
shell: bash
working-directory: packages/ul-react
run: |
npm run build
- name: Run tests
shell: bash
working-directory: packages/ul-react
run: |
npm run test
notify:
needs:
- auth0-acul-js-build
- ul-react-component-build
- ul-react-build
runs-on: ubuntu-latest
if: always()
steps:
- name: Notify Status
run: echo "All relevant package tests completed."