-
Notifications
You must be signed in to change notification settings - Fork 7
370 lines (339 loc) · 19.2 KB
/
openactive-test-suite.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
name: Ref Impl
# This workflow is triggered when there is a push or a pull request to the master branch.
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test-server:
runs-on: ubuntu-latest
steps:
# Checks out this project ie OpenActive.Server.NET
- name: Checkout
uses: actions/checkout@v2
# Uses the actions/setup-dotnet action to set up the .NET Core runtime environment with version 3.1.419
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
# Runs the `dotnet build` command to build the "OpenActive.Server.NET.Tests" project and its dependencies. It uses
# the `--configuration Release` flag to build in release mode, which results in optimized code generation
- name: Build OpenActive.Server.NET.Tests and dependencies
run: dotnet build ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release
# Runs the tests for the "OpenActive.Server.NET.Tests" project using the `dotnet test` command. It runs the unit
# tests and uses the `--configuration Release` flag for release mode, `--no-build` to skip rebuilding the project
# since it was built in the previous step, and `--verbosity normal` for the level of detail in the test output
- name: Run OpenActive.Server.NET.Tests
run: dotnet test ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release --no-build --verbosity normal
test-fake-database:
runs-on: ubuntu-latest
steps:
# Checks out this project ie OpenActive.Server.NET
- name: Checkout
uses: actions/checkout@v2
# Uses the actions/setup-dotnet action to set up the .NET Core runtime environment with version 3.1.419
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
# Runs the `dotnet build` command to build the "OpenActive.FakeDatabase.NET.Tests" project and its dependencies.
# It uses the `--configuration Release` flag to build in release mode, which results in optimized code generation
- name: Build OpenActive.FakeDatabase.NET.Tests
run: dotnet build ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release
# Runs the tests for the "OpenActive.FakeDatabase.NET.Tests" project using the `dotnet test` command. It runs the
# unit tests and uses the `--configuration Release` flag for release mode, `--no-build` to skip rebuilding the
# project since it was built in the previous step, and `--verbosity normal` for the level of detail in the test
# output
- name: Run OpenActive.FakeDatabase.NET.Tests
run: dotnet test ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release --no-build --verbosity normal
core:
# Specifies that this job depends on the successful completion of two other jobs: "test-server" and "test-fake-database"
needs:
- test-server
- test-fake-database
runs-on: ubuntu-latest
# Defines a matrix strategy for running tests with different combinations of parameters, allowing for parallel test
# runs with various configurations. For more information about these parameters, see `.github/README.md` in Test
# Suite
strategy:
fail-fast: false
matrix:
mode: ['random', 'controlled']
profile: ['all-features', 'single-seller', 'no-payment-reconciliation', 'no-auth', 'no-tax-calculation', 'prepayment-always-required', 'facilityuse-has-slots']
steps:
# checks out the `OpenActive.Server.NET` project's code repository and places it in a directory named "server"
- name: Checkout OpenActive.Server.NET
uses: actions/checkout@v2
with:
path: server
# checks if the workflow is triggered by a branch starting with `coverage/`. If so, it sets an output variable named
# `mirror_ref` with the branch name, allowing later steps to use it
- name: Use matching coverage/* branch ${{ github.head_ref }} in OpenActive Test Suite
if: ${{ startsWith(github.head_ref, 'coverage/') }}
id: refs
run: echo "::set-output name=mirror_ref::${{ github.head_ref }}"
# checks out Test Suite and places it in a directory named "tests." The branch used for checkout is determined by
# the `mirror_ref` set in the previous step
- name: Checkout OpenActive Test Suite ${{ steps.refs.outputs.mirror_ref }}
uses: actions/checkout@v2
with:
repository: openactive/openactive-test-suite
ref: ${{ steps.refs.outputs.mirror_ref }}
path: tests
# sets up the .NET Core SDK version 3.1.419 in the job's environment
- name: Setup .NET Core SDK 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Setup Node.js 18.17.1
uses: actions/setup-node@v1
with:
node-version: 18.17.1
# runs `dotnet restore` to install the dependencies for the "OpenActive.Server.NET" project. It is conditional and
# depends on the "profile" value not being 'no-auth' or 'single-seller'
- name: Install OpenActive.Server.NET dependencies
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
run: dotnet restore ./server/
# builds `BookingSystem.AspNetCore.IdentityServer` if the `profile` is not `no-auth` or `single-seller` as it is not
# needed for these profiles
- name: Build .NET Core Authentication Authority Reference Implementation
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
run: dotnet build ./server/Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-restore
# starts IdentityServer if the profiles are relevant (see above)
- name: Start .NET Core Authentication Authority Reference Implementation
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
run: |
dotnet run --no-launch-profile --project ./server/Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-build &
# builds Reference Implementation booking server
- name: Build .NET Core Booking Server Reference Implementation
run: dotnet build ./server/Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' && '--no-restore' || '' }}
# starts Reference Implementation booking server
- name: Start .NET Core Booking Server Reference Implementation
run: |
dotnet run --no-launch-profile --project ./server/Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release --no-build &
env:
ASPNETCORE_ENVIRONMENT: ${{ matrix.profile }}
# runs `npm install` to install the JavaScript dependencies for Test Suite, which is located in the "tests"
# directory
- name: Install OpenActive Test Suite
run: npm install
working-directory: tests
# runs the OpenActive integration tests using `npm start` and specifies various environment variables based on the
# `mode` and `profile` matrix variables specified above
- name: Run OpenActive Integration Tests in ${{ matrix.mode }} mode
run: npm start
env:
FORCE_COLOR: 1
NODE_CONFIG: |
{"broker": {"outputPath": "../../output/"}, "integrationTests": { "outputPath": "../../output/", "conformanceCertificatePath": "../../conformance/examples/${{ matrix.profile }}/${{ matrix.mode }}/", "useRandomOpportunities": ${{ matrix.mode == 'random' }}, "conformanceCertificateId": "https://certificates.reference-implementation.openactive.io/examples/${{ matrix.profile }}/${{ matrix.mode }}/" }}
NODE_ENV: .example.${{ matrix.profile }}
NODE_APP_INSTANCE: ci
working-directory: tests
# uploads the test output as an artifact, which can be used for reference or debugging later
- name: Upload test output for ${{ matrix.mode }} mode as artifact
uses: actions/upload-artifact@v2
if: ${{ success() || failure() }}
with:
name: core.${{ matrix.mode }}.${{ matrix.profile }}
path: ./tests/output/
# deploys a conformance certificate to Azure Blob Storage, but it is conditional and only runs when the GitHub
# branch is `master` and the `profile` is 'all-features' and the `mode` is 'controlled'. For more information on
# Coformance Certificates, see `packages/openactive-integration-tests/test/certification/README.md` in Test Suite
- name: Deploy conformance certificate to Azure Blob Storage (master branch for 'all-features' profile in controlled mode only)
uses: bacongobbler/[email protected]
if: ${{ github.ref == 'refs/heads/master' }}
with:
source_dir: ./tests/conformance/
container_name: '$web'
connection_string: ${{ secrets.CONFORMANCE_CERTIFICATE_BLOB_STORAGE_CONNECTION_STRING }}
sync: false
# This job is very similar to the `core` job explained above. However because it runs on .NET Framework as opposed to
# .NET Core, there are some differences. Due to the similarity, only the differences are outlined below.
framework:
needs:
- test-server
- test-fake-database
# runs on an Windows 2019 virtual machine, not an Ubuntu machine
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
mode: ['random', 'controlled']
profile: ['no-auth']
steps:
- name: Checkout OpenActive.Server.NET
uses: actions/checkout@v2
with:
path: server
- name: Use matching coverage/* branch ${{ github.head_ref }} in OpenActive Test Suite
if: ${{ startsWith(github.head_ref, 'coverage/') }}
id: refs
run: echo "::set-output name=mirror_ref::${{ github.head_ref }}"
- name: Checkout OpenActive Test Suite ${{ steps.refs.outputs.mirror_ref }}
uses: actions/checkout@v2
with:
repository: openactive/openactive-test-suite
ref: ${{ steps.refs.outputs.mirror_ref }}
path: tests
- name: Setup Node.js 18.17.1
uses: actions/setup-node@v1
with:
node-version: 18.17.1
# Building and deploying Framework is done using `msbuild` as opposed to `dotnet build`/`dotnet run`. It is started
# using IIS Express
- name: Setup MSBuild path
uses: microsoft/[email protected]
- name: Setup NuGet
uses: NuGet/[email protected]
- name: Install OpenActive.Server.NET dependencies
run: nuget restore .\server\
- name: Build .NET Framework Reference Implementation
run: msbuild .\server\Examples\BookingSystem.AspNetFramework\BookingSystem.AspNetFramework.csproj /p:Configuration=Release
- name: Deploy .NET Framework Reference Implementation to folder
run: msbuild .\server\Examples\BookingSystem.AspNetFramework\BookingSystem.AspNetFramework.csproj /p:Configuration=Release /p:DeployOnBuild=true /t:WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl=${{ runner.temp }}\deploy\ /p:PackageAsSingleFile=false
- name: Start .NET Framework Reference Implementation from folder (using IIS Express)
run: |
Start-Process -FilePath "$Env:Programfiles\IIS Express\iisexpress.exe" -ArgumentList "/path:${{ runner.temp }}\deploy\ /port:5000"
- name: Install OpenActive Test Suite
run: npm install
working-directory: tests
- name: Run OpenActive Integration Tests in ${{ matrix.mode }} mode
run: npm start
env:
FORCE_COLOR: 1
NODE_CONFIG: |
{"broker": {"outputPath": "../../output/"}, "integrationTests": {"outputPath": "../../output/", "useRandomOpportunities": ${{ matrix.mode == 'random' }}, "conformanceCertificateId": "https://openactive.io/OpenActive.Server.NET/certification/"}}
NODE_ENV: .example.${{ matrix.profile }}
NODE_APP_INSTANCE: framework
working-directory: tests
- name: Upload test output for ${{ matrix.mode }} mode as artifact
uses: actions/upload-artifact@v2
if: ${{ success() || failure() }}
with:
name: framework.${{ matrix.mode }}.${{ matrix.profile }}
path: ./tests/output/
# This job uses many of the steps and setup used above. Because of this, only important or different parts have been
# highlighted.
deploy-reference-implementation:
# Master branch only
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- core
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@master
# Setup .NET Core SDK
- name: Setup .NET Core SDK 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
# Run dotnet build and publish
- name: Install OpenActive.Server.NET dependencies
run: dotnet restore
- name: Build OpenActive.Server.NET Booking Server Reference Implementation
run: dotnet build ./Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release --no-restore
- name: Publish OpenActive.Server.NET Booking Server Reference Implementation
run: dotnet publish ./Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release --no-build --output './web-app-package/BookingSystem.AspNetCore'
- name: Build OpenActive.Server.NET Authentication Authority Reference Implementation
run: dotnet build ./Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-restore
- name: Publish OpenActive.Server.NET Authentication Authority Reference Implementation
run: dotnet publish ./Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-build --output './web-app-package/BookingSystem.AspNetCore.IdentityServer'
# Deploy to Azure Web apps
# deploys the `master` branch of Reference Implementation Booking Server and Identity
# Server Reference Implementation to two Azure webapps
- name: 'Deploy Booking Server Reference Implementation using publish profile credentials'
uses: azure/webapps-deploy@v2
with:
app-name: openactive-reference-implementation
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
package: './web-app-package/BookingSystem.AspNetCore'
- name: 'Deploy Authentication Authority Reference Implementation using publish profile credentials'
uses: azure/webapps-deploy@v2
with:
app-name: openactive-reference-implementation-auth
publish-profile: ${{ secrets.AZURE_WEBAPP_AUTH_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
package: './web-app-package/BookingSystem.AspNetCore.IdentityServer'
# This job uses many of the steps and setup used above. Because of this, only important or different parts have been
# highlighted.
publish-server:
# Master branch only
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- core
- framework
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Install Nerdbank.GitVersioning
run: cp Directory.Build.props.template Directory.Build.props
- name: Get current version
uses: dotnet/nbgv@master
id: nbgv
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build ./OpenActive.Server.NET/OpenActive.Server.NET.csproj --configuration Release --no-restore
- name: Test
run: dotnet test ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release --no-restore --verbosity normal
- name: Pack
run: dotnet pack ./OpenActive.Server.NET/OpenActive.Server.NET.csproj --configuration Release --include-source --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
# publishes the `master` branch of OpenActive.Server.NET to Nuget. It then creates a release in the GitHub
# repository
- name: Push to Nuget
if: "! contains(toJSON(github.event.commits.*.message), '[no-release]')"
run: dotnet nuget push "./OpenActive.Server.NET/**/*.nupkg" -k ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json
- name: Create Release
if: "! contains(toJSON(github.event.commits.*.message), '[no-release]')"
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.nbgv.outputs.SimpleVersion }}
release_name: Release ${{ steps.nbgv.outputs.SimpleVersion }}
body: |
This release contains minor amendments based on updates to the [OpenActive Vocabulary](https://openactive.io/ns/) (codified by the [Data Models](https://github.com/openactive/data-models)), and the latest version of the [Dataset Site Template](https://github.com/openactive/dataset-site-template).
Published to Nuget: [OpenActive.Server.NET](https://www.nuget.org/packages/OpenActive.Server.NET/${{ steps.nbgv.outputs.SimpleVersion }}) and [OpenActive.FakeDatabase.NET](https://www.nuget.org/packages/OpenActive.FakeDatabase.NET/${{ steps.nbgv.outputs.SimpleVersion }}).
draft: false
prerelease: false
publish-fake-database:
# Master branch only
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- core
- framework
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Install Nerdbank.GitVersioning
run: cp Directory.Build.props.template Directory.Build.props
- name: Get current version
uses: dotnet/nbgv@master
id: nbgv
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build ./Fakes/OpenActive.FakeDatabase.NET/OpenActive.FakeDatabase.NET.csproj --configuration Release --no-restore
- name: Test
run: dotnet test ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release --no-restore --verbosity normal
- name: Pack
run: dotnet pack ./Fakes/OpenActive.FakeDatabase.NET/OpenActive.FakeDatabase.NET.csproj --configuration Release --include-source --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
- name: Push to Nuget
if: "! contains(toJSON(github.event.commits.*.message), '[no-release]')"
run: dotnet nuget push "./Fakes/OpenActive.FakeDatabase.NET/**/*.nupkg" -k ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json