Skip to content

Commit 1c2f9c2

Browse files
committed
more documentation
1 parent 94bcbd3 commit 1c2f9c2

File tree

5 files changed

+170
-28
lines changed

5 files changed

+170
-28
lines changed

CONTRIBUTING.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,61 @@
11
# Contribution Guidelines
22

33
## Raising an Issue
4+
45
If you raise an issue against this repository, please include as much information as possible to reproduce any bugs,
56
or specific locations in the case of content errors.
67

78
## Contributing code
9+
810
To contribute code, please fork the repository and raise a pull request.
911

1012
Ideally pull requests should be fairly granular and aim to solve one problem each. It would also be helpful if they
1113
linked to an issue. If the maintainers cannot understand why a pull request was raised, it will be rejected,
1214
so please explain why the changes need to be made (unless it is self-evident).
1315

1416
### Merge responsibility
15-
* It is the responsibility of the reviewer to merge branches they have approved.
16-
* It is the responsibility of the author of the merge to ensure their merge is in a mergeable state.
17-
* It is the responsibility of the maintainers to ensure the merge process is unambiguous and automated where possible.
17+
18+
- It is the responsibility of the reviewer to merge branches they have approved.
19+
- It is the responsibility of the author of the merge to ensure their merge is in a mergeable state.
20+
- It is the responsibility of the maintainers to ensure the merge process is unambiguous and automated where possible.
1821

1922
### Branch naming
23+
2024
Branch names should be of the format:
2125

2226
`aea-nnn-short-issue-description`
2327

2428
Multiple branches are permitted for the same ticket.
2529

2630
### Commit messages
27-
Commit messages should be formatted as follows:
28-
```
29-
AEA-NNN Summary of changes
3031

31-
Longer description of changes if explaining rationale is necessary,
32-
limited to 80 columns and spanning as many lines as you need.
32+
We do not enforce any conventions on commit messages to a branch, as we use squash commits when merging to main branch.
33+
34+
Commits from a pull request get squashed into a single commit on merge, using the pull request title as the commit message.
35+
Please format your pull request title using tags from [ESLint Convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint) as follows:
36+
37+
```text
38+
Tag: [AEA-NNNN] - Short description
3339
```
3440

41+
Tag can be one of:
42+
43+
- `Fix` - for a bug fix. (Patch release)
44+
- `Update` - either for a backwards-compatible enhancement or for a rule change that adds reported problems. (Patch release)
45+
- `New` - implemented a new feature. (Minor release)
46+
- `Breaking` - for a backwards-incompatible enhancement or feature. (Major release)
47+
- `Docs` - changes to documentation only. (Patch release)
48+
- `Build` - changes to build process only. (No release)
49+
- `Upgrade` - for a dependency upgrade. (Patch release)
50+
- `Chore` - for refactoring, adding tests, etc. (anything that isn't user-facing). (Patch release)
51+
52+
If the current release is x.y.z then
53+
- a patch release increases z by 1
54+
- a minor release increases y by 1
55+
- a major release increases x by 1
56+
57+
Correct tagging is necessary for our automated versioning and release process ([Release](./RELEASE.md)).
58+
3559
### Changelog
36-
Every pull request must include a change to the changelog.
3760

38-
Add changes to the top of the current date. If the date is old, the reviewer should update the changelog to be correct before merging.
61+
Release changelogs are generated from the titles of pull requests merged into the `main` branch. Please ensure that your pull request title is sufficiently descriptive of the changes made.

README.md

Lines changed: 83 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,98 @@
1-
# eps-cdk-utils
1+
# Electronic Prescription Service CDK Utils
22

3-
This contains a docker image used to deploy cdk to our environments and a cdk-constructs library
3+
![Build](https://github.com/NHSDigital/eps-cdk-utils/workflows/release/badge.svg?branch=main)
44

5-
# cdk-constructs
5+
This repository contains a docker image used to deploy CDK to our environments and a CDK constructs library for common EPS project patterns.
66

7-
This contains common cdk constructs used in eps projects
7+
- `docker/` Contains Dockerfile used to build image used fo for CDK deployments
8+
- `packages/cdkConstructs/` Contains common CDK constructs used in EPS projects
9+
- `scripts/` Utilities helpful to developers of this specification
10+
- `.github/` Contains GitHub workflows that are used for building and deploying from pull requests and releases
811

9-
Available constructs are
12+
## CDK Constructs
1013

11-
- TypescriptLambdaFunction
14+
This contains common CDK constructs used in EPS projects.
1215

13-
# development
16+
Available constructs are:
1417

15-
If you want to test a new construct, add it to packages/cdkConstructs
16-
Run the following to produce a distributable tarball
17-
```
18+
- `TypescriptLambdaFunction` - A reusable construct for TypeScript Lambda functions
19+
20+
## Contributing
21+
22+
Contributions to this project are welcome from anyone, providing that they
23+
conform to the [guidelines for contribution](./CONTRIBUTING.md) and the [community code of conduct](./CODE_OF_CONDUCT.md).
24+
25+
### Licensing
26+
27+
This code is dual licensed under the MIT license and the OGL (Open Government
28+
License). Any new work added to this repository must conform to the conditions of
29+
these licenses. In particular this means that this project may not depend on
30+
GPL-licensed or AGPL-licensed libraries, as these would violate the terms of those
31+
libraries' licenses.
32+
33+
The contents of this repository are protected by Crown Copyright (C).
34+
35+
## Development
36+
37+
It is recommended that you use Visual Studio Code and a devcontainer as this
38+
will install all necessary components and correct versions of tools and languages.
39+
See [https://code.visualstudio.com/docs/devcontainers/containers](https://code.visualstudio.com/docs/devcontainers/containers) for details on how to set this up on your host machine.
40+
41+
All commits must be made using [signed commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
42+
43+
### Setup
44+
45+
If you want to test a new construct, add it to `packages/cdkConstructs`.
46+
47+
### Testing New Constructs
48+
49+
Run the following to produce a distributable tarball:
50+
51+
```bash
1852
make package
1953
```
20-
This will produce a tarball file in lib folder
2154

22-
Copy this to the project you want to use it in and use the following to install it
55+
This will produce a tarball file in the `lib` folder.
2356

24-
```
25-
npm install --save NHSDigital-eps-cdk-constructs-1.0.0.tgz --workspace packages/cdk/
26-
```
57+
Copy this to the project you want to use it in and use the following to install it:
2758

28-
You will then be able to use it - eg
59+
```bash
60+
npm install --save NHSDigital-eps-cdk-constructs-1.0.0.tgz --workspace packages/cdk/
2961
```
62+
63+
You will then be able to use it - for example:
64+
65+
```typescript
3066
import {TypescriptLambdaFunction} from "@NHSDigital/eps-cdk-constructs"
3167
```
68+
69+
### Make Commands
70+
71+
There are `make` commands that are run as part of the CI pipeline and help alias some
72+
functionality during development.
73+
74+
#### Install targets
75+
76+
- `install-node` Installs node dependencies
77+
- `install-python` Installs python dependencies
78+
- `install-hooks` Installs git pre commit hooks
79+
- `install` Runs all install targets
80+
81+
#### Linting and testing
82+
83+
- `lint` Runs lint for all code
84+
- `test` Runs unit tests for all code
85+
86+
#### Compiling
87+
88+
- `compile` Compiles all code
89+
- `package` Creates distributable tarball of CDK constructs
90+
91+
#### Check licenses
92+
93+
- `check-licenses` Checks licenses for all packages used
94+
95+
#### Clean targets
96+
97+
- `clean` Clears up any files that have been generated by building or testing locally
98+
- `deep-clean` Runs clean target and also removes any node_modules and python libraries installed locally

packages/cdkConstructs/src/constructs/TypescriptLambdaFunction.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ const getDefaultLambdaOptions = (
108108
* - CloudWatch log group with KMS encryption
109109
* - IAM role for execution with necessary permissions
110110
* - Subscription filter on logs so they are forwarded to splunk
111-
* - Lambda Insights layer for monitoring
111+
*
112+
* It also
113+
* - attaches the Lambda Insights layer for monitoring.
114+
* - adds cfnGuard suppressions for common issues.
115+
* - adds cdk-nag suppressions for common issues.
112116
*
113117
* @example
114118
* ```typescript

packages/cdkConstructs/tests/functionConstruct.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe("functionConstruct works correctly with additional layers", () => {
248248
template = Template.fromStack(stack)
249249
})
250250

251-
test("it has the correct policies in the role", () => {
251+
test("it has the correct layers added", () => {
252252
template.hasResourceProperties("AWS::Lambda::Function", {
253253
Handler: "index.handler",
254254
Runtime: "nodejs22.x",
@@ -263,3 +263,39 @@ describe("functionConstruct works correctly with additional layers", () => {
263263
})
264264
})
265265
})
266+
267+
describe("functionConstruct works correctly with custom timeout", () => {
268+
let stack: Stack
269+
let app: App
270+
let template: assertions.Template
271+
272+
beforeAll(() => {
273+
app = new App()
274+
stack = new Stack(app, "lambdaConstructStack")
275+
new TypescriptLambdaFunction(stack, "dummyFunction", {
276+
functionName: "testLambda",
277+
packageBasePath: "packages/cdkConstructs",
278+
entryPoint: "tests/src/dummyLambda.ts",
279+
environmentVariables: {},
280+
logRetentionInDays: 30,
281+
logLevel: "DEBUG",
282+
version: "1.0.0",
283+
layers: [],
284+
commitId: "abcd1234",
285+
baseDir: resolve(__dirname, "../../.."),
286+
timeoutInSeconds: 120
287+
})
288+
template = Template.fromStack(stack)
289+
})
290+
291+
test("it has the correct timeout", () => {
292+
template.hasResourceProperties("AWS::Lambda::Function", {
293+
Handler: "index.handler",
294+
Runtime: "nodejs22.x",
295+
FunctionName: "testLambda",
296+
MemorySize: 256,
297+
Architectures: ["x86_64"],
298+
Timeout: 120
299+
})
300+
})
301+
})

sonar-project.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ sonar.coverage.exclusions=\
99
eslint.config.mjs, \
1010
**/tests/*, \
1111
release.config.js
12+
13+
sonar.cpd.exclusions=\
14+
**/*.test.*
15+
16+
# Define the modules
17+
sonar.modules=\
18+
cdkConstructs
19+
20+
# Modules
21+
cdkConstructs.sonar.projectBaseDir=packages/cdkConstructs
22+
cdkConstructs.sonar.sources=.
23+
cdkConstructs.sonar.javascript.lcov.reportPaths=coverage/lcov.info

0 commit comments

Comments
 (0)