Skip to content

Commit

Permalink
Merge branch 'master' into feature/top-level-certification-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
civsiv authored Mar 8, 2024
2 parents 4ebce7e + 9df7dc9 commit 97e4f4b
Show file tree
Hide file tree
Showing 194 changed files with 47,318 additions and 24,563 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- name: Checkout OpenActive Test Suite
uses: actions/checkout@v2
- name: Setup Node.js 14.x
- name: Setup Node.js 18.17.1
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 18.17.1
- name: Install OpenActive Test Suite
run: npm install
- name: Run Checks on the Code (Test the Tests!)
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/create-data-model-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
ref: master
path: openactive-test-suite

- name: Setup Node.js 14.x
- name: Setup Node.js 18.17.1
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 18.17.1

- name: Update openactive-integration-tests with latest data-models and validators
run: npm install @openactive/data-models@latest @openactive/data-model-validator@latest --save
Expand Down Expand Up @@ -48,6 +48,14 @@ jobs:
automated pr
draft: false

- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash

- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reference-implementation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ jobs:
with:
dotnet-version: 3.1.419

- name: Setup Node.js 14.x
- name: Setup Node.js 18.17.1
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 18.17.1

- name: Install OpenActive.Server.NET dependencies
run: dotnet restore ./server/
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.16.0
v18.17.1
35 changes: 24 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"<node_internals>/**"
],
"type": "node",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"env": {
"NODE_APP_INSTANCE": "dev",
"NODE_CONFIG": "{\"integrationTests\": {\"useRandomOpportunities\": false}}"
Expand All @@ -40,7 +40,7 @@
"<node_internals>/**"
],
"type": "node",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"env": {
"NODE_APP_INSTANCE": "dev",
"NODE_CONFIG": "{\"integrationTests\": {\"useRandomOpportunities\": true}}"
Expand All @@ -52,7 +52,7 @@
"request": "launch",
"cwd": "${workspaceFolder}/packages/openactive-integration-tests",
"runtimeExecutable": "npm",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"runtimeArgs": ["run-script", "debug"],
"env": {
"NODE_APP_INSTANCE": "dev",
Expand All @@ -66,7 +66,7 @@
"request": "launch",
"cwd": "${workspaceFolder}/packages/openactive-integration-tests",
"runtimeExecutable": "npm",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"runtimeArgs": ["run-script", "debug"],
"env": {
"NODE_APP_INSTANCE": "dev",
Expand All @@ -80,7 +80,7 @@
"request": "launch",
"cwd": "${workspaceFolder}/packages/openactive-integration-tests",
"runtimeExecutable": "npm",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"runtimeArgs": ["run-script", "debug"],
"env": {
"NODE_ENV": "dev",
Expand All @@ -91,18 +91,31 @@
"name": "broker-microservice",
"type": "node",
"request": "launch",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"program": "${workspaceFolder}/packages/openactive-broker-microservice/app.js",
"cwd": "${workspaceFolder}/packages/openactive-broker-microservice/",
"env": {
"NODE_APP_INSTANCE": "dev"
},
},
{
"name": "test-interface-criteria - unit tests",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/test-interface-criteria/",
"runtimeArgs": [
"--inspect-brk",
"node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "validate-feeds",
"type": "node",
"request": "launch",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"program": "${workspaceFolder}/packages/openactive-broker-microservice/app.js",
"cwd": "${workspaceFolder}/packages/openactive-broker-microservice/",
"args": [
Expand All @@ -117,31 +130,31 @@
"name": "test-data-generator",
"type": "node",
"request": "launch",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"program": "${workspaceFolder}/packages/openactive-integration-tests/test-data-generator/test-data-generator.js",
"cwd": "${workspaceFolder}/packages/openactive-integration-tests/"
},
{
"name": "certification-validator-microservice",
"type": "node",
"request": "launch",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"program": "${workspaceFolder}/packages/openactive-integration-tests/test/certification/certification-validator-microservice.js",
"cwd": "${workspaceFolder}/packages/openactive-integration-tests/",
},
{
"name": "doc-gen",
"type": "node",
"request": "launch",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"program": "${workspaceFolder}/packages/openactive-integration-tests/documentation/generator.js",
"cwd": "${workspaceFolder}/packages/openactive-integration-tests/"
},
{
"name": "combined",
"type": "node",
"request": "launch",
"runtimeVersion": "14.16.0",
"runtimeVersion": "18.17.1",
"autoAttachChildProcesses": true,
"program": "${workspaceFolder}/start.js",
"env": {
Expand Down
83 changes: 63 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,22 @@ When code is committed, the documentation generator is automatically run. This p

## Reference Implementation

The OpenActive Test Suite is developed against a reference implementation, [OpenActive.Server.NET](https://github.com/openactive/OpenActive.Server.NET/).
[**OpenActive.Server.NET**](https://github.com/openactive/OpenActive.Server.NET/) is a .NET SDK which can be used to create Open Booking API implementations.

The CI checks that the Test Suite passes for the reference implementation. Therefore, the approach for adding each new test is to work on both:
OpenActive.Server.NET contains a **reference implementation** of the Open Booking API, which is called [`BookingSystem.AspNetCore`](https://github.com/openactive/OpenActive.Server.NET/tree/master/Examples/BookingSystem.AspNetCore).

- Reference Implementation: The implementation of the feature that's being tested.
- Test Suite: The test itself.
The OpenActive Test Suite is developed against [`BookingSystem.AspNetCore`](https://github.com/openactive/OpenActive.Server.NET/tree/master/Examples/BookingSystem.AspNetCore). Test Suite's CI checks that the Test Suite passes for this reference implementation.

Any new feature that affects test coverage must be developed in a `coverage/*` branch in both reposities, in order for the CI to automatically run both feature branches against each other.
Therefore, the approach for adding or updating tests is to work on both:

### Locally running the Reference Implementation
- [OpenActive.Server.NET](https://github.com/openactive/OpenActive.Server.NET/): Ensure that the expected behaviour is implemented in the reference implementation. This may require making changes to the libraries within the SDK, which the reference implementation uses, or the reference implementation ([`BookingSystem.AspNetCore`](https://github.com/openactive/OpenActive.Server.NET/tree/master/Examples/BookingSystem.AspNetCore)) itself.

When you're working on both the Reference Implementation and the Test Suite, you'll want to run the Reference Implementation locally so you can check that the new tests and the new implementations work together.
In some cases, no changes are needed here as the updates to tests may be testing behaviours that have already been correctly implemented in the reference implementation.
- [Test Suite](.): The tests.

Additionally, when running the Reference Implementation locally, there is no limit on the number of tests you can run. The live version has a quota.
Please be sure to follow the [**Pull Request Process**](#pull-request-process) when making changes to ensure that changes in both projects are tested together in CI.

How to run them both locally:

* Reference Implementation: To run this locally, follow the guidelines in its [project](https://github.com/openactive/OpenActive.Server.NET)'s documentation
* Test Suite: With Reference Implementation running locally, use the `dev` config by setting env var `NODE_APP_INSTANCE=dev`.
e.g., to run broker and a specific test separately:
```sh
NODE_APP_INSTANCE=dev npm run start-broker # to start the broker
# in another terminal:
NODE_APP_INSTANCE=dev npm run start-tests -- packages/openactive-integration-tests/test/features/core/common-error-conditions/implemented/not-bookable-test.js
```

**N.B.:** When running Reference Implementation locally, the `unknown-endpoint` test in `core/common-error-conditions` will fail as the dev version of Reference Implementation shows a developer error page instead of the regular 404 response.
When the necessary changes are made to both OpenActive.Server.NET and Test Suite, test them together on your machine by following the steps in [**Locally running Test Suite to test changes**](#locally-running-test-suite-to-test-changes).

## Pull Request Process

Expand All @@ -61,3 +50,57 @@ For new features that affect test coverage, use a `coverage/*` branch in this re
2. Ensure that documentation reflects the new changes.
3. Check that CI tests pass before merging a Pull Request.
4. Ensure that your Pull Request has at least one approval before merging.

## Writing a new test

See the [Integration Tests CONTRIBUTING.md](./packages/openactive-integration-tests/CONTRIBUTING.md) for guidance on writing a new test.

## Locally running Test Suite to test changes

When you are making changes to the Test Suite, please run it on your machine to check that the changes work before submitting a [pull request](#pull-request-process). These changes can be checked against the [**reference implementation**](#reference-implementation). You may or may not also have changes to the reference implementation that is required for your updated tests to pass. Either way, you'll need to run both projects on your machine order to test your changes.

How to run them both locally:

* **Reference Implementation**: To run this locally, follow the guidelines in its [project's contribution documentation](https://github.com/openactive/OpenActive.Server.NET/blob/master/CONTRIBUTING.md).
* **Test Suite**: With the reference implementation running locally, use the [`default-dev.json` config](./config/default-dev.json) by setting env var `NODE_APP_INSTANCE=dev`.

For example, to run broker and a specific test separately (See [**Tips for quicker test runs**](#tips-for-quicker-test-runs) for a much more efficient process):

```sh
NODE_APP_INSTANCE=dev npm start
```

**N.B.:** When running the reference implementation locally, the `unknown-endpoint` test in `core/common-error-conditions` will fail as the dev version of reference implementation shows a developer error page instead of the regular 404 response.

### Tips for quicker test runs

Running all of the tests can take a long time. To speed up your development/testing feedback loop, you can:

1. Run a single test at a time, rather than running all of the tests.
2. Keep [Broker Microservice](./packages/openactive-broker-microservice/) running in the background, rather than restarting it for each test.

Here's an example of how to do this:
```sh
# In one terminal, start broker
NODE_APP_INSTANCE=dev npm run start-broker
# Then, in ANOTHER terminal, run only the opportunity-in-past test
NODE_APP_INSTANCE=dev npm run start-tests -- packages/openactive-integration-tests/test/features/core/common-error-conditions/implemented/opportunity-in-past-test.js
# OR, run only the tests within the common-error-conditions feature
NODE_APP_INSTANCE=dev npm run start-tests -- packages/openactive-integration-tests/test/features/core/common-error-conditions/
```
#### Even quicker test runs - reduce random test data
When using the [`default-dev.json` config](./config/default-dev.json) (i.e. with `NODE_APP_INSTANCE=dev`), Test Suite is set to use [**controlled mode**](https://developer.openactive.io/open-booking-api/key-decisions#controlled-mode). This means that it creates all the data that it needs for testing. Therefore, the [reference implementation](#reference-implementation) does not need to generate its own data, which it does by default.
Turning this off will speed up the bootstrapping of both reference implementation and broker microservice, which no longer needs to harvest lots of data.
To do this, see the [**Optimizing for Controlled Mode**](https://github.com/openactive/OpenActive.Server.NET/blob/master/CONTRIBUTING.md#optimizing-for-controlled-mode) section of OpenActive.Server.NET's contribution documentation.

### NODE_APP_INSTANCE=dev

Setting env var `NODE_APP_INSTANCE=dev` informs Test Suite to use the [`default-dev.json` config file](./config/default-dev.json), which is configured to run against the reference implementation running locally.

`NODE_APP_INSTANCE` is a feature of the [`config`](https://github.com/node-config/node-config/) library.
Loading

0 comments on commit 97e4f4b

Please sign in to comment.