Skip to content

Commit 03d9be9

Browse files
committed
cmsnav-747 Added api_development.md to summarise the process
1 parent 689c333 commit 03d9be9

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

azure/api_development.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# NHS Website Content API Update and Release Process
2+
3+
This document outlines the steps involved in updating the NHS Website Content API, from making code changes to deploying them to production.
4+
5+
## 1. Prerequisites and Setup
6+
7+
* **Development Environment:**
8+
* Use the provided VSCode Dev Container for an automated setup.
9+
* Alternatively, manually install `make`, NodeJS (`npm`), Python (`poetry`), and Java 8+.
10+
* **Install Dependencies:** Run `make install` in the project root directory. This installs both Node and Python dependencies.
11+
* **Install Git Hooks:** Run `make install-hooks` to set up pre-commit hooks that help prevent committing invalid changes.
12+
* **Environment Variables:** Configure necessary environment variables (e.g., for API keys, tokens). Using `direnv` with a local `.envrc` file is recommended.
13+
14+
## 2. Making Changes
15+
16+
* **Create a Branch:** Create a new feature branch from the `master` branch. Follow the naming convention: `apm-nnn-short-issue-description` (where `apm-nnn` is the relevant Jira ticket number).
17+
* **Implement Changes:** Modify the necessary files:
18+
* **API Specification:** Edit files within the `specification/` directory (primarily `nhs-website-content-api.yaml` and files in `specification/components/`).
19+
* **Sandbox Implementation:** Update the NodeJS sandbox application in the `sandbox/` directory if required.
20+
* **Apigee Proxies:** Modify proxy definitions in `proxies/live/` or `proxies/sandbox/`.
21+
* **Tests:** Add or update tests in the `tests/` directory.
22+
* **Scripts/Tooling:** Update files in `scripts/` or the `Makefile` if necessary.
23+
* **Commit Changes:** Commit your work frequently with clear messages following the format:
24+
```
25+
APM-NNN Summary of changes
26+
27+
Longer description of changes if explaining rationale is necessary...
28+
```
29+
30+
## 3. Local Validation
31+
32+
* **Linting:** Run `make lint` to check code style and specification validity. The pre-commit hooks should also run linters automatically.
33+
* **Build Specification:** Run `make publish` to bundle the OpenAPI specification into a single file in the `build/` directory. This helps catch resolution errors.
34+
* **Preview Specification:** Run `make serve` to view a human-readable version of the specification locally at `http://127.0.0.1:5000`.
35+
* **Local Testing (Conceptual):** While the `Makefile` includes targets like `make test`, running these directly in the VSCode terminal might not work as the full execution context (like dependent services) exists within deployed containers. These tests are primarily designed to be run within the CI/CD pipeline. If manual testing against a locally running sandbox (via Docker) is needed, you would typically use `docker compose exec` to run commands like `pytest` within the appropriate container.
36+
37+
## 4. Pull Request and Code Review
38+
39+
* **Push Branch:** Push your feature branch to the GitHub repository.
40+
* **Create Pull Request (PR):** Open a PR from your feature branch targeting the `master` branch.
41+
* Ensure the PR title and description are clear and link to the relevant Jira ticket (APM-NNN).
42+
* **Automated Checks:** The PR will trigger automated workflows (defined in `.github/workflows/` and `azure/azure-pr-pipeline.yml`):
43+
* Linting checks.
44+
* Deployment of an ephemeral version of the API (including specification, proxy, and sandbox container) to a development environment (e.g., `internal-dev`) for testing.
45+
* **Code Review:** Team members review the code changes, specification updates, and test results from the ephemeral deployment.
46+
* **Approval:** Once the PR is approved and all checks pass, it's ready for merging.
47+
48+
## 5. Merging
49+
50+
* **Merge:** The *reviewer* who approved the PR is responsible for merging it into the `master` branch.
51+
52+
## 6. CI/CD Pipeline (Azure DevOps)
53+
54+
* **Trigger:** Merging to `master` automatically triggers the main Azure DevOps pipelines (`azure-build-pipeline.yml`, `azure-release-pipeline.yml`).
55+
* **Build (`azure-build-pipeline.yml`):**
56+
* Builds the consolidated OpenAPI specification (`make publish`).
57+
* Builds the Apigee proxy bundles (`make build-proxy`).
58+
* Builds any necessary Docker images (e.g., the sandbox defined in `sandbox/Dockerfile` and configured in `ecs-proxies-containers.yml`).
59+
* Pushes Docker images to the container registry.
60+
* Packages build artifacts (spec, proxies, test files, config like `manifest_template.yml`, `ecs-proxies-deploy.yml`) for deployment.
61+
* **Release (`azure-release-pipeline.yml`):**
62+
* Deploys the artifacts and containers sequentially to configured environments (e.g., Internal Dev -> Internal QA -> Production).
63+
* Deployment includes:
64+
* Apigee Proxies (Live and Sandbox).
65+
* Updated API Specification to the Apigee Developer Portal.
66+
* Deployment/Update of backend containers (like the Sandbox) on ECS, configured via `ecs-proxies-deploy.yml`.
67+
* Runs automated tests (smoke tests, integration tests defined in `tests/` and executed via `Makefile` targets like `smoketest` or `test`) against each environment after deployment (`azure/templates/run-tests.yml`).
68+
69+
## 7. Production Release
70+
71+
* **Promotion:** After successful deployment and testing in pre-production environments (e.g., Internal QA), the release pipeline promotes the changes to the Production environment.
72+
* **Post-Release Checks:** Smoke tests (`make smoketest-prod`) are typically run against the production environment to verify the deployment.
73+
* **GitHub Release:** A GitHub release is automatically created/updated upon merging to `master` (driven by `.github/workflows/continuous-integration.yml`).
74+
75+
This process ensures that changes are validated, tested, and deployed systematically across environments.

0 commit comments

Comments
 (0)