-
Notifications
You must be signed in to change notification settings - Fork 5
263 lines (242 loc) · 8.57 KB
/
nightly-pr-to-main.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
name: Nightly PR to Main
on:
workflow_call:
inputs:
repo-name:
required: true
type: string
pull-request-id:
required: true
type: number
org-name:
required: false
type: string
default: 51degrees
user:
required: false
type: string
default: Automation51D
email:
required: false
type: string
default: "51DCI@51Degrees.com"
dryrun:
required: false
type: string
default: false
cache-assets:
default: false
type: boolean
common-ci-ref:
required: false
type: string
default: ''
secrets:
token:
required: true
AcceptCHBrowserKey:
AcceptCHHardwareKey:
AcceptCHNoneKey:
AcceptCHPlatformKey:
ApiKey:
CodeSigningCert:
CodeSigningCertAlias:
CodeSigningCertPassword:
CsvUrl:
DeviceDetection:
DeviceDetectionUrl:
JavaGpgKeyPassphrase:
JavaPGP:
MavenSettings:
NPMAuthToken:
NginxCert:
NginxKey:
PypiToken:
TestBrowserResourceKey:
TestHardwareResourceKey:
TestLicenseKey:
TestNoSetHeaderResourceKey:
TestPlatformResourceKey:
TestPypiToken:
TestResourceKey:
TestSuperResourceKey:
UsePublishTests:
jobs:
Configure:
name : Configure - ${{ inputs.pull-request-id }}
runs-on: ubuntu-latest
outputs:
options: ${{ steps.configure.outputs.options }}
asset-cache-key: ${{ steps.hash-asset-cache-key.outputs.hash }}
steps:
- name: Checkout Common
uses: actions/checkout@v3
with:
repository: ${{ inputs.org-name }}/common-ci
path: common
ref: ${{ inputs.common-ci-ref }}
- name: Hash the Asset Cache Key
id: hash-asset-cache-key
if: inputs.cache-assets
shell: pwsh
env:
KEY: ${{ toJSON(secrets) }}
run: |
$stringAsStream = [System.IO.MemoryStream]::new()
$writer = [System.IO.StreamWriter]::new($stringAsStream)
$writer.write($env:KEY)
$writer.Flush()
$stringAsStream.Position = 0
"hash=$(Get-Date -Format FileDate)-$((Get-FileHash -InputStream $stringAsStream).Hash)" | Out-File $env:GITHUB_OUTPUT -Append
- name: Configure
shell: pwsh
id: configure
working-directory: ${{ github.workspace }}/common/
run: |
. ${{ github.workspace }}/common/nightly-pr-to-main_configure-pr.ps1 `
-RepoName ${{ inputs.repo-name }} `
-OrgName ${{ inputs.org-name }} `
-GitHubToken ${{ secrets.token }} `
-GitHubOutput $Env:GITHUB_OUTPUT `
-PullRequestId ${{ inputs.pull-request-id }} `
-GitHubUser ${{ inputs.user }} `
-GitHubEmail ${{ inputs.email }}
Build-and-Test:
needs: Configure
strategy:
matrix:
options: ${{ fromJSON(needs.configure.outputs.options ) }}
name: Build and Test - ${{ inputs.pull-request-id }} - ${{ matrix.options.name }}
runs-on: ${{ matrix.options.image }}
steps:
- name: Checkout Common
uses: actions/checkout@v3
with:
repository: ${{ inputs.org-name }}/common-ci
path: common
ref: ${{ inputs.common-ci-ref }}
- name: Install Runtime
if: matrix.options.Language != '' && matrix.options.LanguageVersion != ''
uses: ./common/.github/actions/install_runtime
with:
language: ${{ matrix.options.Language }}
version: ${{ matrix.options.LanguageVersion }}
- name: Restore Asset Cache
if: inputs.cache-assets
uses: actions/cache/restore@v3
with:
key: ${{ needs.configure.outputs.asset-cache-key }}
path: ${{ github.workspace }}/common/assets
- name: Build and Test
id: build-and-test
shell: pwsh
working-directory: ${{ github.workspace }}/common/
env:
SECRETS: ${{ toJSON(secrets) }}
run: |
$DryRun = [bool]::Parse( "${{ inputs.dryrun }}" )
$Options = $(ConvertFrom-Json -AsHashtable '${{ toJSON(matrix.options) }}')
$Options.Add("Keys", $(ConvertFrom-Json -AsHashtable $env:SECRETS))
. ${{ github.workspace }}/common/nightly-pr-to-main_build-and-test.ps1 `
-RepoName ${{ inputs.repo-name }} `
-OrgName ${{ inputs.org-name }} `
-GitHubToken ${{ secrets.token }} `
-GitHubOutput $Env:GITHUB_OUTPUT `
-PullRequestId ${{ inputs.pull-request-id }} `
-Options $Options `
-GitHubUser ${{ inputs.user }} `
-GitHubEmail ${{ inputs.email }} `
-DryRun $DryRun
- name: Save Asset Cache
if: inputs.cache-assets && always()
uses: actions/cache/save@v3
with:
key: ${{ needs.configure.outputs.asset-cache-key }}
path: ${{ github.workspace }}/common/assets
- name: Publish Test Results
if: always()
uses: ./common/.github/actions/publish_test_results
with:
repo-name: ${{ inputs.repo-name }}
name: ${{ matrix.options.name }}
commit: ${{ steps.build-and-test.outputs.pr-sha }}
skip-performance: ${{ !matrix.options.runperformance }}
- name: Upload Performance Results Artifact
uses: actions/upload-artifact@v3.1.2
if: ${{ matrix.options.runperformance }}
with:
name: performance_results_${{ inputs.pull-request-id }}
path: ${{ github.workspace }}/common/${{ inputs.repo-name }}/test-results/performance-summary/results_*.json
if-no-files-found: ignore
- name: Upload Artifacts
uses: actions/upload-artifact@v3.1.2
with:
name: artifacts_${{ inputs.pull-request-id }}
path: ${{ github.workspace }}/common/${{ inputs.repo-name }}/artifacts/*
if-no-files-found: ignore
Compare-Performance:
# This needs to run on Windows to support ScottPlot
runs-on: windows-latest
needs: [ Configure, Build-and-Test ]
name: Compare Performance - ${{ inputs.pull-request-id }}
steps:
- name: Checkout Common
uses: actions/checkout@v3
with:
repository: ${{ inputs.org-name }}/common-ci
path: common
ref: ${{ inputs.common-ci-ref }}
- name: Download Performance Artifact
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: performance_results_${{ inputs.pull-request-id }}
path: ${{ github.workspace }}/common
- name: Compare Performance
shell: pwsh
working-directory: ${{ github.workspace }}/common/
run: |
$DryRun = [bool]::Parse( "${{ inputs.dryrun }}" )
$Options = $(ConvertFrom-Json -AsHashtable '${{ needs.configure.outputs.options }}')
. ${{ github.workspace }}/common/nightly-pr-to-main_compare-performance.ps1 `
-RepoName ${{ inputs.repo-name }} `
-OrgName ${{ inputs.org-name }} `
-GitHubToken ${{ secrets.token }} `
-GitHubOutput $Env:GITHUB_OUTPUT `
-PullRequestId ${{ inputs.pull-request-id }} `
-Options $Options `
-RunId ${{ github.run_id }} `
-GitHubUser ${{ inputs.user }} `
-GitHubEmail ${{ inputs.email }} `
-DryRun $DryRun
- name: Upload Successful Performance Results Artifact
if: ${{ success()}}
uses: actions/upload-artifact@v3.1.2
with:
name: performance_results_passed_${{ inputs.pull-request-id }}
path: ${{ github.workspace }}/common/results_*.json
if-no-files-found: ignore
Complete:
runs-on: ubuntu-latest
name: Complete ${{ inputs.pull-request-id }}
needs: [ Build-and-Test, Compare-Performance ]
steps:
- name: Checkout Common
uses: actions/checkout@v3
with:
repository: ${{ inputs.org-name }}/common-ci
path: common
ref: ${{ inputs.common-ci-ref }}
- name: Complete
shell: pwsh
working-directory: ${{ github.workspace }}/common/
run: |
$DryRun = [bool]::Parse( "${{ inputs.dryrun }}" )
. ${{ github.workspace }}/common/nightly-pr-to-main_complete.ps1 `
-RepoName ${{ inputs.repo-name }} `
-OrgName ${{ inputs.org-name }} `
-GitHubToken ${{ secrets.token }} `
-PullRequestId ${{ inputs.pull-request-id }} `
-GitHubUser ${{ inputs.user }} `
-GitHubEmail ${{ inputs.email }} `
-DryRun $DryRun