Skip to content

Commit 59ae8fc

Browse files
Run Example Tests on Pull Request (#22)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This runs the example tests using GitHub actions on a pull request. ## Context <!-- Why is this change required? What problem does it solve? --> It allows us to test our code is working before merging changes. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [ ] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] I am familiar with the [contributing guidelines](../docs/CONTRIBUTING.md) - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes - [ ] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent 7490494 commit 59ae8fc

File tree

5 files changed

+55
-65
lines changed

5 files changed

+55
-65
lines changed

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
version: "${{ needs.metadata.outputs.version }}"
8989
secrets: inherit
9090
build-stage: # Recommended maximum execution time is 3 minutes
91-
name: "Build stage"
91+
name: "Build & Assurance stage"
9292
needs: [metadata, test-stage]
9393
uses: ./.github/workflows/stage-3-build.yaml
9494
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
@@ -100,16 +100,16 @@ jobs:
100100
python_version: "${{ needs.metadata.outputs.python_version }}"
101101
version: "${{ needs.metadata.outputs.version }}"
102102
secrets: inherit
103-
acceptance-stage: # Recommended maximum execution time is 10 minutes
104-
name: "Acceptance stage"
105-
needs: [metadata, build-stage]
106-
uses: ./.github/workflows/stage-4-acceptance.yaml
107-
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
108-
with:
109-
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
110-
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
111-
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
112-
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
113-
python_version: "${{ needs.metadata.outputs.python_version }}"
114-
version: "${{ needs.metadata.outputs.version }}"
115-
secrets: inherit
103+
# acceptance-stage: # Recommended maximum execution time is 10 minutes
104+
# name: "Acceptance stage"
105+
# needs: [metadata, build-stage]
106+
# uses: ./.github/workflows/stage-4-acceptance.yaml
107+
# if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened'))
108+
# with:
109+
# build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
110+
# build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
111+
# build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
112+
# nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
113+
# python_version: "${{ needs.metadata.outputs.python_version }}"
114+
# version: "${{ needs.metadata.outputs.version }}"
115+
# secrets: inherit

.github/workflows/cicd-2-publish.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,20 @@ jobs:
7676
# asset_path: ./*
7777
# asset_name: repository-template-${{ needs.metadata.outputs.version }}.tar.gz
7878
# asset_content_type: "application/gzip"
79-
success:
80-
name: "Success notification"
81-
runs-on: ubuntu-latest
82-
needs: [publish]
83-
steps:
84-
- name: "Check prerequisites for notification"
85-
id: check
86-
run: echo "secret_exist=${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL != '' }}" >> $GITHUB_OUTPUT
87-
- name: "Notify on publishing packages"
88-
if: steps.check.outputs.secret_exist == 'true'
89-
uses: nhs-england-tools/[email protected]
90-
with:
91-
github-token: ${{ secrets.GITHUB_TOKEN }}
92-
teams-webhook-url: ${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL }}
93-
message-title: "Notification title"
94-
message-text: "This is a notification body"
95-
link: ${{ github.event.pull_request.html_url }}
79+
# success:
80+
# name: "Success notification"
81+
# runs-on: ubuntu-latest
82+
# needs: [publish]
83+
# steps:
84+
# - name: "Check prerequisites for notification"
85+
# id: check
86+
# run: echo "secret_exist=${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL != '' }}" >> $GITHUB_OUTPUT
87+
# - name: "Notify on publishing packages"
88+
# if: steps.check.outputs.secret_exist == 'true'
89+
# uses: nhs-england-tools/[email protected]
90+
# with:
91+
# github-token: ${{ secrets.GITHUB_TOKEN }}
92+
# teams-webhook-url: ${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL }}
93+
# message-title: "Notification title"
94+
# message-text: "This is a notification body"
95+
# link: ${{ github.event.pull_request.html_url }}
Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build stage"
1+
name: "Build & Assurance stage"
22

33
on:
44
workflow_call:
@@ -29,37 +29,27 @@ on:
2929
type: string
3030

3131
jobs:
32-
artefact-1:
33-
name: "Artefact 1"
32+
run-tests:
33+
name: "Run Example Tests"
3434
runs-on: ubuntu-latest
3535
timeout-minutes: 3
3636
steps:
37-
- name: "Checkout code"
38-
uses: actions/checkout@v4
39-
- name: "Build artefact 1"
37+
- uses: actions/checkout@v4
38+
- name: Set up Python
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: '3.12'
42+
- name: Install dependencies
4043
run: |
41-
echo "Building artefact 1 ..."
42-
- name: "Check artefact 1"
43-
run: |
44-
echo "Checking artefact 1 ..."
45-
- name: "Upload artefact 1"
46-
run: |
47-
echo "Uploading artefact 1 ..."
48-
# TODO: Use either action/cache or action/upload-artifact
49-
artefact-2:
50-
name: "Artefact 2"
51-
runs-on: ubuntu-latest
52-
timeout-minutes: 3
53-
steps:
54-
- name: "Checkout code"
55-
uses: actions/checkout@v4
56-
- name: "Build artefact 2"
57-
run: |
58-
echo "Building artefact 2 ..."
59-
- name: "Check artefact 2"
60-
run: |
61-
echo "Checking artefact 2 ..."
62-
- name: "Upload artefact 2"
63-
run: |
64-
echo "Uploading artefact 2 ..."
65-
# TODO: Use either action/cache or action/upload-artifact
44+
python -m pip install --upgrade pip
45+
pip install -r requirements.txt
46+
- name: Ensure browsers are installed
47+
run: python -m playwright install --with-deps
48+
- name: Run example tests
49+
run: pytest
50+
- uses: actions/upload-artifact@v4
51+
if: ${{ !cancelled() }}
52+
with:
53+
name: result-output
54+
path: test-results/
55+
retention-days: 5

buildBase.dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ RUN mkdir -p /utils/
1414
COPY ./utils/ ./utils/
1515
COPY ./pytest.ini ./pytest.ini
1616
COPY ./run_tests.sh ./run_tests.sh
17+
18+
RUN chmod +x ./run_tests.sh

run_tests.sh

100644100755
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/bin/sh
22

3-
BASE_URL=${1:-${BASE_URL}}
4-
5-
pytest --base-url $1
3+
pytest

0 commit comments

Comments
 (0)