Skip to content

Commit ad6752e

Browse files
authored
Merge branch 'main' into aea-6055-reg-test-lambda-invoke
2 parents ece6cb6 + e9ac836 commit ad6752e

18 files changed

Lines changed: 603 additions & 572 deletions

File tree

.github/instructions/languages/cdk.instructions.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@ This file provides instructions for generating, reviewing, and maintaining AWS C
2323
- Suppress warnings with `nagSuppressions.ts` only when justified and documented
2424
- Use `bin/` for entrypoint apps, `constructs/` for reusable components, and `stacks/` for stack definitions
2525
- Prefer `props` interfaces for construct configuration
26+
- For Step Functions definitions, prefer a chain-centric style where states are defined inline within `Chain.start(...).next(...)` so the execution flow reads top-to-bottom in one place. Avoid mixing a chain with many separately declared state `const`s; instead embed calls to helper functions directly in the chain when needed.
27+
- For Step Functions chain formatting, place `.start`, `.next`, `.when`, and `.otherwise` on their own lines, and give helper calls such as `.jsonata(...)` the same line-break weight so nested flow blocks are visually aligned and easy to scan.
28+
- For construct props that group resources (for example lambda functions or state machines), prefer explicit named object shapes (e.g. `{status: TypescriptLambdaFunction}`) over generic index signatures or broad maps so consumers are strongly typed to only the supported resources.
29+
- For construct props that consume grouped resources, prefer inline explicit object shapes in the props contract (for example `functions: { status: TypescriptLambdaFunction }`) over `Pick<...>` or generic map types.
30+
31+
### Good Example - Inline Explicit Shape
32+
33+
```typescript
34+
interface ApisProps {
35+
readonly functions: {
36+
readonly status: TypescriptLambdaFunction
37+
}
38+
readonly stateMachines: {
39+
readonly getMyPrescriptions: ExpressStateMachine
40+
}
41+
}
42+
```
43+
44+
### Bad Example - Hidden Contract via Pick
45+
46+
```typescript
47+
interface ApisProps {
48+
readonly functions: Pick<FunctionResources, "status" | "capabilityStatement">
49+
}
50+
```
51+
52+
### Bad Example - Generic Map
53+
54+
```typescript
55+
interface ApisProps {
56+
functions: {[key: string]: TypescriptLambdaFunction}
57+
stateMachines: {[key: string]: ExpressStateMachine}
58+
}
59+
```
2660

2761
## Code Standards
2862

@@ -33,6 +67,7 @@ This file provides instructions for generating, reviewing, and maintaining AWS C
3367
- Variables: camelCase
3468
- Stacks: Suffix with `Stack` (e.g., `CptsApiAppStack`)
3569
- Entry points: Suffix with `App` (e.g., `CptsApiApp.ts`)
70+
- CDK app entry points must follow `<app acronym><Api|Ui>[Sandbox]App` naming (e.g., `PsuApiApp`, `PsuApiSandboxApp`)
3671

3772
### File Organization
3873

@@ -88,11 +123,26 @@ export class CptsApiAppStack extends Stack {
88123
- Prefer VPC endpoints for private connectivity
89124
- Minimize resource creation in test environments
90125

126+
## Unit Testing
127+
128+
- Write unit tests for CDK stacks and constructs using synthesis-based assertions.
129+
- Prefer in-process tests that instantiate CDK `App` and `Stack` objects directly and assert on synthesized templates.
130+
- Keep assertions light-touch and stable, such as resource counts and a small number of important properties.
131+
- Avoid mocking AWS resources or writing tests that attempt to exercise live AWS behaviour.
132+
- CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo.
133+
- Do not test AWS implementation details owned by the CDK library. Test the resources and properties your code is responsible for declaring.
134+
135+
### Recommended Test Styles
136+
137+
- Smoke tests for `bin/` files: execute the entrypoint and assert that synthesis completes without throwing.
138+
- In-process synth tests for stacks and constructs: instantiate the stack directly and assert resource counts or key CloudFormation properties with `Template.fromStack(...)`.
139+
91140

92141
## Validation and Verification
93142

94143
- Build: `make cdk-synth`
95144
- Lint: `npm run lint --workspace packages/cdk`
145+
- Test: `npm test --workspace packages/cdk`
96146

97147
## Maintenance
98148

.github/instructions/languages/typescript.instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This document provides instructions for generating, reviewing, and maintaining T
2323
- Use destructuring for objects and arrays to improve readability.
2424
- Avoid magic numbers and hardcoded values; use named constants.
2525
- Keep functions pure and side-effect free when possible.
26+
- Do not use the `void` operator to silence unused-value warnings; prefer code that makes usage explicit.
2627

2728
## Code Standards
2829

@@ -92,6 +93,7 @@ This document provides instructions for generating, reviewing, and maintaining T
9293
### Type Safety
9394

9495
- Prefer interfaces and types. You MUST NOT use `any`.
96+
- Prefer `Array<T>` over `T[]` for array type annotations.
9597
- Use type guards and assertions when necessary.
9698
- Example:
9799

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ permissions: {}
77

88
jobs:
99
get_config_values:
10-
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@bda627e2ce1a32ea56bcc815aec57b06cfa63c9d
10+
uses: NHSDigital/eps-common-workflows/.github/workflows/get-repo-config.yml@b83cff6a2951a8a2951b8c00a7734edd0cc832d3
1111
permissions:
1212
attestations: read
1313
contents: read
1414
packages: read
1515
with:
1616
verify_published_from_main_image: true
1717
quality_checks:
18-
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@bda627e2ce1a32ea56bcc815aec57b06cfa63c9d
18+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks-devcontainer.yml@b83cff6a2951a8a2951b8c00a7734edd0cc832d3
1919
needs: [get_config_values]
2020
permissions:
2121
contents: read
@@ -38,7 +38,7 @@ jobs:
3838
3939
tag_release:
4040
needs: [quality_checks, get_commit_id, get_config_values]
41-
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release-devcontainer.yml@bda627e2ce1a32ea56bcc815aec57b06cfa63c9d
41+
uses: NHSDigital/eps-common-workflows/.github/workflows/tag-release-devcontainer.yml@b83cff6a2951a8a2951b8c00a7734edd0cc832d3
4242
permissions:
4343
id-token: write
4444
contents: write

0 commit comments

Comments
 (0)