Skip to content

Commit 61ad5ac

Browse files
authored
feat(layers): add arm64 to integration test matrix (#1720)
* feat(layers): add arm64 to test matrix
1 parent 9cc7190 commit 61ad5ac

File tree

10 files changed

+76
-19
lines changed

10 files changed

+76
-19
lines changed

Diff for: .github/workflows/run-e2e-tests.yml

+15-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
workflow_dispatch:
55
inputs:
66
prNumber:
7-
description: "(Optional) PR Number. If you specify a value the value of the branch field will be ignored."
7+
description: '(Optional) PR Number. If you specify a value the value of the branch field will be ignored.'
88
required: false
9-
default: ""
9+
default: ''
1010

1111
jobs:
1212
run-e2e-tests-on-utils:
@@ -19,12 +19,21 @@ jobs:
1919
contents: read
2020
strategy:
2121
matrix:
22-
package: [layers, packages/logger, packages/metrics, packages/tracer, packages/parameters, packages/idempotency]
22+
package:
23+
[
24+
layers,
25+
packages/logger,
26+
packages/metrics,
27+
packages/tracer,
28+
packages/parameters,
29+
packages/idempotency,
30+
]
2331
version: [14, 16, 18]
32+
arch: [x86_64, arm64]
2433
fail-fast: false
2534
steps:
2635
- name: Checkout Repo
27-
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
36+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2837
# If we pass a PR Number when triggering the workflow we will retrieve the PR info and get its headSHA
2938
- name: Extract PR details
3039
id: extract_PR_details
@@ -38,7 +47,7 @@ jobs:
3847
# we checkout the PR at that point in time
3948
- name: Checkout PR code
4049
if: ${{ inputs.prNumber != '' }}
41-
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
50+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
4251
with:
4352
ref: ${{ steps.extract_PR_details.outputs.headSHA }}
4453
- name: Setup NodeJS
@@ -59,5 +68,6 @@ jobs:
5968
env:
6069
RUNTIME: nodejs${{ matrix.version }}x
6170
CI: true
71+
ARCH: ${{ matrix.arch }}
6272
JSII_SILENCE_WARNING_DEPRECATED_NODE_VERSION: true
6373
run: npm run test:e2e -w ${{ matrix.package }}

Diff for: packages/idempotency/tests/e2e/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const RESOURCE_NAME_PREFIX = 'Idempotency-E2E';
1+
export const RESOURCE_NAME_PREFIX = 'Idempotency';
22

33
export const ONE_MINUTE = 60 * 1_000;
44
export const TEARDOWN_TIMEOUT = 5 * ONE_MINUTE;

Diff for: packages/logger/tests/e2e/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { randomUUID } from 'node:crypto';
22

3-
const RESOURCE_NAME_PREFIX = 'Logger-E2E';
3+
const RESOURCE_NAME_PREFIX = 'Logger';
44
const ONE_MINUTE = 60 * 1000;
55
const TEST_CASE_TIMEOUT = ONE_MINUTE;
66
const SETUP_TIMEOUT = 5 * ONE_MINUTE;

Diff for: packages/metrics/tests/e2e/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { randomUUID } from 'node:crypto';
22
import { MetricUnits } from '../../src';
33

4-
const RESOURCE_NAME_PREFIX = 'Metrics-E2E';
4+
const RESOURCE_NAME_PREFIX = 'Metrics';
55
const ONE_MINUTE = 60 * 1000;
66
const TEST_CASE_TIMEOUT = 3 * ONE_MINUTE;
77
const SETUP_TIMEOUT = 5 * ONE_MINUTE;

Diff for: packages/parameters/tests/e2e/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const RESOURCE_NAME_PREFIX = 'Parameters-E2E';
1+
export const RESOURCE_NAME_PREFIX = 'Parameters';
22
export const ONE_MINUTE = 60 * 1000;
33
export const TEST_CASE_TIMEOUT = 3 * ONE_MINUTE;
44
export const SETUP_TIMEOUT = 5 * ONE_MINUTE;

Diff for: packages/parameters/tests/helpers/resources.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import {
77
concatenateResourceName,
88
getRuntimeKey,
9+
getArchitectureKey,
910
TestDynamodbTable,
1011
TestNodejsFunction,
1112
} from '@aws-lambda-powertools/testing-utils';
@@ -58,7 +59,7 @@ class TestSecureStringParameter extends Construct {
5859

5960
const { value } = props;
6061

61-
const name = `/secure/${getRuntimeKey()}/${randomUUID()}`;
62+
const name = `/secure/${getRuntimeKey()}/${getArchitectureKey()}/${randomUUID()}`;
6263
const secureStringCreator = new AwsCustomResource(
6364
testStack.stack,
6465
`create-${randomUUID()}`,

Diff for: packages/testing/src/constants.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Runtime } from 'aws-cdk-lib/aws-lambda';
1+
import { Runtime, Architecture } from 'aws-cdk-lib/aws-lambda';
22

33
/**
44
* The default AWS Lambda runtime to use when none is provided.
@@ -14,4 +14,22 @@ const TEST_RUNTIMES = {
1414
[defaultRuntime]: Runtime.NODEJS_18_X,
1515
} as const;
1616

17-
export { TEST_RUNTIMES, defaultRuntime };
17+
/**
18+
* The default AWS Lambda architecture to use when none is provided.
19+
*/
20+
const defaultArchitecture = 'x86_64';
21+
22+
/**
23+
* The AWS Lambda architectures that are supported by the project.
24+
*/
25+
const TEST_ARCHITECTURES = {
26+
[defaultArchitecture]: Architecture.X86_64,
27+
arm64: Architecture.ARM_64,
28+
} as const;
29+
30+
export {
31+
TEST_RUNTIMES,
32+
defaultRuntime,
33+
TEST_ARCHITECTURES,
34+
defaultArchitecture,
35+
};

Diff for: packages/testing/src/helpers.ts

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { randomUUID } from 'node:crypto';
2-
import { TEST_RUNTIMES, defaultRuntime } from './constants';
2+
import {
3+
TEST_RUNTIMES,
4+
defaultRuntime,
5+
TEST_ARCHITECTURES,
6+
defaultArchitecture,
7+
} from './constants';
38

49
const isValidRuntimeKey = (
510
runtime: string
@@ -15,6 +20,21 @@ const getRuntimeKey = (): keyof typeof TEST_RUNTIMES => {
1520
return runtime;
1621
};
1722

23+
const isValidArchitectureKey = (
24+
architecture: string
25+
): architecture is keyof typeof TEST_ARCHITECTURES =>
26+
architecture in TEST_ARCHITECTURES;
27+
28+
const getArchitectureKey = (): keyof typeof TEST_ARCHITECTURES => {
29+
const architecture: string = process.env.ARCH || defaultArchitecture;
30+
31+
if (!isValidArchitectureKey(architecture)) {
32+
throw new Error(`Invalid architecture key value: ${architecture}`);
33+
}
34+
35+
return architecture;
36+
};
37+
1838
/**
1939
* Generate a unique name for a test.
2040
*
@@ -23,10 +43,11 @@ const getRuntimeKey = (): keyof typeof TEST_RUNTIMES => {
2343
* @example
2444
* ```ts
2545
* process.env.RUNTIME = 'nodejs18x';
26-
* const testPrefix = 'E2E-TRACER';
46+
* process.env.ARCH = 'x86_64';
47+
* const testPrefix = 'TRACER';
2748
* const testName = 'someFeature';
2849
* const uniqueName = generateTestUniqueName({ testPrefix, testName });
29-
* // uniqueName = 'E2E-TRACER-node18-12345-someFeature'
50+
* // uniqueName = 'TRACER-18-x86-12345-someFeature'
3051
* ```
3152
*/
3253
const generateTestUniqueName = ({
@@ -38,7 +59,8 @@ const generateTestUniqueName = ({
3859
}): string =>
3960
[
4061
testPrefix,
41-
getRuntimeKey().replace(/[jsx]/g, ''),
62+
getRuntimeKey().replace(/[nodejsx]/g, ''),
63+
getArchitectureKey().replace(/_64/g, ''),
4264
randomUUID().toString().substring(0, 5),
4365
testName,
4466
]
@@ -81,4 +103,5 @@ export {
81103
generateTestUniqueName,
82104
concatenateResourceName,
83105
findAndGetStackOutputValue,
106+
getArchitectureKey,
84107
};

Diff for: packages/testing/src/resources/TestNodejsFunction.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ import { Tracing } from 'aws-cdk-lib/aws-lambda';
33
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
44
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
55
import { randomUUID } from 'node:crypto';
6-
import { TEST_RUNTIMES } from '../constants';
7-
import { concatenateResourceName, getRuntimeKey } from '../helpers';
6+
import { TEST_RUNTIMES, TEST_ARCHITECTURES } from '../constants';
7+
import {
8+
concatenateResourceName,
9+
getRuntimeKey,
10+
getArchitectureKey,
11+
} from '../helpers';
812
import type { TestStack } from '../TestStack';
913
import type { ExtraTestProps, TestNodejsFunctionProps } from './types';
1014

@@ -29,6 +33,7 @@ class TestNodejsFunction extends NodejsFunction {
2933
resourceName: extraProps.nameSuffix,
3034
}),
3135
runtime: TEST_RUNTIMES[getRuntimeKey()],
36+
architecture: TEST_ARCHITECTURES[getArchitectureKey()],
3237
logRetention: RetentionDays.ONE_DAY,
3338
});
3439

Diff for: packages/tracer/tests/e2e/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Prefix for all resources created by the E2E tests
2-
const RESOURCE_NAME_PREFIX = 'Tracer-E2E';
2+
const RESOURCE_NAME_PREFIX = 'Tracer';
33
// Constants relating time to be used in the tests
44
const ONE_MINUTE = 60 * 1_000;
55
const TEST_CASE_TIMEOUT = 5 * ONE_MINUTE;

0 commit comments

Comments
 (0)