Skip to content

Commit b4d8d13

Browse files
CCM-14029 Centralise Precommits & GHAs
1 parent 98605e0 commit b4d8d13

2 files changed

Lines changed: 86 additions & 5 deletions

File tree

.pre-commit-hooks.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Pre-commit Hook Manifest
2+
# This file defines hooks that this repository PROVIDES to other repos.
3+
# Service repos reference these via: repo: https://github.com/NHSDigital/nhs-notify-shared-modules
4+
#
5+
# This is NOT the pre-commit config for this repo (that's in scripts/config/pre-commit.yaml)
6+
7+
- id: sort-dictionary
8+
name: Sort dictionary
9+
entry: scripts/githooks/sort-dictionary.sh
10+
language: script
11+
pass_filenames: false
12+
13+
- id: scan-secrets
14+
name: Scan secrets
15+
entry: scripts/githooks/scan-secrets.sh
16+
language: script
17+
pass_filenames: false
18+
19+
- id: check-file-format
20+
name: Check file format
21+
entry: scripts/githooks/check-file-format.sh
22+
language: script
23+
pass_filenames: false

README.md

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Make use of this repository template to expedite your project setup and enhance
3434
## Documentation
3535

3636
- [Built](/)
37-
- [Source](/docs/README.md)
3837

3938
## Setup
4039

@@ -83,7 +82,68 @@ make config
8382
8483
## Usage
8584

86-
After a successful installation, provide an informative example of how this project can be used. Additional code snippets, screenshots and demos work well in this space. You may also link to the other documentation resources, e.g. the [User Guide](./docs/user-guide.md) to demonstrate more use cases and to show more features.
85+
This repository provides shared resources for NHS Notify service repositories:
86+
87+
### Terraform Modules
88+
89+
Reusable Terraform modules are published as GitHub release assets. Service repos reference them via release URLs:
90+
91+
```hcl
92+
module "lambda_example" {
93+
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip"
94+
# ... module configuration
95+
}
96+
```
97+
98+
See [infrastructure/modules/](./infrastructure/modules/) for available modules.
99+
100+
### Pre-commit Hooks
101+
102+
Centralised pre-commit hooks are defined in [.pre-commit-hooks.yaml](./.pre-commit-hooks.yaml) and can be consumed by service repos:
103+
104+
```yaml
105+
# In service repo's scripts/config/pre-commit.yaml
106+
repos:
107+
- repo: https://github.com/NHSDigital/nhs-notify-shared-modules
108+
rev: v2.1.0 # Use specific tag for version control
109+
hooks:
110+
- id: sort-dictionary
111+
- id: scan-secrets
112+
args: [check=whole-history]
113+
- id: check-file-format
114+
args: [check=branch]
115+
```
116+
117+
**Available hooks:**
118+
- `sort-dictionary` - Sorts Vale dictionary files to avoid merge conflicts
119+
- `scan-secrets` - Scans for hardcoded secrets using gitleaks
120+
- `check-file-format` - Validates EditorConfig compliance
121+
122+
**Arguments:**
123+
- `scan-secrets`: `check={whole-history,last-commit,staged-changes}` (default: `staged-changes`)
124+
- `check-file-format`: `check={all,staged-changes,working-tree-changes,branch}` (default: `working-tree-changes`)
125+
126+
### GitHub Composite Actions
127+
128+
Reusable GitHub Actions can be referenced directly from service repo workflows:
129+
130+
```yaml
131+
# In service repo's .github/workflows/*.yaml
132+
jobs:
133+
scan-secrets:
134+
steps:
135+
- uses: actions/checkout@v4
136+
- uses: NHSDigital/nhs-notify-shared-modules/.github/actions/scan-secrets@v2.1.0
137+
```
138+
139+
See [.github/actions/](./.github/actions/) for available actions.
140+
141+
### Versioning Strategy
142+
143+
- Use **semantic versioning** for releases (e.g., `v2.1.0`)
144+
- Service repos should **pin specific tags** rather than using `main`
145+
- Update service repo references after testing new shared-modules releases
146+
- Breaking changes require major version bump
87147

88148
### Testing
89149

@@ -95,9 +155,7 @@ There are `make` tasks for you to configure to run your tests. Run `make test`
95155

96156
The [C4 model](https://c4model.com/) 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.
97157

98-
![Repository Template](./docs/diagrams/Repository_Template_GitHub_Generic.png)
99-
100-
The source for diagrams should be in Git for change control and review purposes. Recommendations are [draw.io](https://app.diagrams.net/) (example above in [docs](.docs/diagrams/) folder) and [Mermaids](https://github.com/mermaid-js/mermaid). Here is an example Mermaids sequence diagram:
158+
The source for diagrams should be in Git for change control and review purposes. Recommendations are [draw.io](https://app.diagrams.net/) and [Mermaids](https://github.com/mermaid-js/mermaid). Here is an example Mermaids sequence diagram:
101159

102160
```mermaid
103161
sequenceDiagram

0 commit comments

Comments
 (0)