Skip to content

Commit 027d806

Browse files
civsivlukehesluke
andauthored
feat: add workflows/README.md to elaborate on GitHub workflows (#210)
* feat: add workflows/README.md to elaborate on GitHub workflows * feat: fix CI by upgrading Node version (#220) * move most of the detail into the workflows * Update .github/workflows/README.md Co-authored-by: Luke Winship <luke.winship@gmail.com> * Update .github/workflows/README.md Co-authored-by: Luke Winship <luke.winship@gmail.com> * Update .github/workflows/README.md Co-authored-by: Luke Winship <luke.winship@gmail.com> * Update .github/workflows/README.md Co-authored-by: Luke Winship <luke.winship@gmail.com> * review comments * fix conflict --------- Co-authored-by: Luke Winship <luke.winship@gmail.com>
1 parent 163c655 commit 027d806

2 files changed

Lines changed: 147 additions & 1 deletion

File tree

.github/workflows/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# CI Workflows
2+
This project contains two GitHub Action workflows that are performed following various triggers. For more information on Github Actions see [here](https://docs.github.com/en/actions).
3+
4+
## openactive-test-suite.yml
5+
6+
7+
This workflow defines the following jobs:
8+
- **test-server**
9+
- **test-fake-database**
10+
- **core**
11+
- **framework**
12+
- **deploy-reference-implementation**
13+
- **publish-server**
14+
- **publish-fake-database**
15+
16+
### test-server job
17+
This job builds and runs the `OpenActive.Server.NET.Tests` project i.e. it runs unit tests against `OpenActive.Server.NET`.
18+
19+
### test-fake-database job
20+
This job builds and runs the `Fakes/OpenActive.FakeDatabase.NET.Tests` project i.e. it runs unit tests against `Fakes/OpenActive.FakeDatabase.NET`.
21+
22+
### core job
23+
This job uses Test Suite to run a matrix of tests against the `OpenActive.Server.NET` project.
24+
25+
### framework job
26+
This job is very similar to the above but builds `OpenActive.Server.NET` using .NET Framework and runs Test Suite against it.
27+
28+
29+
### deploy-reference-implementation job
30+
This job deploys the `master` branch of Reference Implementation Booking Server ([see here](../../Examples/BookingSystem.AspNetCore/README.md)) and Identity Server Reference Implementation ([see here](../../Examples/BookingSystem.AspNetCore.IdentityServer/README.md)) to two Azure webapps
31+
32+
33+
### publish-server job
34+
This job publishes the OpenActive.Server.NET project to Nuget. It then creates a release in the GitHub repository.
35+
36+
37+
### publish-fake-database job
38+
Very similar to the above `publish-server` job, this job publishes the Fake Database project within OpenActive.Server.NET to Nuget.
39+
40+
## create-dependencies-pr.yaml
41+
42+
This workflow creates a pull request to OpenActive.Server.NET's OpenActive (OA) dependencies if there has been a change in one of those projects. This therefore keeps Server.NET up-to-date with the rest of the OA ecosystem.
43+
44+
This workflow can be triggered in two ways:
45+
46+
- **workflow_dispatch**: This allows you to manually trigger the workflow through the GitHub Actions UI.
47+
48+
- **repository_dispatch**: This allows the workflow to be triggered when a custom repository dispatch event is sent. It listens for dispatch events from two OA repos: `OpenActive.NET` and `OpenActive.DatasetSite.NET`. For more information on repository dispatch events [see here](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#repository_dispatch)
49+
50+
This workflow defines one job: **generate**.
51+
52+
### generate job
53+
The main steps of this job are as follows:
54+
- **Update OpenActive.NET to latest version in OpenActive.Server.NET**: This step updates the Server.NET solution with the latest OpenActive.NET library.
55+
56+
- **Update OpenActive.DatasetSite.NET to latest version in OpenActive.Server.NET**: Similar to the previous step, this updates Server.NET with the latest OpenActive.DatasetSite.NET.
57+
58+
- **Update OpenActive.NET to latest version in OpenActive.FakeDatabase.NET**: Similar to the previous step, this updates FakeDatabase.NET with the latest OpenActive.NET.
59+
60+
- **Create Pull Request**: This step uses the peter-evans/create-pull-request action to create a pull request. It performs several actions which are relatively self explanatory:
61+
62+
- Sets up the access token needed for making changes to the repository.
63+
- Specifies the path to the repository containing the changes.
64+
- Defines a commit message, committer, author, branch name, and other PR-related details.
65+
- Provides a title and body for the pull request, explaining the purpose of the update.
66+
- Adds labels to the pull request (`automated pr`).
67+
- Marks the pull request as not a draft.
68+
69+
- **Check outputs** prints information about the created pull request, including the pull request number and URL, to the console.

.github/workflows/openactive-test-suite.yml

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Ref Impl
2+
# This workflow is triggered when there is a push or a pull request to the master branch.
23
on:
34
push:
45
branches: [ master ]
@@ -9,56 +10,92 @@ jobs:
910
test-server:
1011
runs-on: ubuntu-latest
1112
steps:
13+
# Checks out this project ie OpenActive.Server.NET
1214
- name: Checkout
1315
uses: actions/checkout@v2
16+
17+
# Uses the actions/setup-dotnet action to set up the .NET Core runtime environment with version 3.1.419
1418
- name: Setup .NET Core 3.1.419
1519
uses: actions/setup-dotnet@v1
1620
with:
1721
dotnet-version: 3.1.419
22+
23+
# Runs the `dotnet build` command to build the "OpenActive.Server.NET.Tests" project and its dependencies. It uses
24+
# the `--configuration Release` flag to build in release mode, which results in optimized code generation
1825
- name: Build OpenActive.Server.NET.Tests and dependencies
1926
run: dotnet build ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release
27+
28+
# Runs the tests for the "OpenActive.Server.NET.Tests" project using the `dotnet test` command. It runs the unit
29+
# tests and uses the `--configuration Release` flag for release mode, `--no-build` to skip rebuilding the project
30+
# since it was built in the previous step, and `--verbosity normal` for the level of detail in the test output
2031
- name: Run OpenActive.Server.NET.Tests
2132
run: dotnet test ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release --no-build --verbosity normal
2233

2334
test-fake-database:
2435
runs-on: ubuntu-latest
2536
steps:
37+
# Checks out this project ie OpenActive.Server.NET
2638
- name: Checkout
2739
uses: actions/checkout@v2
40+
41+
# Uses the actions/setup-dotnet action to set up the .NET Core runtime environment with version 3.1.419
2842
- name: Setup .NET Core 3.1.419
2943
uses: actions/setup-dotnet@v1
3044
with:
3145
dotnet-version: 3.1.419
46+
47+
# Runs the `dotnet build` command to build the "OpenActive.FakeDatabase.NET.Tests" project and its dependencies.
48+
# It uses the `--configuration Release` flag to build in release mode, which results in optimized code generation
3249
- name: Build OpenActive.FakeDatabase.NET.Tests
3350
run: dotnet build ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release
51+
52+
# Runs the tests for the "OpenActive.FakeDatabase.NET.Tests" project using the `dotnet test` command. It runs the
53+
# unit tests and uses the `--configuration Release` flag for release mode, `--no-build` to skip rebuilding the
54+
# project since it was built in the previous step, and `--verbosity normal` for the level of detail in the test
55+
# output
3456
- name: Run OpenActive.FakeDatabase.NET.Tests
3557
run: dotnet test ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release --no-build --verbosity normal
3658

3759
core:
60+
# Specifies that this job depends on the successful completion of two other jobs: "test-server" and "test-fake-database"
3861
needs:
3962
- test-server
4063
- test-fake-database
4164
runs-on: ubuntu-latest
65+
66+
# Defines a matrix strategy for running tests with different combinations of parameters, allowing for parallel test
67+
# runs with various configurations. For more information about these parameters, see `.github/README.md` in Test
68+
# Suite
4269
strategy:
4370
fail-fast: false
4471
matrix:
4572
mode: ['random', 'controlled']
4673
profile: ['all-features', 'single-seller', 'no-payment-reconciliation', 'no-auth', 'no-tax-calculation', 'prepayment-always-required', 'facilityuse-has-slots']
4774
steps:
75+
76+
# checks out the `OpenActive.Server.NET` project's code repository and places it in a directory named "server"
4877
- name: Checkout OpenActive.Server.NET
4978
uses: actions/checkout@v2
5079
with:
5180
path: server
81+
82+
# checks if the workflow is triggered by a branch starting with `coverage/`. If so, it sets an output variable named
83+
# `mirror_ref` with the branch name, allowing later steps to use it
5284
- name: Use matching coverage/* branch ${{ github.head_ref }} in OpenActive Test Suite
5385
if: ${{ startsWith(github.head_ref, 'coverage/') }}
5486
id: refs
5587
run: echo "::set-output name=mirror_ref::${{ github.head_ref }}"
88+
89+
# checks out Test Suite and places it in a directory named "tests." The branch used for checkout is determined by
90+
# the `mirror_ref` set in the previous step
5691
- name: Checkout OpenActive Test Suite ${{ steps.refs.outputs.mirror_ref }}
5792
uses: actions/checkout@v2
5893
with:
5994
repository: openactive/openactive-test-suite
6095
ref: ${{ steps.refs.outputs.mirror_ref }}
6196
path: tests
97+
98+
# sets up the .NET Core SDK version 3.1.419 in the job's environment
6299
- name: Setup .NET Core SDK 3.1.419
63100
uses: actions/setup-dotnet@v1
64101
with:
@@ -67,26 +104,44 @@ jobs:
67104
uses: actions/setup-node@v1
68105
with:
69106
node-version: 18.17.1
107+
108+
# runs `dotnet restore` to install the dependencies for the "OpenActive.Server.NET" project. It is conditional and
109+
# depends on the "profile" value not being 'no-auth' or 'single-seller'
70110
- name: Install OpenActive.Server.NET dependencies
71111
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
72112
run: dotnet restore ./server/
113+
114+
# builds `BookingSystem.AspNetCore.IdentityServer` if the `profile` is not `no-auth` or `single-seller` as it is not
115+
# needed for these profiles
73116
- name: Build .NET Core Authentication Authority Reference Implementation
74117
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
75118
run: dotnet build ./server/Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-restore
119+
120+
# starts IdentityServer if the profiles are relevant (see above)
76121
- name: Start .NET Core Authentication Authority Reference Implementation
77122
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
78123
run: |
79124
dotnet run --no-launch-profile --project ./server/Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-build &
125+
126+
# builds Reference Implementation booking server
80127
- name: Build .NET Core Booking Server Reference Implementation
81128
run: dotnet build ./server/Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' && '--no-restore' || '' }}
129+
130+
# starts Reference Implementation booking server
82131
- name: Start .NET Core Booking Server Reference Implementation
83132
run: |
84133
dotnet run --no-launch-profile --project ./server/Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release --no-build &
85134
env:
86135
ASPNETCORE_ENVIRONMENT: ${{ matrix.profile }}
136+
137+
# runs `npm install` to install the JavaScript dependencies for Test Suite, which is located in the "tests"
138+
# directory
87139
- name: Install OpenActive Test Suite
88140
run: npm install
89141
working-directory: tests
142+
143+
# runs the OpenActive integration tests using `npm start` and specifies various environment variables based on the
144+
# `mode` and `profile` matrix variables specified above
90145
- name: Run OpenActive Integration Tests in ${{ matrix.mode }} mode
91146
run: npm start
92147
env:
@@ -96,12 +151,18 @@ jobs:
96151
NODE_ENV: .example.${{ matrix.profile }}
97152
NODE_APP_INSTANCE: ci
98153
working-directory: tests
154+
155+
# uploads the test output as an artifact, which can be used for reference or debugging later
99156
- name: Upload test output for ${{ matrix.mode }} mode as artifact
100157
uses: actions/upload-artifact@v2
101158
if: ${{ success() || failure() }}
102159
with:
103160
name: core.${{ matrix.mode }}.${{ matrix.profile }}
104161
path: ./tests/output/
162+
163+
# deploys a conformance certificate to Azure Blob Storage, but it is conditional and only runs when the GitHub
164+
# branch is `master` and the `profile` is 'all-features' and the `mode` is 'controlled'. For more information on
165+
# Coformance Certificates, see `packages/openactive-integration-tests/test/certification/README.md` in Test Suite
105166
- name: Deploy conformance certificate to Azure Blob Storage (master branch for 'all-features' profile in controlled mode only)
106167
uses: bacongobbler/azure-blob-storage-upload@v1.2.0
107168
if: ${{ github.ref == 'refs/heads/master' }}
@@ -111,11 +172,15 @@ jobs:
111172
connection_string: ${{ secrets.CONFORMANCE_CERTIFICATE_BLOB_STORAGE_CONNECTION_STRING }}
112173
sync: false
113174

175+
# This job is very similar to the `core` job explained above. However because it runs on .NET Framework as opposed to
176+
# .NET Core, there are some differences. Due to the similarity, only the differences are outlined below.
114177
framework:
115178
needs:
116179
- test-server
117180
- test-fake-database
181+
# runs on an Windows 2019 virtual machine, not an Ubuntu machine
118182
runs-on: windows-2019
183+
119184
strategy:
120185
fail-fast: false
121186
matrix:
@@ -140,6 +205,9 @@ jobs:
140205
uses: actions/setup-node@v1
141206
with:
142207
node-version: 18.17.1
208+
209+
# Building and deploying Framework is done using `msbuild` as opposed to `dotnet build`/`dotnet run`. It is started
210+
# using IIS Express
143211
- name: Setup MSBuild path
144212
uses: microsoft/setup-msbuild@v1.0.2
145213
- name: Setup NuGet
@@ -172,6 +240,8 @@ jobs:
172240
name: framework.${{ matrix.mode }}.${{ matrix.profile }}
173241
path: ./tests/output/
174242

243+
# This job uses many of the steps and setup used above. Because of this, only important or different parts have been
244+
# highlighted.
175245
deploy-reference-implementation:
176246
# Master branch only
177247
if: ${{ github.ref == 'refs/heads/master' }}
@@ -197,7 +267,9 @@ jobs:
197267
run: dotnet build ./Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-restore
198268
- name: Publish OpenActive.Server.NET Authentication Authority Reference Implementation
199269
run: dotnet publish ./Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-build --output './web-app-package/BookingSystem.AspNetCore.IdentityServer'
200-
# Deploy to Azure Web apps
270+
# Deploy to Azure Web apps
271+
# deploys the `master` branch of Reference Implementation Booking Server and Identity
272+
# Server Reference Implementation to two Azure webapps
201273
- name: 'Deploy Booking Server Reference Implementation using publish profile credentials'
202274
uses: azure/webapps-deploy@v2
203275
with:
@@ -211,6 +283,8 @@ jobs:
211283
publish-profile: ${{ secrets.AZURE_WEBAPP_AUTH_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
212284
package: './web-app-package/BookingSystem.AspNetCore.IdentityServer'
213285

286+
# This job uses many of the steps and setup used above. Because of this, only important or different parts have been
287+
# highlighted.
214288
publish-server:
215289
# Master branch only
216290
if: ${{ github.ref == 'refs/heads/master' }}
@@ -240,6 +314,9 @@ jobs:
240314
run: dotnet test ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release --no-restore --verbosity normal
241315
- name: Pack
242316
run: dotnet pack ./OpenActive.Server.NET/OpenActive.Server.NET.csproj --configuration Release --include-source --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
317+
318+
# publishes the `master` branch of OpenActive.Server.NET to Nuget. It then creates a release in the GitHub
319+
# repository
243320
- name: Push to Nuget
244321
if: "! contains(toJSON(github.event.commits.*.message), '[no-release]')"
245322
run: dotnet nuget push "./OpenActive.Server.NET/**/*.nupkg" -k ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)