Skip to content

Commit 5d6e542

Browse files
authored
Merge branch 'main' into feature/CCM-11602_get_endpoint
2 parents 5ef7bed + 3b7b924 commit 5d6e542

File tree

15 files changed

+522
-29
lines changed

15 files changed

+522
-29
lines changed

.github/actions/build-proxies/action.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: "Build Proxies"
22
description: "Build Proxies"
3+
34
inputs:
45
version:
56
description: "Version number"
67
required: true
8+
79
runs:
810
using: composite
911

@@ -19,7 +21,6 @@ runs:
1921
run: npm ci
2022
shell: bash
2123

22-
2324
- name: Setup Proxy Name and target
2425
shell: bash
2526
run: |
@@ -35,10 +36,8 @@ runs:
3536
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
3637
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3738
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
38-
3939
fi
4040
41-
4241
- name: Install Proxygen client
4342
shell: bash
4443
run: |
@@ -54,29 +53,6 @@ runs:
5453
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
5554
envsubst < ./.github/proxygen-settings.yaml | cat
5655
57-
58-
- name: Build internal dev oas
59-
working-directory: .
60-
shell: bash
61-
run: |
62-
if [ -z $PR_NUMBER ]
63-
then
64-
make build-json-oas-spec APIM_ENV=internal-dev
65-
else
66-
make build-json-oas-spec APIM_ENV=internal-dev-pr
67-
fi
68-
69-
- name: Set target and cert
70-
shell: bash
71-
run: |
72-
jq --arg newurl "$TARGET" '.["x-nhsd-apim"].target.url = $newurl' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
73-
jq --arg newmtls "$MTLS_NAME" '.["x-nhsd-apim"].target.security.secret = $newmtls' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
74-
75-
- name: Deploy to Internal Dev
76-
shell: bash
77-
run: |
78-
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm
79-
8056
- name: Build sandbox oas
8157
working-directory: .
8258
shell: bash
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Deploy proxy to internal-dev
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
deploy-internal-dev:
11+
runs-on: ubuntu-latest
12+
name: Deploy to Internal Dev
13+
env:
14+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_ENCODED_NOTIFY_SUPPLIER_PRIVATE_KEY }}
15+
PROXYGEN_KID: notify-supplier-key-1
16+
PROXYGEN_CLIENT_ID: nhs-notify-supplier-client
17+
PROXYGEN_API_NAME: nhs-notify-supplier
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 24
25+
26+
- name: Npm install
27+
working-directory: .
28+
run: npm ci
29+
shell: bash
30+
31+
- name: "Check if pull request exists for this branch"
32+
id: pr_exists
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
37+
echo "Current branch is '$branch_name'"
38+
39+
pr_json=$(gh pr list --head "$branch_name" --state open --json number --limit 1)
40+
pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty')
41+
42+
if [[ -n "$pr_number" ]]; then
43+
echo "Pull request exists: #$pr_number"
44+
echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
45+
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
46+
else
47+
echo "Pull request doesn't exist"
48+
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
49+
echo "pr_number=" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- name: Setup Proxy Name and target
53+
shell: bash
54+
env:
55+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
56+
run: |
57+
if [ -z $PR_NUMBER ]
58+
then
59+
echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
60+
echo "TARGET=https://main.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
61+
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
62+
echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
63+
else
64+
echo "TARGET=https://pr$PR_NUMBER.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
65+
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
66+
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
67+
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
68+
fi
69+
70+
- name: Install Proxygen client
71+
shell: bash
72+
run: |
73+
# Install proxygen cli
74+
pip install pipx
75+
pipx install proxygen-cli
76+
77+
# Setup proxygen auth and settings
78+
mkdir -p ${HOME}/.proxygen
79+
echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
80+
envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
81+
envsubst < ./.github/proxygen-credentials-template.yaml | cat
82+
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
83+
envsubst < ./.github/proxygen-settings.yaml | cat
84+
85+
- name: Build internal dev oas
86+
working-directory: .
87+
shell: bash
88+
env:
89+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
90+
run: |
91+
if [ -z $PR_NUMBER ]
92+
then
93+
make build-json-oas-spec APIM_ENV=internal-dev
94+
else
95+
make build-json-oas-spec APIM_ENV=internal-dev-pr
96+
fi
97+
98+
- name: Set target and cert
99+
shell: bash
100+
run: |
101+
jq --arg newurl "$TARGET" '.["x-nhsd-apim"].target.url = $newurl' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
102+
jq --arg newmtls "$MTLS_NAME" '.["x-nhsd-apim"].target.security.secret = $newmtls' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
103+
104+
- name: Deploy to Internal Dev
105+
shell: bash
106+
run: |
107+
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version.json
1212

1313
# Please, add your custom content below!
1414
.idea
15+
.env
1516

1617
# dependencies
1718
node_modules

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
//".devcontainer": true,
1212
".github": false,
1313
".vscode": false
14-
}
14+
},
1515
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ If packages are unavailable the latest SDKs can be downloaded directly from:
6868

6969
### Examples
7070

71-
TODO: Links to example clients.
71+
TODO:CCM-11209 Links to example clients.
7272

7373
## API Developers
7474

@@ -106,7 +106,7 @@ should understand the below.
106106
##### Servers
107107

108108
- Servers folder is being built at build time from OAS specs.
109-
- TODO: Build actual servers
109+
- TODO:CCM-12139 Build actual servers
110110

111111
##### Libs
112112

tests/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Playwright
3+
node_modules/
4+
/test-results/
5+
/playwright-report/
6+
/blob-report/
7+
/playwright/.cache/
8+
/allure-results
9+
/target

tests/config/main.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
import { config as baseConfig } from './playwright.base.config';
3+
import { getReporters } from './reporters';
4+
5+
const localConfig: PlaywrightTestConfig = {
6+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
7+
reporter: getReporters('api-test'),
8+
...baseConfig,
9+
//globalSetup: require.resolve('./setup/globalSetup'),
10+
//globalTeardown: require.resolve('./setup/globalTeardown'),
11+
testIgnore: [],
12+
projects: [
13+
{
14+
name: 'sandbox',
15+
testMatch: 'tests/messages/get_single_letter/*.spec.ts',
16+
},
17+
],
18+
};
19+
20+
export default localConfig;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
3+
const baseUrl = process.env.NHSD_APIM_PROXY_URL || 'http://localhost:3000/';
4+
const envMaxInstances = Number.parseInt(process.env.WORKERS_MAX_INST!) || 10;
5+
/**
6+
* See https://playwright.dev/docs/test-configuration.
7+
*/
8+
export const config: PlaywrightTestConfig = {
9+
testDir: '../sandbox/messages/get_single_letter/',
10+
testMatch: '*.spec.ts/',
11+
/* Maximum time one test can run for. */
12+
timeout: 60 * 1000,
13+
workers: envMaxInstances,
14+
expect: {
15+
/**
16+
* Maximum time expect() should wait for the condition to be met.
17+
* For example in `await expect(locator).toHaveText();`
18+
*/
19+
timeout: 5000,
20+
},
21+
/* Run tests in files in parallel */
22+
fullyParallel: true,
23+
/* Fail the build on CI if you accidentally left test.only in the source code. */
24+
forbidOnly: !!process.env.CI,
25+
/* Retry on CI only */
26+
retries: process.env.CI ? 2 : 0,
27+
28+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
29+
use: {
30+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
31+
actionTimeout: 0,
32+
/* Base URL to use in actions like `await page.goto('/')`. */
33+
baseURL: baseUrl,
34+
ignoreHTTPSErrors: true,
35+
trace: 'on-first-retry',
36+
/* Slows down Playwright operations by the specified amount of milliseconds. */
37+
launchOptions: {
38+
slowMo: 0,
39+
},
40+
},
41+
};
42+
export default config;

tests/config/reporters.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { ReporterDescription } from '@playwright/test';
2+
3+
const resultsDir = process.env.RESULTS_DIR || 'results';
4+
const reportsDir = process.env.REPORTS_DIR || 'reports';
5+
6+
export function getReporters(allureFolder: string) {
7+
return [
8+
[
9+
'allure-playwright',
10+
{
11+
outputFolder: `./target/reports/allure-results/${allureFolder}`,
12+
detail: false,
13+
suiteTitle: true,
14+
open: 'always',
15+
environmentInfo: {
16+
E2E_NODE_VERSION: process.env.ENVIRONMENT,
17+
E2E_OS: process.platform,
18+
},
19+
},
20+
],
21+
[
22+
'html',
23+
{
24+
outputFolder: `../target/test-artifacts/${reportsDir}/html-report`,
25+
open: process.env.CI ? 'never' : 'on-failure',
26+
},
27+
],
28+
['list', { printSteps: true }],
29+
[
30+
'junit',
31+
{
32+
outputFile: `../target/test-artifacts/${resultsDir}/junit-results.xml`,
33+
},
34+
],
35+
[
36+
'json',
37+
{
38+
outputFile: `../target/test-artifacts/${resultsDir}/json-results.json`,
39+
},
40+
],
41+
] as ReporterDescription[];
42+
}

tests/constants/api_constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const LETTERS_ENDPOINT = 'letters';

0 commit comments

Comments
 (0)