-
Notifications
You must be signed in to change notification settings - Fork 26
246 lines (210 loc) · 8.33 KB
/
catalog-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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: Pull request
on:
pull_request:
branches:
- master
paths:
- 'apps/**'
jobs:
checkout-and-build-pr:
runs-on: ubuntu-latest
steps:
# Checkout PR branch and all history (not just last commit), so we can perform `git diff` below
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
# Checkout submodules
# Note: Uses 8 jobs for checking out submodules quicker
- name: Checkout submodules
shell: bash
run: |
# If your submodules are configured to use SSH instead of HTTPS please uncomment the following line
#git config --global url."https://github.com/".insteadOf "git@github.com:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --depth=1 --recursive --jobs 8
# Get Submodule_name using Git Diff
- name: Get/Set SUBMODULE_NAME
run: |
git diff --submodule=log --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
SUB_NAME=$(git diff --submodule=log --diff-filter=AM ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | awk '{for (I=1;I<=NF;I++) if ($I == "Submodule") {print $(I+1)};}')
if [ -z "$SUB_NAME" ]; then
echo "Error: Could not determine submodule name"
exit 1
else
echo "SUBMODULE_NAME=$SUB_NAME" >> $GITHUB_ENV
fi
- name: Check SUBMODULE_NAME was set
if: env.SUBMODULE_NAME != ''
run: |
echo SUBMODULE_NAME: ${{ env.SUBMODULE_NAME }}
# Upload SUBMODULE_NAME as artifact to be used in other jobs
- name: Create submodule_name.txt artifact
if: env.SUBMODULE_NAME != ''
run: |
echo ${{ env.SUBMODULE_NAME }} > submodule_name.txt
- name: Upload SUBMODULE_NAME artifact
uses: actions/upload-artifact@v1
with:
name: submodule_name
path: ./submodule_name.txt
- name: Setup node
if: env.SUBMODULE_NAME != ''
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install Dependencies
if: env.SUBMODULE_NAME != ''
working-directory: ./${{ env.SUBMODULE_NAME }}
run: npm install
- name: Install NR1 CLI
if: env.SUBMODULE_NAME != ''
run: curl -s https://cli.nr-ext.net/installer.sh | sudo bash
- name: NR1 Nerdpack Build
if: env.SUBMODULE_NAME != ''
working-directory: ./${{ env.SUBMODULE_NAME }}
run: nr1 nerdpack:build
lint:
name: lint
needs: checkout-and-build-pr
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
# Checkout submodules
# Note: Uses 8 jobs for checking out submodules quicker
- name: Checkout submodules
shell: bash
run: |
# If your submodules are configured to use SSH instead of HTTPS please uncomment the following line
#git config --global url."https://github.com/".insteadOf "git@github.com:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --depth=1 --recursive --jobs 8
- name: Download submodule_name artifact
uses: actions/download-artifact@v1
with:
name: submodule_name
- name: Set SUBMODULE_NAME env var
run: |
SUB_NAME=$(cat submodule_name/submodule_name.txt)
if [ -z "$SUB_NAME" ]; then
echo "Error: Could not determine submodule name from artifact"
exit 1
else
echo "SUBMODULE_NAME=$SUB_NAME" >> $GITHUB_ENV
echo SUBMODULE_NAME: $SUB_NAME
fi
- name: Setup node
if: env.SUBMODULE_NAME != ''
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install Dependencies
if: env.SUBMODULE_NAME != ''
working-directory: ./${{ env.SUBMODULE_NAME }}
run: npm install
- name: Run eslint-check
if: env.SUBMODULE_NAME != ''
working-directory: ./${{ env.SUBMODULE_NAME }}
run: npm run eslint-check
test:
name: test
needs: checkout-and-build-pr
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
# Checkout submodules
# Note: Uses 8 jobs for checking out submodules quicker
- name: Checkout submodules
shell: bash
run: |
# If your submodules are configured to use SSH instead of HTTPS please uncomment the following line
#git config --global url."https://github.com/".insteadOf "git@github.com:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --depth=1 --recursive --jobs 8
- name: Download submodule_name artifact
uses: actions/download-artifact@v1
with:
name: submodule_name
- name: Set SUBMODULE_NAME env var
run: |
SUB_NAME=$(cat submodule_name/submodule_name.txt)
if [ -z "$SUB_NAME" ]; then
echo "Error: Could not determine submodule name from artifact"
exit 1
else
echo "SUBMODULE_NAME=$SUB_NAME" >> $GITHUB_ENV
echo SUBMODULE_NAME: $SUB_NAME
fi
- name: Setup node
if: env.SUBMODULE_NAME != ''
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install Dependencies
if: env.SUBMODULE_NAME != ''
working-directory: ./${{ env.SUBMODULE_NAME }}
run: npm install
- name: Run npm test
if: env.SUBMODULE_NAME != ''
working-directory: ./${{ env.SUBMODULE_NAME }}
run: npm test
validate-catalog-nerdpack:
name: validate-catalog-requirements
needs: checkout-and-build-pr
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
# Checkout submodules
# Note: Uses 8 jobs for checking out submodules quicker
- name: Checkout submodules
shell: bash
run: |
# If your submodules are configured to use SSH instead of HTTPS please uncomment the following line
#git config --global url."https://github.com/".insteadOf "git@github.com:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --depth=1 --recursive --jobs 8
- name: Download submodule_name artifact
uses: actions/download-artifact@v1
with:
name: submodule_name
- name: Set SUBMODULE_NAME env var
run: |
SUB_NAME=$(cat submodule_name/submodule_name.txt)
if [ -z "$SUB_NAME" ]; then
echo "Error: Could not determine submodule name from artifact"
exit 1
else
echo "SUBMODULE_NAME=$SUB_NAME" >> $GITHUB_ENV
echo SUBMODULE_NAME: $SUB_NAME
fi
- name: Setup node
if: env.SUBMODULE_NAME != ''
uses: actions/setup-node@v1
with:
node-version: 16
# Custom action to check for OSS files
- name: compile files-present-action
if: env.SUBMODULE_NAME != ''
run: |
cd ./.github/actions/files-present-action
npm install
npm run build && npm run pack
- name: files-present-action
if: env.SUBMODULE_NAME != ''
uses: ./.github/actions/files-present-action
with:
path: ./${{ env.SUBMODULE_NAME }}
files: "README.md, .prettierrc.js, .eslintrc.js, .gitignore, package.json, LICENSE, THIRD_PARTY_NOTICES.md, cla.md, .github/ISSUE_TEMPLATE/bug_report.md, .github/ISSUE_TEMPLATE/enhancement.md, nr1.json, icon.png, catalog/config.json"