From a255910e2cf82b04fe515d3b4d970c413ec48a23 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:16:39 +0000 Subject: [PATCH 1/9] feat: GitHub actions --- action.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000000..89a7a5601d --- /dev/null +++ b/action.yml @@ -0,0 +1,33 @@ +name: 'OpenActive Test Suite' +description: 'Test suite for OpenActive implementations' +inputs: + args: # id of input + description: 'Arguments to pass to `npm start` of OpenActive Test Suite' + required: false + default: '' + config: # id of input + description: 'The path of a config file to copy into ./config/ of OpenActive Test Suite' + required: false + default: '' + NODE_CONFIG: # id of input + description: 'JSON configuration string to pass into OpenActive Test Suite' + required: true + default: '{ "ci": true }' + NODE_ENV: # id of input + description: 'Value of NODE_ENV environment variable to pass into OpenActive Test Suite' + required: false + default: '' + NODE_APP_INSTANCE: # id of input + description: 'Value of NODE_APP_INSTANCE environment variable to pass into OpenActive Test Suite' + required: false + default: '' +runs: + using: 'docker' + image: 'docker://ghcr.io/openactive/test-suite:latest' + args: + - ${{ inputs.args }} + env: + FORCE_COLOR: 1 + NODE_CONFIG: ${{ inputs.NODE_CONFIG }} + NODE_ENV: ${{ inputs.NODE_ENV }} + NODE_APP_INSTANCE: ${{ inputs.NODE_APP_INSTANCE }} From 58d33ea32858d5342c9f648d79478494b314f447 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:38:37 +0000 Subject: [PATCH 2/9] Update docker-entrypoint.sh --- docker-entrypoint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index c5e30e43fb..7c1d1adfe5 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -4,9 +4,11 @@ # enables signal interactivity (e.g. Ctrl-C). ## Specify the working directory explicitly as GitHub Actions will overwrite it -## Copy any config file specified by `INPUT_CONFIG` to the config directory (used by GitHub Actions) -if [ -f "${INPUT_CONFIG}" ]; then - cp "${INPUT_CONFIG}" /openactive-test-suite/config/ +## Copy any config file specified by `INPUT_CONFIG_DIR` to the config directory (used by GitHub Actions) +if [ -f "${INPUT_CONFIG_DIR}" ]; then + cp "${INPUT_CONFIG_DIR}" /openactive-test-suite/config/ + ## Reset INPUT_CONFIG_DIR so that the test suite does not use it + export INPUT_CONFIG_DIR= fi # Change directory and start the app From 0471e6534fa1aaa5189dc7ae9986ce162def6f11 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:40:17 +0000 Subject: [PATCH 3/9] Update action.yml --- action.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 89a7a5601d..48840a2a22 100644 --- a/action.yml +++ b/action.yml @@ -1,23 +1,23 @@ name: 'OpenActive Test Suite' description: 'Test suite for OpenActive implementations' inputs: - args: # id of input + args: description: 'Arguments to pass to `npm start` of OpenActive Test Suite' required: false default: '' - config: # id of input + NODE_CONFIG_DIR: description: 'The path of a config file to copy into ./config/ of OpenActive Test Suite' required: false default: '' - NODE_CONFIG: # id of input + NODE_CONFIG: description: 'JSON configuration string to pass into OpenActive Test Suite' required: true default: '{ "ci": true }' - NODE_ENV: # id of input + NODE_ENV: description: 'Value of NODE_ENV environment variable to pass into OpenActive Test Suite' required: false default: '' - NODE_APP_INSTANCE: # id of input + NODE_APP_INSTANCE: description: 'Value of NODE_APP_INSTANCE environment variable to pass into OpenActive Test Suite' required: false default: '' @@ -28,6 +28,7 @@ runs: - ${{ inputs.args }} env: FORCE_COLOR: 1 + NODE_CONFIG_DIR: ${{ inputs.NODE_CONFIG_DIR }} NODE_CONFIG: ${{ inputs.NODE_CONFIG }} NODE_ENV: ${{ inputs.NODE_ENV }} NODE_APP_INSTANCE: ${{ inputs.NODE_APP_INSTANCE }} From 44bc8f3778165035f350a877573b8523d68af743 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:47:53 +0000 Subject: [PATCH 4/9] Update action.yml --- action.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 48840a2a22..52c5fdec91 100644 --- a/action.yml +++ b/action.yml @@ -6,7 +6,11 @@ inputs: required: false default: '' NODE_CONFIG_DIR: - description: 'The path of a config file to copy into ./config/ of OpenActive Test Suite' + description: 'The path of a config directory to copy into ./config/ of OpenActive Test Suite' + required: false + default: '' + NODE_CONFIG_FILE: + description: 'The path of a config file to copy into ./config/ of OpenActive Test Suite. This will also set NODE_CONFIG and NODE_APP_INSTANCE to ensure that the test suite uses this file.' required: false default: '' NODE_CONFIG: @@ -29,6 +33,7 @@ runs: env: FORCE_COLOR: 1 NODE_CONFIG_DIR: ${{ inputs.NODE_CONFIG_DIR }} + NODE_CONFIG_FILE: ${{ inputs.NODE_CONFIG_FILE }} NODE_CONFIG: ${{ inputs.NODE_CONFIG }} NODE_ENV: ${{ inputs.NODE_ENV }} NODE_APP_INSTANCE: ${{ inputs.NODE_APP_INSTANCE }} From 58838c24bc7c68714c3ce19c7821ad35640275ac Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:57:31 +0000 Subject: [PATCH 5/9] Update docker-entrypoint.sh --- docker-entrypoint.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7c1d1adfe5..5349506471 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,12 +3,25 @@ # The `exec` command replaces the current process with the new process, which # enables signal interactivity (e.g. Ctrl-C). +## INPUT_CONFIG_DIR and INPUT_CONFIG_FILE relate to the `config_dir` and `config_file` inputs in GitHub Actions +## The below is used by the GitHub Action + ## Specify the working directory explicitly as GitHub Actions will overwrite it -## Copy any config file specified by `INPUT_CONFIG_DIR` to the config directory (used by GitHub Actions) +## Copy any config directory specified by `INPUT_CONFIG_DIR` to the config directory if [ -f "${INPUT_CONFIG_DIR}" ]; then cp "${INPUT_CONFIG_DIR}" /openactive-test-suite/config/ - ## Reset INPUT_CONFIG_DIR so that the test suite does not use it - export INPUT_CONFIG_DIR= + ## Reset NODE_CONFIG_DIR so that the test suite does not use it, to ensure that this directory is used + export NODE_CONFIG_DIR= +fi + +## Specify the working directory explicitly as GitHub Actions will overwrite it +## Copy any config file specified by `INPUT_CONFIG_FILE` to the config directory +if [ -f "${INPUT_CONFIG_FILE}" ]; then + cp "${INPUT_CONFIG_FILE}" /openactive-test-suite/config/dev.json + ## Configure test suite to use this file + export NODE_ENV=dev + export NODE_APP_INSTANCE= + export NODE_CONFIG_DIR= fi # Change directory and start the app From e61384e9f2ac5f28eff4ef9fcd75ae264b10b8c2 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:57:35 +0000 Subject: [PATCH 6/9] Update action.yml --- action.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 52c5fdec91..062f084f32 100644 --- a/action.yml +++ b/action.yml @@ -5,11 +5,11 @@ inputs: description: 'Arguments to pass to `npm start` of OpenActive Test Suite' required: false default: '' - NODE_CONFIG_DIR: + config_dir: description: 'The path of a config directory to copy into ./config/ of OpenActive Test Suite' required: false default: '' - NODE_CONFIG_FILE: + config_file: description: 'The path of a config file to copy into ./config/ of OpenActive Test Suite. This will also set NODE_CONFIG and NODE_APP_INSTANCE to ensure that the test suite uses this file.' required: false default: '' @@ -32,8 +32,6 @@ runs: - ${{ inputs.args }} env: FORCE_COLOR: 1 - NODE_CONFIG_DIR: ${{ inputs.NODE_CONFIG_DIR }} - NODE_CONFIG_FILE: ${{ inputs.NODE_CONFIG_FILE }} NODE_CONFIG: ${{ inputs.NODE_CONFIG }} NODE_ENV: ${{ inputs.NODE_ENV }} NODE_APP_INSTANCE: ${{ inputs.NODE_APP_INSTANCE }} From 2e2d43c37f6967e015e116e59f06b186967eff13 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:16:10 +0000 Subject: [PATCH 7/9] Update README.md --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 67edfb19a4..46845665ee 100644 --- a/README.md +++ b/README.md @@ -356,6 +356,41 @@ Some things to note: - When using a hostname other than `localhost` for your booking system, it must included at least one `.` to pass the validator. - `host.docker.internal` must be the host to access your booking system locally if it is not running in another Docker container. This hostname must also be used within `NODE_CONFIG`. +### CI - GitHub Actions + +This repository can also be referenced as a GitHub action, which conveniently wraps the Docker container. + +The following steps may be used within a GitHub Actions script: + +```yaml + steps: + - name: Run OpenActive Test Suite + uses: openactive/openactive-test-suite + with: + config_file: ./test-suite-config.json + NODE_CONFIG: | + {"broker": {"outputPath": "/github/workspace/test-suite/output/", "datasetSiteUrl": "http://host.docker.internal/openactive"}, "integrationTests": { "outputPath": "/github/workspace/test-suite/output/", "conformanceCertificatePath": "/github/workspace/test-suite/conformance/", "conformanceCertificateId": "https://certificates.example.com/openactive/" }, "sellers": {"primary": { "@id": "http://host.docker.internal/api/identifiers/sellers/1","secondary": { "@id": "http://host.docker.internal/api/identifiers/sellers/2"}}}} + - name: Upload test output as artifact + uses: actions/upload-artifact@v2 + if: ${{ success() || failure() }} + with: + name: openactive-test-suite + path: ./test-suite/output/ + - name: Deploy conformance certificate to Azure Blob Storage (master branch only) + uses: bacongobbler/azure-blob-storage-upload@v1.2.0 + if: ${{ github.ref == 'refs/heads/master' }} + with: + source_dir: ./test-suite/conformance/ + container_name: '$web' + connection_string: ${{ secrets.CONFORMANCE_CERTIFICATE_BLOB_STORAGE_CONNECTION_STRING }} + sync: false +``` + +Note that `outputPath` and `conformanceCertificatePath` must start with `/github/workspace/` to ensure these outputs are accessible in subsequent steps. + +As above, `host.docker.internal` must be the host to access your booking system locally to the GitHub action if it is not running in another Docker container. This hostname must also be used within `NODE_CONFIG` for `datasetSiteUrl` and Seller `@id`s. + + ## Test Data Requirements In order to run the tests in random mode, the target Open Booking API implementation will need to have some Opportunity data pre-loaded. Use [Test Data Generator](./packages/openactive-integration-tests/test-data-generator/) to find out how much data is needed and in what configuration. From 84031a355bef2593b3dc09a3c9245ee1da5b77c4 Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:20:33 +0000 Subject: [PATCH 8/9] Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46845665ee..c2fe960e97 100644 --- a/README.md +++ b/README.md @@ -369,7 +369,7 @@ The following steps may be used within a GitHub Actions script: with: config_file: ./test-suite-config.json NODE_CONFIG: | - {"broker": {"outputPath": "/github/workspace/test-suite/output/", "datasetSiteUrl": "http://host.docker.internal/openactive"}, "integrationTests": { "outputPath": "/github/workspace/test-suite/output/", "conformanceCertificatePath": "/github/workspace/test-suite/conformance/", "conformanceCertificateId": "https://certificates.example.com/openactive/" }, "sellers": {"primary": { "@id": "http://host.docker.internal/api/identifiers/sellers/1","secondary": { "@id": "http://host.docker.internal/api/identifiers/sellers/2"}}}} + {"ci": true, "broker": {"outputPath": "/github/workspace/test-suite/output/", "datasetSiteUrl": "http://host.docker.internal/openactive"}, "integrationTests": { "outputPath": "/github/workspace/test-suite/output/", "conformanceCertificatePath": "/github/workspace/test-suite/conformance/", "conformanceCertificateId": "https://certificates.example.com/openactive/" }, "sellers": {"primary": { "@id": "http://host.docker.internal/api/identifiers/sellers/1","secondary": { "@id": "http://host.docker.internal/api/identifiers/sellers/2"}}}} - name: Upload test output as artifact uses: actions/upload-artifact@v2 if: ${{ success() || failure() }} @@ -386,9 +386,13 @@ The following steps may be used within a GitHub Actions script: sync: false ``` +And as in the parent section, `NODE_CONFIG` must include `"ci": true`. + Note that `outputPath` and `conformanceCertificatePath` must start with `/github/workspace/` to ensure these outputs are accessible in subsequent steps. -As above, `host.docker.internal` must be the host to access your booking system locally to the GitHub action if it is not running in another Docker container. This hostname must also be used within `NODE_CONFIG` for `datasetSiteUrl` and Seller `@id`s. +As in the previous section, `host.docker.internal` must be the host to access your booking system locally to the GitHub action if it is not running in another Docker container. This hostname must also be used within `NODE_CONFIG` for `datasetSiteUrl` and Seller `@id`s. + +The Test Suite Certificate should be updated upon each successfull CI run. ## Test Data Requirements From 416ae36f63b800eb17d59bb3d9daf0991573a52c Mon Sep 17 00:00:00 2001 From: Nick Evans <2616208+nickevansuk@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:21:50 +0000 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2fe960e97..5afa2145fd 100644 --- a/README.md +++ b/README.md @@ -365,7 +365,7 @@ The following steps may be used within a GitHub Actions script: ```yaml steps: - name: Run OpenActive Test Suite - uses: openactive/openactive-test-suite + uses: openactive/openactive-test-suite@master with: config_file: ./test-suite-config.json NODE_CONFIG: |