Skip to content

NHSDigital/nhs-notify-shared-modules

Repository files navigation

NHS Notify Repository Template

CI/CD Pull Request Quality Gate Status

Start with an overview or a brief description of what the project is about and what it does. For example -

Welcome to our repository template designed to streamline your project setup! This robust template provides a reliable starting point for your new projects, covering an essential tech stack and encouraging best practices in documenting.

This repository template aims to foster a user-friendly development environment by ensuring that every included file is concise and adequately self-documented. By adhering to this standard, we can promote increased clarity and maintainability throughout your project's lifecycle. Bundled within this template are resources that pave the way for seamless repository creation. Currently supported technologies are:

  • Terraform
  • Docker

Make use of this repository template to expedite your project setup and enhance your productivity right from the get-go. Enjoy the advantage of having a well-structured, self-documented project that reduces overhead and increases focus on what truly matters - coding!

Table of Contents

Documentation

Setup

By including preferably a one-liner or if necessary a set of clear CLI instructions we improve user experience. This should be a frictionless installation process that works on various operating systems (macOS, Linux, Windows WSL) and handles all the dependencies.

Clone the repository

git clone https://github.com/nhs-england-tools/repository-template.git
cd nhs-england-tools/repository-template

Prerequisites

The following software packages, or their equivalents, are expected to be installed and configured:

Note

The version of GNU make available by default on macOS is earlier than 3.82. You will need to upgrade it or certain make tasks will fail. On macOS, you will need Homebrew installed, then to install make, like so:

brew install make

You will then see instructions to fix your $PATH variable to make the newly installed version available. If you are using dotfiles, this is all done for you.

  • GNU sed and GNU grep are required for the scripted command-line output processing,
  • GNU coreutils and GNU binutils may be required to build dependencies like Python, which may need to be compiled during installation,

Note

For macOS users, installation of the GNU toolchain has been scripted and automated as part of the dotfiles project. Please see this script for details.

  • Python required to run Git hooks,
  • jq a lightweight and flexible command-line JSON processor.

Configuration

Installation and configuration of the toolchain dependencies

make config

Usage

This repository provides shared resources for NHS Notify service repositories:

Terraform Modules

Reusable Terraform modules are published as GitHub release assets. Service repos reference them via release URLs:

module "lambda_example" {
  source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip"
  # ... module configuration
}

See infrastructure/modules/ for available modules.

Pre-commit Hooks

Centralised pre-commit hooks are defined in .pre-commit-hooks.yaml and can be consumed by service repos:

# In service repo's scripts/config/pre-commit.yaml
repos:
  - repo: https://github.com/NHSDigital/nhs-notify-shared-modules
    rev: v2.1.0  # Use specific tag for version control
    hooks:
      - id: sort-dictionary
      - id: scan-secrets
        args: [check=whole-history]
      - id: check-file-format
        args: [check=branch]

Available hooks:

  • sort-dictionary - Sorts Vale dictionary files to avoid merge conflicts
  • scan-secrets - Scans for hard-coded secrets using Gitleaks
  • check-file-format - Validates EditorConfig compliance

Arguments:

  • scan-secrets: check={whole-history,last-commit,staged-changes} (default: staged-changes)
  • check-file-format: check={all,staged-changes,working-tree-changes,branch} (default: working-tree-changes)

GitHub Composite Actions

Reusable GitHub Actions can be referenced directly from service repository workflows:

# In service repository's .github/workflows/*.yaml
jobs:
  scan-secrets:
    steps:
      - uses: actions/checkout@v4
      - uses: NHSDigital/nhs-notify-shared-modules/.github/actions/scan-secrets@v2.1.0

See the .github/actions/ directory for available actions.

Versioning Strategy

  • Use semantic versioning for releases (e.g., v2.1.0)
  • Service repositories should pin specific tags rather than using main
  • Update service repository references after testing new shared-modules releases
  • Breaking changes require major version bump

Testing

There are make tasks for you to configure to run your tests. Run make test to see how they work. You should be able to use the same entry points for local development as in your CI pipeline.

Design

Diagrams

The C4 model is a simple and intuitive way to create software architecture diagrams that are clear, consistent, scalable and most importantly collaborative. This should result in documenting all the system interfaces, external dependencies and integration points.

The source for diagrams should be in Git for change control and review purposes. Recommendations are draw.io and Mermaids. Here is an example Mermaids sequence diagram:

sequenceDiagram
    User->>+Service: GET /users?params=...
    Service->>Service: auth request
    Service->>Database: get all users
    Database-->>Service: list of users
    Service->>Service: filter users
    Service-->>-User: list[User]
Loading

Modularity

Most of the projects are built with customisability and extendability in mind. At a minimum, this can be achieved by implementing service level configuration options and settings. The intention of this section is to show how this can be used. If the system processes data, you could mention here for example how the input is prepared for testing - anonymised, synthetic or live data.

Contributing

Describe or link templates on how to raise an issue, feature request or make a contribution to the codebase. Reference the other documentation files, like

  • Environment setup for contribution, i.e. CONTRIBUTING.md
  • Coding standards, branching, linting, practices for development and testing
  • Release process, versioning, changelog
  • Backlog, board, roadmap, ways of working
  • High-level requirements, guiding principles, decision records, etc.

Contacts

Provide a way to contact the owners of this project. It can be a team, an individual or information on the means of getting in touch via active communication channels, e.g. opening a GitHub discussion, raising an issue, etc.

Licence

The LICENCE.md file will need to be updated with the correct year and owner

Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.

Any HTML or Markdown documentation is © Crown Copyright and available under the terms of the Open Government Licence v3.0.

About

Terraform Shared Modules repo for all Notify AMET repos

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 10