-
Notifications
You must be signed in to change notification settings - Fork 45
296 lines (279 loc) · 14.1 KB
/
pull-request-checks.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# This workflow runs on creation and update of pull
# requests to execute jobs that do not require access
# to repository secrets. Jobs that do require repository
# secrets are executed when this workflow is manually
# executed to ensure protection of those secrets.
name: 'Pull Request Checks'
on:
workflow_dispatch:
inputs:
latest-only:
description: 'Run the latest version of browsers only instead of all versions'
default: true
type: boolean
pull_request:
jobs:
# Jobs for pull_request events
jest-tests:
name: Jest tests
if: github.event_name == 'pull_request'
uses: ./.github/workflows/jest.yml
with:
ref: ${{ github.ref }}
coverage: true
secrets: inherit
types-test:
runs-on: ubuntu-latest
name: Types Test
if: github.event_name == 'pull_request'
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
- name: Install dependencies
run: npm ci
- name: Running types build
run: |
npm run npm:build:types
- name: Running types tests
run: |
npm run test:types
eslint:
name: ESLint
if: github.event_name == 'pull_request'
uses: ./.github/workflows/eslint.yml
with:
ref: ${{ github.ref }}
size-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
- name: Install dependencies
run: npm ci
- name: Running cdn build
run: npm run cdn:build:dev
- name: Generating asset size report
uses: ./.github/actions/size-diff
with:
compare_from: dev
compare_to: local
- name: Reading asset size report
id: asset-size-report
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "results<<$EOF" >> "$GITHUB_OUTPUT"
echo "## Asset Size Report <br><br>" >> "$GITHUB_OUTPUT"
echo "Merging this pull request will result in the following asset size changes: <br><br>" >> "$GITHUB_OUTPUT"
cat ./build/size_report.md >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Comment pull request
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ github.event.number }}
comment: ${{ steps.asset-size-report.outputs.results }}
comment_tag: <!-- browser_agent asset size report -->
- name: Get local stats
id: get-stats
shell: bash
run: |
rum=$(cat ./build/nr-rum-standard.stats.json); echo "rum=$rum" >> $GITHUB_OUTPUT;
full=$(cat ./build/nr-full-standard.stats.json); echo "full=$full" >> $GITHUB_OUTPUT;
spa=$(cat ./build/nr-spa-standard.stats.json); echo "spa=$spa" >> $GITHUB_OUTPUT;
- name: Report lite size to NR
uses: newrelic/capture-build-size@main
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.rum }}
file-name-filter: '.min.js'
trigger: 'pull-request-checks'
- name: Report pro size to NR
uses: newrelic/capture-build-size@main
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.full }}
file-name-filter: '.min.js'
trigger: 'pull-request-checks'
- name: Report spa size to NR
uses: newrelic/capture-build-size@main
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-contents: ${{ steps.get-stats.outputs.spa }}
file-name-filter: '.min.js'
trigger: 'pull-request-checks'
- name: Report dev lite size to NR
uses: newrelic/capture-build-size@main
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-url: 'https://js-agent.newrelic.com/dev/nr-rum-standard.stats.json'
file-name-filter: '.min.js'
trigger: 'pull-request-checks'
version: 'main'
- name: Report dev pro size to NR
uses: newrelic/capture-build-size@main
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-url: 'https://js-agent.newrelic.com/dev/nr-full-standard.stats.json'
file-name-filter: '.min.js'
trigger: 'pull-request-checks'
version: 'main'
- name: Report dev spa size to NR
uses: newrelic/capture-build-size@main
with:
nr-api-key: ${{ secrets.INTERNAL_STAGING_INGEST_LICENSE_KEY }}
nr-account-id: ${{ secrets.INTERNAL_STAGING_INGEST_ACCOUNT_ID }}
nr-env: 'staging'
analysis-file-url: 'https://js-agent.newrelic.com/dev/nr-spa-standard.stats.json'
file-name-filter: '.min.js'
trigger: 'pull-request-checks'
version: 'main'
# Jobs for workflow_dispatch events
find-pull-request:
name: Find pull request target
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
outputs:
pull-request-target: ${{ steps.pull-request-target.outputs.results }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
- name: Find pull request target
id: pull-request-target
uses: ./.github/actions/find-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_required: true
pending-comment-pull-request:
name: Pending comment pull request
if: github.event_name == 'workflow_dispatch'
needs: find-pull-request
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Setup runner
run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y git tzdata
- uses: actions/checkout@v4
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
- uses: actions/setup-node@v4
with:
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
- name: Get workflow time
id: workflow-time
run: echo "results=$(TZ=America/Chicago date +'%B %d, %Y %H:%M:%S %Z')" >> $GITHUB_OUTPUT
- name: Comment pull request
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Pending-yellow)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
comment_tag: <!-- browser_agent pull request checks -->
wdio-coverage:
name: WDIO coverage
if: github.event_name == 'workflow_dispatch'
needs: find-pull-request
uses: ./.github/workflows/wdio-single-browser.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
browser-target: chrome@latest
coverage: true
secrets: inherit
wdio:
name: WDIO
if: github.event_name == 'workflow_dispatch'
needs: find-pull-request
uses: ./.github/workflows/wdio-all-browsers.yml
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
latest-only: ${{ inputs.latest-only }}
secrets: inherit
complete-status-comment-pull-request:
name: Comment pull request
if: always() && github.event_name == 'workflow_dispatch' && needs.find-pull-request.result == 'success'
needs: [find-pull-request,wdio-coverage,wdio]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Setup container
run: sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y git tzdata
- uses: actions/checkout@v4
with:
ref: 'refs/pull/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}/merge'
- uses: actions/setup-node@v4
with:
node-version: 22.11.0 # See package.json for the stable node version that works with our testing. Do not change this unless you know what you are doing as some node versions do not play nicely with our testing server.
- name: Get workflow time
id: workflow-time
run: echo "results=$(TZ=America/Chicago date +'%B %d, %Y %H:%M:%S %Z')" >> $GITHUB_OUTPUT
- name: Comment pull request success
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Success-green)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
comment_tag: <!-- browser_agent pull request checks -->
- name: Comment pull request failed
if: ${{ contains(needs.*.result, 'failure') }}
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Failure-red)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
comment_tag: <!-- browser_agent pull request checks -->
- name: Comment pull request cancelled
if: ${{ contains(needs.*.result, 'cancelled') }}
uses: ./.github/actions/comment-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_number: ${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).pr_number }}
comment: |
[![Static Badge](https://img.shields.io/badge/Pull_Request_Checks-Cancelled-orange)](https://github.com/newrelic/newrelic-browser-agent/actions/runs/${{ github.run_id }})
Last ran on `${{ steps.workflow-time.outputs.results }}`
Checking merge of (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}) into [${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_ref }}](https://github.com/newrelic/newrelic-browser-agent/compare/${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).head_sha }}..${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }}) (${{ fromJSON(needs.find-pull-request.outputs.pull-request-target).base_sha }})
comment_tag: <!-- browser_agent pull request checks -->