skuba 5.0.1 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/lib/api/buildkite/annotate.d.ts +1 -1
  2. package/lib/api/git/commitAllChanges.d.ts +8 -1
  3. package/lib/api/git/commitAllChanges.js +3 -2
  4. package/lib/api/git/commitAllChanges.js.map +2 -2
  5. package/lib/api/git/getChangedFiles.d.ts +8 -2
  6. package/lib/api/git/getChangedFiles.js +7 -2
  7. package/lib/api/git/getChangedFiles.js.map +2 -2
  8. package/lib/api/git/index.d.ts +1 -0
  9. package/lib/api/git/index.js.map +2 -2
  10. package/lib/api/github/checkRun.d.ts +2 -2
  11. package/lib/api/github/push.d.ts +9 -3
  12. package/lib/api/github/push.js +4 -3
  13. package/lib/api/github/push.js.map +2 -2
  14. package/lib/api/jest/index.d.ts +2 -2
  15. package/lib/cli/adapter/prettier.js +15 -1
  16. package/lib/cli/adapter/prettier.js.map +2 -2
  17. package/lib/cli/configure/processing/prettier.d.ts +1 -1
  18. package/lib/cli/configure/processing/typescript.d.ts +2 -2
  19. package/lib/cli/configure/types.d.ts +6 -6
  20. package/lib/cli/init/getConfig.js +18 -5
  21. package/lib/cli/init/getConfig.js.map +2 -2
  22. package/lib/cli/init/prompts.d.ts +14 -1
  23. package/lib/cli/init/prompts.js +7 -1
  24. package/lib/cli/init/prompts.js.map +2 -2
  25. package/lib/cli/init/types.d.ts +3 -2
  26. package/lib/cli/init/types.js +2 -1
  27. package/lib/cli/init/types.js.map +2 -2
  28. package/lib/cli/init/validation.d.ts +5 -0
  29. package/lib/cli/init/validation.js +10 -2
  30. package/lib/cli/init/validation.js.map +2 -2
  31. package/lib/cli/lint/autofix.d.ts +2 -0
  32. package/lib/cli/lint/autofix.js +17 -3
  33. package/lib/cli/lint/autofix.js.map +2 -2
  34. package/lib/skuba.js.map +1 -1
  35. package/lib/utils/command.d.ts +1 -1
  36. package/lib/utils/copy.d.ts +1 -1
  37. package/lib/utils/error.d.ts +1 -1
  38. package/lib/utils/exec.d.ts +2 -2
  39. package/lib/utils/logging.d.ts +1 -1
  40. package/lib/utils/manifest.d.ts +1 -1
  41. package/lib/utils/template.d.ts +2 -2
  42. package/lib/utils/version.d.ts +1 -1
  43. package/lib/utils/wait.d.ts +1 -1
  44. package/lib/wrapper/main.js.map +1 -1
  45. package/package.json +14 -14
  46. package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
  47. package/template/express-rest-api/.gantry/common.yml +1 -1
  48. package/template/express-rest-api/.gantry/dev.yml +1 -0
  49. package/template/express-rest-api/.gantry/prod.yml +1 -0
  50. package/template/express-rest-api/Dockerfile +1 -1
  51. package/template/express-rest-api/Dockerfile.dev-deps +1 -1
  52. package/template/express-rest-api/README.md +7 -10
  53. package/template/express-rest-api/gantry.apply.yml +2 -2
  54. package/template/express-rest-api/gantry.build.yml +1 -1
  55. package/template/greeter/.buildkite/pipeline.yml +1 -1
  56. package/template/greeter/Dockerfile +1 -1
  57. package/template/greeter/README.md +6 -9
  58. package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
  59. package/template/koa-rest-api/.gantry/common.yml +1 -1
  60. package/template/koa-rest-api/.gantry/dev.yml +1 -0
  61. package/template/koa-rest-api/.gantry/prod.yml +1 -0
  62. package/template/koa-rest-api/Dockerfile +1 -1
  63. package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
  64. package/template/koa-rest-api/README.md +7 -10
  65. package/template/koa-rest-api/gantry.apply.yml +2 -2
  66. package/template/koa-rest-api/gantry.build.yml +1 -1
  67. package/template/koa-rest-api/package.json +2 -2
  68. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +4 -4
  69. package/template/lambda-sqs-worker/.nvmrc +1 -1
  70. package/template/lambda-sqs-worker/Dockerfile +1 -1
  71. package/template/lambda-sqs-worker/README.md +7 -10
  72. package/template/lambda-sqs-worker/package.json +10 -5
  73. package/template/lambda-sqs-worker/serverless.yml +2 -4
  74. package/template/lambda-sqs-worker/src/app.test.ts +5 -6
  75. package/template/lambda-sqs-worker/src/framework/handler.test.ts +2 -2
  76. package/template/lambda-sqs-worker/src/hooks.ts +22 -30
  77. package/template/lambda-sqs-worker/src/services/aws.ts +2 -2
  78. package/template/lambda-sqs-worker/src/services/pipelineEventSender.test.ts +9 -7
  79. package/template/lambda-sqs-worker/src/services/pipelineEventSender.ts +6 -4
  80. package/template/lambda-sqs-worker/src/testing/services.ts +11 -7
  81. package/template/lambda-sqs-worker/tsconfig.json +2 -2
  82. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +4 -4
  83. package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
  84. package/template/lambda-sqs-worker-cdk/Dockerfile +1 -1
  85. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +2 -4
  86. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +4 -4
  87. package/template/lambda-sqs-worker-cdk/package.json +4 -4
  88. package/template/lambda-sqs-worker-cdk/tsconfig.json +2 -2
  89. package/template/oss-npm-package/_package.json +1 -1
  90. package/template/private-npm-package/_package.json +1 -1
@@ -4,24 +4,21 @@
4
4
 
5
5
  Next steps:
6
6
 
7
- 1. [ ] Check if your team has a Graviton-based Buildkite cluster;
8
- see the [ARM64 guide] for more information.
9
- 2. [ ] Finish templating if this was skipped earlier:
7
+ 1. [ ] Finish templating if this was skipped earlier:
10
8
 
11
9
  ```shell
12
10
  yarn skuba configure
13
11
  ```
14
12
 
15
- 3. [ ] Create a new repository in the appropriate GitHub organisation.
16
- 4. [ ] Add the repository to BuildAgency;
13
+ 2. [ ] Create a new repository in the appropriate GitHub organisation.
14
+ 3. [ ] Add the repository to BuildAgency;
17
15
  see [Builds at SEEK] for more information.
18
- 5. [ ] Add Datadog configuration and data classification tags to [.gantry/common.yml](.gantry/common.yml);
16
+ 4. [ ] Add Datadog configuration and data classification tags to [.gantry/common.yml](.gantry/common.yml);
19
17
  see the [Gantry] documentation for more information.
20
- 6. [ ] Push local commits to the upstream GitHub branch.
21
- 7. [ ] Configure [GitHub repository settings].
22
- 8. [ ] Delete this checklist 😌.
18
+ 5. [ ] Push local commits to the upstream GitHub branch.
19
+ 6. [ ] Configure [GitHub repository settings].
20
+ 7. [ ] Delete this checklist 😌.
23
21
 
24
- [arm64 guide]: https://seek-oss.github.io/skuba/docs/deep-dives/arm64.html
25
22
  [builds at seek]: https://builds-at-seek.ssod.skinfra.xyz
26
23
  [github repository settings]: https://github.com/<%-orgName%>/<%-repoName%>/settings
27
24
 
@@ -10,7 +10,7 @@ env:
10
10
  # https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
11
11
  AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1'
12
12
 
13
- ENVIRONMENT: '{{.Environment}}'
13
+ ENVIRONMENT: '{{values "environment"}}'
14
14
  OPENTELEMETRY_ENABLED: '{{.Values.openTelemetry.enabled | default false}}'
15
15
  SERVICE: '{{values "service"}}'
16
16
 
@@ -126,4 +126,4 @@ tags:
126
126
  {{$key}}: '{{$value}}'
127
127
  {{end}}
128
128
 
129
- cpuArchitecture: arm64
129
+ cpuArchitecture: <%- platformName %>
@@ -12,4 +12,4 @@ buildArgs:
12
12
  # SEEK-Jobs/gantry#1661
13
13
  failOnScanFindings: false
14
14
 
15
- cpuArchitecture: arm64
15
+ cpuArchitecture: <%- platformName %>
@@ -16,8 +16,8 @@
16
16
  "@opentelemetry/api": "^1.1.0",
17
17
  "@opentelemetry/exporter-collector-grpc": "^0.25.0",
18
18
  "@opentelemetry/instrumentation-aws-sdk": "^0.32.0",
19
- "@opentelemetry/instrumentation-http": "^0.33.0",
20
- "@opentelemetry/sdk-node": "^0.33.0",
19
+ "@opentelemetry/instrumentation-http": "^0.34.0",
20
+ "@opentelemetry/sdk-node": "^0.34.0",
21
21
  "@seek/logger": "^5.0.1",
22
22
  "aws-sdk": "^2.1039.0",
23
23
  "hot-shots": "^9.0.0",
@@ -26,13 +26,13 @@ configs:
26
26
  - yarn deploy
27
27
  concurrency: 1
28
28
  plugins:
29
- - artifacts#v1.7.0:
29
+ - artifacts#v1.8.0:
30
30
  build: ${BUILDKITE_BUILD_ID}
31
31
  download: lib/*
32
32
  - *aws-sm
33
33
  - *private-npm
34
34
  - *docker-ecr-cache
35
- - docker-compose#v4.5.0:
35
+ - docker-compose#v4.9.0:
36
36
  dependencies: false
37
37
  run: app
38
38
  retry:
@@ -60,13 +60,13 @@ steps:
60
60
  - *aws-sm
61
61
  - *private-npm
62
62
  - *docker-ecr-cache
63
- - docker-compose#v4.5.0:
63
+ - docker-compose#v4.9.0:
64
64
  run: app
65
65
  timeout_in_minutes: 10
66
66
 
67
67
  - agents:
68
68
  queue: <%- devBuildkiteQueueName %>
69
- branches: '!renovate--*'
69
+ branches: '!renovate-*'
70
70
  label: 🧖‍♀️ Warm Dev
71
71
  command: ':'
72
72
  plugins:
@@ -1 +1 @@
1
- 16
1
+ 18
@@ -1,6 +1,6 @@
1
1
  # syntax=docker/dockerfile:1.2
2
2
 
3
- FROM --platform=${BUILDPLATFORM:-arm64} node:16-alpine AS dev-deps
3
+ FROM --platform=${BUILDPLATFORM:-<%- platformName %>} node:18-alpine AS dev-deps
4
4
 
5
5
  WORKDIR /workdir
6
6
 
@@ -4,23 +4,20 @@
4
4
 
5
5
  Next steps:
6
6
 
7
- 1. [ ] Check if your team has a Graviton-based Buildkite cluster;
8
- see the [ARM64 guide] for more information.
9
- 2. [ ] Finish templating if this was skipped earlier:
7
+ 1. [ ] Finish templating if this was skipped earlier:
10
8
 
11
9
  ```shell
12
10
  yarn skuba configure
13
11
  ```
14
12
 
15
- 3. [ ] Create a new repository in the appropriate GitHub organisation.
16
- 4. [ ] Add the repository to BuildAgency;
13
+ 2. [ ] Create a new repository in the appropriate GitHub organisation.
14
+ 3. [ ] Add the repository to BuildAgency;
17
15
  see [Builds at SEEK] for more information.
18
- 5. [ ] Add Datadog extension, deployment bucket configuration and data classification tags to [serverless.yml](serverless.yml).
19
- 6. [ ] Push local commits to the upstream GitHub branch.
20
- 7. [ ] Configure [GitHub repository settings].
21
- 8. [ ] Delete this checklist 😌.
16
+ 4. [ ] Add Datadog extension, deployment bucket configuration and data classification tags to [serverless.yml](serverless.yml).
17
+ 5. [ ] Push local commits to the upstream GitHub branch.
18
+ 6. [ ] Configure [GitHub repository settings].
19
+ 7. [ ] Delete this checklist 😌.
22
20
 
23
- [arm64 guide]: https://seek-oss.github.io/skuba/docs/deep-dives/arm64.html
24
21
  [builds at seek]: https://builds-at-seek.ssod.skinfra.xyz
25
22
  [github repository settings]: https://github.com/<%-orgName%>/<%-repoName%>/settings
26
23
 
@@ -14,25 +14,30 @@
14
14
  "test:watch": "skuba test --watch"
15
15
  },
16
16
  "dependencies": {
17
+ "@aws-sdk/client-codedeploy": "^3.213.0",
18
+ "@aws-sdk/client-lambda": "^3.213.0",
19
+ "@aws-sdk/client-sns": "^3.213.0",
17
20
  "@seek/logger": "^5.0.1",
18
- "aws-sdk": "^2.1011.0",
19
21
  "datadog-lambda-js": "^6.83.0",
22
+ "dd-trace": "^3.8.0",
20
23
  "skuba-dive": "^2.0.0",
21
24
  "zod": "^3.19.1"
22
25
  },
23
26
  "devDependencies": {
24
27
  "@types/aws-lambda": "^8.10.84",
25
28
  "@types/chance": "^1.1.3",
26
- "@types/node": "16.11.64",
29
+ "@types/node": "^18.11.9",
30
+ "aws-sdk-client-mock": "^2.0.1",
31
+ "aws-sdk-client-mock-jest": "^2.0.1",
27
32
  "chance": "^1.1.8",
28
33
  "pino-pretty": "^9.0.0",
29
- "serverless": "^3.17.0",
34
+ "serverless": "^3.25.0",
30
35
  "serverless-plugin-canary-deployments": "^0.8.0",
31
- "serverless-plugin-datadog": "^5.7.0",
36
+ "serverless-plugin-datadog": "^5.12.0",
32
37
  "serverless-prune-plugin": "^2.0.0",
33
38
  "skuba": "*"
34
39
  },
35
40
  "engines": {
36
- "node": ">=16"
41
+ "node": ">=18"
37
42
  }
38
43
  }
@@ -37,8 +37,8 @@ provider:
37
37
  logRetentionInDays: 30
38
38
  name: aws
39
39
  region: ap-southeast-2
40
- runtime: nodejs16.x
41
- architecture: arm64
40
+ runtime: nodejs18.x
41
+ architecture: <%- lambdaServerlessArchitecture %>
42
42
  deploymentMethod: direct
43
43
  stackName: ${self:service}
44
44
  stage: ${env:ENVIRONMENT}
@@ -47,8 +47,6 @@ provider:
47
47
  # This is easier to manage in terms of access, deployment, and tagging.
48
48
  name: ${param:deploymentBucket}
49
49
  environment:
50
- # https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
51
- AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
52
50
  NODE_ENV: production
53
51
  # https://nodejs.org/api/cli.html#cli_node_options_options
54
52
  NODE_OPTIONS: --enable-source-maps
@@ -1,3 +1,5 @@
1
+ import { PublishCommand } from '@aws-sdk/client-sns';
2
+
1
3
  import { metricsClient } from 'src/framework/metrics';
2
4
  import { createCtx, createSqsEvent } from 'src/testing/handler';
3
5
  import { logger } from 'src/testing/logging';
@@ -23,13 +25,10 @@ describe('handler', () => {
23
25
 
24
26
  beforeAll(logger.spy);
25
27
  beforeAll(scoringService.spy);
26
- beforeAll(sns.spy);
27
28
 
28
29
  beforeEach(() => {
29
30
  scoringService.request.mockResolvedValue(score);
30
- sns.publish.mockPromise(
31
- Promise.resolve({ MessageId: chance.guid({ version: 4 }) }),
32
- );
31
+ sns.publish.resolves({ MessageId: chance.guid({ version: 4 }) });
33
32
  });
34
33
 
35
34
  afterEach(() => {
@@ -59,7 +58,7 @@ describe('handler', () => {
59
58
  ['job.scored', 1],
60
59
  ]);
61
60
 
62
- expect(sns.publish).toHaveBeenCalledTimes(1);
61
+ expect(sns.client).toReceiveCommandTimes(PublishCommand, 1);
63
62
  });
64
63
 
65
64
  it('throws on invalid input', () => {
@@ -83,7 +82,7 @@ describe('handler', () => {
83
82
  it('bubbles up SNS error', async () => {
84
83
  const err = Error(chance.sentence());
85
84
 
86
- sns.publish.mockPromise(Promise.reject(err));
85
+ sns.publish.rejects(err);
87
86
 
88
87
  const event = createSqsEvent([JSON.stringify(jobPublished)]);
89
88
 
@@ -40,7 +40,7 @@ describe('createHandler', () => {
40
40
 
41
41
  await expect(handler(input, ctx)).rejects.toThrow('Function failed');
42
42
 
43
- expect(logger.error.mock.calls).toEqual([[{ err }, 'Function failed']]);
43
+ expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
44
44
 
45
45
  expect(logger.info).not.toHaveBeenCalled();
46
46
  });
@@ -54,7 +54,7 @@ describe('createHandler', () => {
54
54
 
55
55
  await expect(handler(input, ctx)).rejects.toThrow('Function failed');
56
56
 
57
- expect(logger.error.mock.calls).toEqual([[{ err }, 'Function failed']]);
57
+ expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
58
58
 
59
59
  expect(logger.info).not.toHaveBeenCalled();
60
60
  });
@@ -2,28 +2,21 @@
2
2
  /* istanbul ignore file */
3
3
 
4
4
  // Use minimal dependencies to reduce the chance of crashes on module load.
5
- import { CodeDeploy, Lambda } from 'aws-sdk';
5
+ import {
6
+ CodeDeployClient,
7
+ PutLifecycleEventHookExecutionStatusCommand,
8
+ } from '@aws-sdk/client-codedeploy';
9
+ import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda';
10
+ import { toUtf8 } from '@aws-sdk/util-utf8-node';
6
11
 
7
- /**
8
- * Common AWS options to avoid hanging the deployment on a transient error.
9
- *
10
- * AWS uses exponential backoff, so we wait for ~15 seconds total per request.
11
- */
12
- const awsRetryOptions = {
13
- maxRetries: 5,
14
- retryDelayOptions: {
15
- base: 500,
16
- },
17
- };
18
-
19
- const codeDeploy = new CodeDeploy({
20
- ...awsRetryOptions,
12
+ const codeDeploy = new CodeDeployClient({
21
13
  apiVersion: '2014-10-06',
14
+ maxAttempts: 5,
22
15
  });
23
16
 
24
- const lambda = new Lambda({
25
- ...awsRetryOptions,
17
+ const lambda = new LambdaClient({
26
18
  apiVersion: '2015-03-31',
19
+ maxAttempts: 5,
27
20
  });
28
21
 
29
22
  type Status = 'Succeeded' | 'Failed';
@@ -43,24 +36,23 @@ const smokeTestLambdaFunction = async (): Promise<Status> => {
43
36
 
44
37
  console.info('Function:', functionName);
45
38
 
46
- const response = await lambda
47
- .invoke({
39
+ const response = await lambda.send(
40
+ new InvokeCommand({
48
41
  FunctionName: functionName,
49
42
  InvocationType: 'RequestResponse',
50
43
  // Treat an empty object as our smoke test event.
51
- Payload: '{}',
52
- // An unqualified reference implicitly invokes $LATEST, which has been
53
- // updated to point to the new version when this pre hook runs.
54
- Qualifier: undefined,
55
- })
56
- .promise();
44
+ Payload: Buffer.from('{}'),
45
+ }),
46
+ );
57
47
 
58
48
  console.info('Version:', response.ExecutedVersion ?? '?');
59
49
  console.info('Status', response.StatusCode ?? '?');
60
50
 
61
51
  if (response.FunctionError) {
62
52
  console.error('Error:', response.FunctionError);
63
- console.error(response.Payload);
53
+ if (response.Payload) {
54
+ console.error(toUtf8(response.Payload));
55
+ }
64
56
  return 'Failed';
65
57
  }
66
58
 
@@ -94,11 +86,11 @@ export const pre = async (
94
86
  status = 'Failed';
95
87
  }
96
88
 
97
- await codeDeploy
98
- .putLifecycleEventHookExecutionStatus({
89
+ await codeDeploy.send(
90
+ new PutLifecycleEventHookExecutionStatusCommand({
99
91
  deploymentId: event.DeploymentId,
100
92
  lifecycleEventHookExecutionId: event.LifecycleEventHookExecutionId,
101
93
  status,
102
- })
103
- .promise();
94
+ }),
95
+ );
104
96
  };
@@ -1,5 +1,5 @@
1
- import { SNS } from 'aws-sdk';
1
+ import { SNSClient } from '@aws-sdk/client-sns';
2
2
 
3
- export const sns = new SNS({
3
+ export const sns = new SNSClient({
4
4
  apiVersion: '2010-03-31',
5
5
  });
@@ -1,33 +1,35 @@
1
+ import { PublishCommand } from '@aws-sdk/client-sns';
2
+
1
3
  import { sns } from 'src/testing/services';
2
4
  import { chance } from 'src/testing/types';
3
5
 
4
6
  import { sendPipelineEvent } from './pipelineEventSender';
5
7
 
6
8
  describe('sendPipelineEvent', () => {
7
- beforeAll(sns.spy);
8
-
9
- afterEach(sns.clear);
9
+ afterEach(() => {
10
+ jest.clearAllMocks();
11
+ });
10
12
 
11
13
  it('handles happy path', async () => {
12
14
  const messageId = chance.guid({ version: 4 });
13
15
 
14
- sns.publish.mockPromise(Promise.resolve({ MessageId: messageId }));
16
+ sns.publish.resolves({ MessageId: messageId });
15
17
 
16
18
  await expect(sendPipelineEvent({})).resolves.toBe(messageId);
17
19
 
18
- expect(sns.publish).toHaveBeenCalledTimes(1);
20
+ expect(sns.client).toReceiveCommandTimes(PublishCommand, 1);
19
21
  });
20
22
 
21
23
  it('bubbles up SNS error', () => {
22
24
  const err = Error(chance.sentence());
23
25
 
24
- sns.publish.mockPromise(Promise.reject(err));
26
+ sns.publish.rejects(err);
25
27
 
26
28
  return expect(sendPipelineEvent({})).rejects.toThrow(err);
27
29
  });
28
30
 
29
31
  it('throws on missing message ID', () => {
30
- sns.publish.mockPromise(Promise.resolve({}));
32
+ sns.publish.resolves({});
31
33
 
32
34
  return expect(
33
35
  sendPipelineEvent({}),
@@ -1,3 +1,5 @@
1
+ import { PublishCommand } from '@aws-sdk/client-sns';
2
+
1
3
  import { config } from 'src/config';
2
4
 
3
5
  import { sns } from './aws';
@@ -6,8 +8,8 @@ export const sendPipelineEvent = async (
6
8
  event: unknown,
7
9
  smokeTest: boolean = false,
8
10
  ): Promise<string> => {
9
- const snsResponse = await sns
10
- .publish({
11
+ const snsResponse = await sns.send(
12
+ new PublishCommand({
11
13
  Message: JSON.stringify(event),
12
14
  ...(smokeTest && {
13
15
  MessageAttributes: {
@@ -20,8 +22,8 @@ export const sendPipelineEvent = async (
20
22
  },
21
23
  }),
22
24
  TopicArn: config.destinationSnsTopicArn,
23
- })
24
- .promise();
25
+ }),
26
+ );
25
27
 
26
28
  if (snsResponse.MessageId === undefined) {
27
29
  throw Error('SNS did not return a message ID');
@@ -1,4 +1,9 @@
1
- import * as aws from 'src/services/aws';
1
+ import 'aws-sdk-client-mock-jest';
2
+
3
+ import { PublishCommand } from '@aws-sdk/client-sns';
4
+ import { mockClient } from 'aws-sdk-client-mock';
5
+
6
+ import { sns as snsClient } from 'src/services/aws';
2
7
  import * as jobScorer from 'src/services/jobScorer';
3
8
 
4
9
  export const scoringService = {
@@ -12,13 +17,12 @@ export const scoringService = {
12
17
  .mockImplementation(scoringService.request),
13
18
  };
14
19
 
20
+ const snsMock = mockClient(snsClient);
21
+
15
22
  export const sns = {
16
- publish: Object.assign(jest.fn(), {
17
- mockPromise: (promise: Promise<unknown>) =>
18
- sns.publish.mockReturnValue({ promise: () => promise } as any),
19
- }),
23
+ publish: snsMock.on(PublishCommand),
20
24
 
21
- clear: () => sns.publish.mockClear(),
25
+ clear: () => snsMock.resetHistory(),
22
26
 
23
- spy: () => jest.spyOn(aws.sns, 'publish').mockImplementation(sns.publish),
27
+ client: snsMock,
24
28
  };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "baseUrl": ".",
4
- "lib": ["ES2020"],
4
+ "lib": ["ES2022"],
5
5
  "outDir": "lib",
6
6
  "paths": {
7
7
  "src": ["src"]
8
8
  },
9
- "target": "ES2020"
9
+ "target": "ES2022"
10
10
  },
11
11
  "exclude": ["lib*/**/*"],
12
12
  "extends": "skuba/config/tsconfig.json"
@@ -26,13 +26,13 @@ configs:
26
26
  - yarn deploy
27
27
  concurrency: 1
28
28
  plugins:
29
- - artifacts#v1.7.0:
29
+ - artifacts#v1.8.0:
30
30
  build: ${BUILDKITE_BUILD_ID}
31
31
  download: lib/*
32
32
  - *aws-sm
33
33
  - *private-npm
34
34
  - *docker-ecr-cache
35
- - docker-compose#v4.5.0:
35
+ - docker-compose#v4.9.0:
36
36
  dependencies: false
37
37
  run: app
38
38
  retry:
@@ -57,13 +57,13 @@ steps:
57
57
  - *aws-sm
58
58
  - *private-npm
59
59
  - *docker-ecr-cache
60
- - docker-compose#v4.5.0:
60
+ - docker-compose#v4.9.0:
61
61
  run: app
62
62
  timeout_in_minutes: 10
63
63
 
64
64
  - agents:
65
65
  queue: <%- devBuildkiteQueueName %>
66
- branches: '!renovate--*'
66
+ branches: '!renovate-*'
67
67
  label: 🧖‍♀️ Warm Dev
68
68
  command: ':'
69
69
  plugins:
@@ -1 +1 @@
1
- 16
1
+ 18
@@ -1,6 +1,6 @@
1
1
  # syntax=docker/dockerfile:1.2
2
2
 
3
- FROM --platform=${BUILDPLATFORM:-arm64} node:16-alpine AS dev-deps
3
+ FROM --platform=${BUILDPLATFORM:-<%- platformName %>} node:18-alpine AS dev-deps
4
4
 
5
5
  WORKDIR /workdir
6
6
 
@@ -157,7 +157,6 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
157
157
  },
158
158
  "Environment": {
159
159
  "Variables": {
160
- "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1",
161
160
  "NODE_ENV": "production",
162
161
  "NODE_OPTIONS": "--enable-source-maps",
163
162
  "SOMETHING": "dev",
@@ -177,7 +176,7 @@ exports[`returns expected CloudFormation stack for dev 1`] = `
177
176
  "Arn",
178
177
  ],
179
178
  },
180
- "Runtime": "nodejs16.x",
179
+ "Runtime": "nodejs18.x",
181
180
  },
182
181
  "Type": "AWS::Lambda::Function",
183
182
  },
@@ -519,7 +518,6 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
519
518
  },
520
519
  "Environment": {
521
520
  "Variables": {
522
- "AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1",
523
521
  "NODE_ENV": "production",
524
522
  "NODE_OPTIONS": "--enable-source-maps",
525
523
  "SOMETHING": "prod",
@@ -539,7 +537,7 @@ exports[`returns expected CloudFormation stack for prod 1`] = `
539
537
  "Arn",
540
538
  ],
541
539
  },
542
- "Runtime": "nodejs16.x",
540
+ "Runtime": "nodejs18.x",
543
541
  },
544
542
  "Type": "AWS::Lambda::Function",
545
543
  },
@@ -50,16 +50,16 @@ export class AppStack extends Stack {
50
50
  encryptionMasterKey: kmsKey,
51
51
  });
52
52
 
53
+ const architecture = '<%- lambdaCdkArchitecture %>';
54
+
53
55
  const worker = new aws_lambda.Function(this, 'worker', {
54
- architecture: aws_lambda.Architecture.ARM_64,
56
+ architecture: aws_lambda.Architecture[architecture],
55
57
  code: new aws_lambda.AssetCode('./lib'),
56
- runtime: aws_lambda.Runtime.NODEJS_16_X,
58
+ runtime: aws_lambda.Runtime.NODEJS_18_X,
57
59
  handler: 'app.handler',
58
60
  functionName: '<%- serviceName %>',
59
61
  environmentEncryption: kmsKey,
60
62
  environment: {
61
- // https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
62
- AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
63
63
  NODE_ENV: 'production',
64
64
  // https://nodejs.org/api/cli.html#cli_node_options_options
65
65
  NODE_OPTIONS: '--enable-source-maps',
@@ -18,13 +18,13 @@
18
18
  "devDependencies": {
19
19
  "@aws-cdk/assert": "^2.24.0",
20
20
  "@types/aws-lambda": "^8.10.82",
21
- "@types/node": "16.11.64",
22
- "aws-cdk": "^2.24.0",
23
- "aws-cdk-lib": "^2.24.0",
21
+ "@types/node": "^18.11.9",
22
+ "aws-cdk": "^2.51.1",
23
+ "aws-cdk-lib": "^2.51.1",
24
24
  "constructs": "^10.0.17",
25
25
  "skuba": "*"
26
26
  },
27
27
  "engines": {
28
- "node": ">=16"
28
+ "node": ">=18"
29
29
  }
30
30
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "baseUrl": ".",
4
- "lib": ["ES2020"],
4
+ "lib": ["ES2022"],
5
5
  "outDir": "lib",
6
6
  "paths": {
7
7
  "src": ["src"]
8
8
  },
9
- "target": "ES2020"
9
+ "target": "ES2022"
10
10
  },
11
11
  "exclude": ["lib*/**/*"],
12
12
  "extends": "skuba/config/tsconfig.json"
@@ -2,7 +2,7 @@
2
2
  "dependencies": {},
3
3
  "description": "<%- description %>",
4
4
  "devDependencies": {
5
- "@types/node": "16.11.64",
5
+ "@types/node": "^16.18.3",
6
6
  "commitizen": "^4.2.4",
7
7
  "skuba": "*"
8
8
  },
@@ -2,7 +2,7 @@
2
2
  "dependencies": {},
3
3
  "description": "<%- description %>",
4
4
  "devDependencies": {
5
- "@types/node": "16.11.64",
5
+ "@types/node": "^16.18.3",
6
6
  "commitizen": "^4.2.4",
7
7
  "skuba": "*"
8
8
  },