Skip to content

Commit cda69b5

Browse files
authored
Merge pull request #3 from NHSDigital/feature/test-cicd
Adding in linting and specification checks to CI/CD pipeline
2 parents 79b3e23 + 494d25c commit cda69b5

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: "Lint and Validate OpenAPI v2 Spec"
22
description: "Lint and validate an OpenAPI v2 (Swagger) specification using Spectral and Swagger CLI"
33
inputs:
4-
spec-file:
5-
description: "Path to the OpenAPI v2 (Swagger) specification file"
4+
apim-env:
5+
description: "APIM environment for constructing the spec"
66
required: true
77

88
runs:
@@ -11,17 +11,28 @@ runs:
1111
- name: Set up Node.js
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: '20'
14+
node-version: "20"
1515

16-
- name: Install Spectral and Swagger CLI
16+
- name: Install dependencies
1717
shell: bash
1818
run: |
19-
npm install -g @stoplight/spectral-cli swagger-cli
19+
sudo apt-get update
20+
sudo apt-get install -y make
21+
22+
- name: Install Spectral, Swagger CLI, and Redocly CLI
23+
shell: bash
24+
run: |
25+
npm install -g @stoplight/spectral-cli swagger-cli @redocly/cli
26+
27+
- name: Construct OpenAPI Spec
28+
shell: bash
29+
run: |
30+
make construct-spec APIM_ENV=${{ inputs.apim-env }}
2031
2132
- name: Lint OpenAPI Spec with Spectral
2233
shell: bash
23-
run: spectral lint ${{ inputs.spec-file }}
34+
run: spectral lint --ruleset .spectral.yaml build/specification/eligibility-signposting-api.yaml
2435

2536
- name: Validate OpenAPI Spec with Swagger CLI
2637
shell: bash
27-
run: swagger-cli validate ${{ inputs.spec-file }}
38+
run: swagger-cli validate build/specification/eligibility-signposting-api.yaml

.github/workflows/stage-1-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ jobs:
118118
- uses: actions/checkout@v4
119119
- uses: ./.github/actions/lint-and-validate-specification
120120
with:
121-
spec-file: specification/eligibility-signposting-api.yaml
121+
apim-env: sandbox # or your desired environment

.spectral.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: spectral:oas

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ construct-spec: guard-APIM_ENV
110110
mkdir -p build/specification && \
111111
npx redocly bundle specification/eligibility-signposting-api.yaml --remove-unused-components --keep-url-references --ext yaml \
112112
> build/specification/eligibility-signposting-api.yaml
113-
ifeq ($(APIM_ENV), sandbox)
114-
@ $(MAKE) publish
115-
endif
116113

117114
SPEC_DIR := $(CURDIR)/specification
118115
POSTMAN_DIR := $(SPEC_DIR)/postman

scripts/config/vale/styles/config/vocabularies/words/accept.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ OAuth
1010
Octokit
1111
onboarding
1212
Podman
13+
Proxygen
1314
Python
15+
Redocly
1416
sed
1517
Syft
1618
Terraform

specification/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ To build a specification for a specific environment:
2828
2. Run `make construct-spec` from the repository root, which:
2929
- Updates templates with environment-specific values
3030
- Uses Redocly to compile the complete specification to `build/specification/`
31-
- For the `sandbox` environment, automatically runs `make publish` to convert the specification to JSON and save it to `sandbox/specification/` for immediate use
31+
3. For the `sandbox` environment, run `make publish` to convert the specification to JSON and save it to `sandbox/specification/` for immediate use
3232

3333
### Deploying Environment-Specific Specifications
3434

specification/eligibility-signposting-api.yaml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)