Skip to content

Commit 8a2b6bc

Browse files
NPA-5247: Use Portman to Generate Postman Collection (#22)
## 🧾 Ticket Link https://nhsd-jira.digital.nhs.uk/browse/NPA-5247 --- ## 📄 Description/Summary of Changes <!-- Describe the changes made in this PR. Include the purpose/scope/impact/context of the changes --> - Generates Postman Collection using Portman with `make postman-generate-collection` - Add GitHub action to test sandbox environment - Action runs as part of PR checks on PR sandbox environment - Added docs on generating a Postman Collection --- ## 🧪 Developer Testing Carried Out <!-- Describe what tests (automated/unit/manual etc.) have been done for the ticket. Include: --> <!-- - Any tests added/updated --> <!-- - Evidence that each acceptance criterion from the Jira ticket is met --> - Automated Sandbox testing --- ## ✅ Developer Checklist <!-- To be completed by the developer --> - [x] I have set the PR title to follow the format: `NPA-XXXX: <short-description>` - [x] My branch name follows the convention: `<type>/NPA-XXXX/<short-description>` - [x] My commit messages follow the template: `NPA-XXXX: <short-description>` - [x] I have updated the documentation accordingly - [x] I have set assignees and added appropriate labels --- ## 👀 Reviewer Checklist <!-- To be completed by the reviewer --> - [ ] Changes meet the acceptance criteria of the Jira ticket - [ ] Code is able to be merged (no conflicts and adheres to coding standards) - [ ] Sufficient test evidence is provided (manual and/or automated) --- ## 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. --------- Co-authored-by: Ellie Bound <175816742+ellie-bound1-NHSD@users.noreply.github.com>
1 parent 162f30e commit 8a2b6bc

18 files changed

Lines changed: 3683 additions & 426 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ indent_size = 4
1919

2020
[{Makefile,*.mk,go.mod,go.sum,*.go,.gitmodules}]
2121
indent_style = tab
22+
23+
[postman/postman_collection.json]
24+
insert_final_newline = unset

.github/actions/compile-spec/action.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Run Postman Collection"
2+
description: Run Postman collection with Newman
3+
4+
inputs:
5+
SANDBOX_BASE_URL:
6+
description: The base URL for the sandbox environment (e.g., https://sandbox.api.service.nhs.uk/im1-pfs-auth/)
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Install Node.js
13+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
14+
with:
15+
node-version: "24"
16+
- name: Install NPM packages
17+
run: npm install
18+
shell: bash
19+
- name: Run Postman Collection
20+
run: make postman-test-pr-environment
21+
shell: bash

.github/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ updates:
1010
- ".github/actions/check-github-actions"
1111
- ".github/actions/check-markdown-format"
1212
- ".github/actions/check-uv-lock"
13-
- ".github/actions/compile-spec"
1413
- ".github/actions/create-lines-of-code-report"
1514
- ".github/actions/perform-static-analysis"
1615
- ".github/actions/prettier-checks"
1716
- ".github/actions/ruff-checks"
1817
- ".github/actions/ruff-format"
18+
- ".github/actions/run-postman-collection"
1919
- ".github/actions/run-unit-tests"
2020
- ".github/actions/scan-dependencies"
2121
- ".github/actions/scan-secrets"

.github/workflows/pull-request-checks.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ jobs:
5050
PROXYGEN_CLIENT_ID: ${{ secrets.PROXYGEN_CLIENT_ID }}
5151
PROXYGEN_KEY_ID: ${{ secrets.PROXYGEN_KEY_ID }}
5252
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }}
53+
54+
run-postman-collection:
55+
name: "Run Postman Collection"
56+
runs-on: ubuntu-latest
57+
needs: deploy-dev-sandbox
58+
steps:
59+
- name: Checkout Repository
60+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
61+
with:
62+
fetch-depth: 0
63+
persist-credentials: false
64+
65+
- name: Run Postman Collection
66+
uses: ./.github/actions/run-postman-collection
67+
env:
68+
SANDBOX_BASE_URL: ${{ needs.deploy-dev-sandbox.outputs.environment_url }}

.github/workflows/reusable-deploy.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ on:
2424
required: true
2525
type: string
2626

27+
outputs:
28+
environment_url:
29+
description: "The URL of the deployed environment"
30+
value: ${{ jobs.deploy-environment.outputs.environment_url }}
31+
2732
secrets:
2833
PROXYGEN_CLIENT_ID:
2934
required: true
@@ -90,8 +95,16 @@ jobs:
9095
needs: build-and-push-container
9196
environment:
9297
name: ${{ inputs.environment }}
93-
url: https://${{ inputs.environment }}.api.platform.nhs.uk/${{ inputs.additional_path && format('im1-pfs-auth-{0}', inputs.additional_path) || 'im1-pfs-auth' }}
98+
url: ${{ steps.deploy-environment-url.outputs.environment_url }}
99+
outputs:
100+
environment_url: ${{ steps.deploy-environment-url.outputs.environment_url }}
94101
steps:
102+
- name: "Output PROXYGEN_URL_PATH"
103+
run: echo "PROXYGEN_URL_PATH=${{ inputs.additional_path && format('im1-pfs-auth-{0}', inputs.additional_path) || 'im1-pfs-auth' }}" >> $GITHUB_ENV
104+
- name: "Output Environment URL"
105+
id: deploy-environment-url
106+
run: echo "ENVIRONMENT_URL=https://${{ inputs.environment }}.api.service.nhs.uk/$PROXYGEN_URL_PATH" >> $GITHUB_OUTPUT
107+
95108
- name: "Checkout code"
96109
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
97110
with:
@@ -105,12 +118,11 @@ jobs:
105118
PROXYGEN_CLIENT_ID: ${{ secrets.PROXYGEN_CLIENT_ID }}
106119
PROXYGEN_KEY_ID: ${{ secrets.PROXYGEN_KEY_ID }}
107120
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }}
108-
109121
- name: Deploy environment
110122
run: make deploy-ci
111123
env:
112124
ENVIRONMENT: ${{ inputs.environment }}
113-
PROXYGEN_URL_PATH: ${{ inputs.additional_path && format('im1-pfs-auth-{0}', inputs.additional_path) || 'im1-pfs-auth' }}
125+
PROXYGEN_URL_PATH: ${{ env.PROXYGEN_URL_PATH }}
114126

115127
- name: "Check Deployment"
116128
run: cat specification/x-nhsd-apim/x-nhsd-apim.generated.yaml

.gitignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# ----------------
2+
# Custom
3+
# ----------------
4+
specification/im1-pfs-auth-api.portman.generated.yaml
5+
# Portman temp directory
6+
tmp/
7+
# ----------------
8+
# Python .gitignore - https://github.com/github/gitignore/blob/main/Python.gitignore
9+
# ----------------
110
.scannerwork
211
*cloc*report*.json
312
*sbom*report*.json
@@ -10,6 +19,7 @@
1019

1120
sandbox/pyproject.toml
1221
sandbox/uv.lock
22+
specification/assets/*.json
1323

1424
### This is the Github Python.gitignore https://github.com/github/gitignore/blob/main/Python.gitignore
1525
# Byte-compiled / optimized / DLL files
@@ -216,7 +226,9 @@ __marimo__/
216226
# Streamlit
217227
.streamlit/secrets.toml
218228

219-
### This is the Github Node.gitignore https://github.com/github/gitignore/blob/main/Node.gitignore
229+
# ----------------
230+
# Node .gitignore - https://github.com/github/gitignore/blob/main/Node.gitignore
231+
# ----------------
220232
# Logs
221233
logs
222234
*.log

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
postman/postman_collection.json

.tool-versions

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ vale 3.12.0
55
gitleaks 8.28.0
66
python 3.13.5
77
actionlint 1.7.7
8-
uv 0.8.3
8+
uv 0.8.5
9+
node 24.5
10+
npm 11.5
911

1012
# ==============================================================================
1113
# The section below is reserved for Docker image versions.

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ spec-compile:
7878
mkdir -p build
7979
npm run spec-compile
8080

81+
# ==============================================================================
82+
# Postman Commands
83+
# ==============================================================================
84+
85+
# Generate Postman collection from OpenAPI specification
86+
postman-generate-collection:
87+
yq 'del(.x-nhsd-apim)' specification/im1-pfs-auth-api.yaml > specification/im1-pfs-auth-api.portman.generated.yaml
88+
npx portman --cliOptionsFile portman/portman-cli.json
89+
90+
# Run Postman tests using Newman
91+
postman-test:
92+
npx newman run postman/postman_collection.json $(NEWMAN_ARGS)
93+
94+
# Run Postman Tests
95+
postman-test-pr-environment:
96+
# Mandatory arguments:
97+
# SANDBOX_BASE_URL: The base URL for the sandbox environment (e.g., https://sandbox.api.service.nhs.uk/im1-pfs-auth/)
98+
@make postman-test NEWMAN_ARGS="--env-var baseUrl=$(SANDBOX_BASE_URL)"
99+
81100
# ==============================================================================
82101
# App Commands
83102
# ==============================================================================

0 commit comments

Comments
 (0)