Skip to content

Commit fafcc76

Browse files
authored
ci: run unit and integration tests against more node versions (#221)
*Issue #, if available:* #220 *Description of changes:* Refactoring our GH workflows to run against nodejs 20.x, 22.x, 24.x. The new workflow is like this: 1. Build workflow is run once, uploading the build artifacts 2. Unit tests for each node version are concurrently triggered by the build workflow (downloading from artifacts) 3. Integration tests for each node version are concurrently triggered by the build workflow (downloading from artifacts) 4. Cleanup workflow is run for each node version (not concurrently, since there is throttling for DeleteFunction) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent b39dfff commit fafcc76

File tree

9 files changed

+361
-246
lines changed

9 files changed

+361
-246
lines changed

.github/workflows/build.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: ["main", "development"]
6+
pull_request:
7+
branches: ["main", "development"]
8+
9+
permissions:
10+
contents: read # This is required for actions/checkout
11+
12+
# Cancel when pull request is updated
13+
concurrency:
14+
group: ${{ github.head_ref }}-${{ github.run_id}}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
lint-commits:
19+
# Note: To re-run `lint-commits` after fixing the PR title, close-and-reopen the PR.
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Use Node.js 22.x
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 22.x
27+
cache: "npm"
28+
- name: Check PR title
29+
run: |
30+
node "$GITHUB_WORKSPACE/.github/workflows/lintcommit.js"
31+
32+
build:
33+
needs: lint-commits
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Use Node.js 22.x
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 22.x
41+
cache: "npm"
42+
- name: Install dependencies
43+
run: npm run install-all
44+
- name: Build project
45+
run: npm run build
46+
- name: Upload build artifacts
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: built-artifacts
50+
path: |
51+
packages/**/dist*/*
52+
package.json
53+
package-lock.json
54+
55+
unit-tests:
56+
needs: build
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
node-version: ["20.x", "22.x", "24.x"]
61+
uses: "./.github/workflows/unit-tests.yml"
62+
with:
63+
node-version: ${{ matrix.node-version }}
64+
65+
integration-tests:
66+
needs: build
67+
permissions:
68+
contents: read
69+
id-token: write
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
node-version: ["20.x", "22.x", "24.x"]
74+
uses: "./.github/workflows/integration-tests.yml"
75+
with:
76+
node-version: ${{ matrix.node-version }}
77+
secrets: inherit
78+
79+
cleanup-integration-tests:
80+
needs: [integration-tests]
81+
runs-on: ubuntu-latest
82+
permissions:
83+
contents: read
84+
id-token: write
85+
86+
concurrency:
87+
group: ${{ github.head_ref }}-${{ github.run_id }}-${{ matrix.node-version }}-integ
88+
cancel-in-progress: true
89+
90+
strategy:
91+
# Clean up functions sequentially to avoid throttling
92+
max-parallel: 1
93+
fail-fast: false
94+
matrix:
95+
node-version: ["20.x", "22.x", "24.x"]
96+
97+
if: ${{ !failure() }}
98+
99+
steps:
100+
- uses: actions/checkout@v4
101+
102+
- name: Setup Node.js
103+
uses: actions/setup-node@v4
104+
with:
105+
node-version: ${{ matrix.node-version }}
106+
cache: "npm"
107+
108+
- name: Download build artifacts
109+
uses: actions/download-artifact@v4
110+
with:
111+
name: built-artifacts
112+
path: .
113+
114+
- name: Install dependencies
115+
run: |
116+
npm run install-all
117+
118+
- name: Get AWS Credentials
119+
id: credentials
120+
if: github.actor != 'nektos/act'
121+
uses: aws-actions/configure-aws-credentials@v4
122+
with:
123+
role-to-assume: "${{ secrets.ACTIONS_INTEGRATION_ROLE_NAME }}"
124+
role-session-name: githubIntegrationTest
125+
aws-region: ${{ vars.AWS_REGION }}
126+
127+
- name: Cleanup Lambda functions
128+
env:
129+
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }}
130+
GITHUB_EVENT_NAME: ${{ github.event_name }}
131+
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
132+
run: |
133+
node .github/workflows/scripts/integration-test/integration-test.js --cleanup-only --runtime ${{ matrix.node-version }}

.github/workflows/cleanup-pr-logs.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,32 @@ on:
77
- development
88

99
permissions:
10-
id-token: write # This is required for requesting the JWT
1110
contents: read # This is required for actions/checkout
1211

13-
env:
14-
AWS_REGION: ${{ vars.AWS_REGION }}
15-
1612
jobs:
1713
cleanup-logs:
1814
if: github.event.pull_request.merged == true
1915
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
id-token: write # Required for AWS credentials
2019

2120
steps:
2221
- name: Configure AWS credentials
2322
uses: aws-actions/configure-aws-credentials@v4
2423
with:
2524
role-to-assume: "${{ secrets.ACTIONS_WEBHOOK_ROLE_ARN }}"
2625
role-session-name: "GitHub-PR-${{ github.event.pull_request.number }}-Cleanup"
27-
aws-region: ${{ env.AWS_REGION }}
26+
aws-region: ${{ vars.AWS_REGION }}
2827

2928
- name: Install awscurl
3029
run: pip install awscurl
3130

3231
- name: Cleanup PR log group
3332
run: |
3433
awscurl --service execute-api \
35-
--region ${{ env.AWS_REGION }} \
34+
--region ${{ vars.AWS_REGION }} \
3635
-X POST \
3736
-H "Content-Type: application/json" \
38-
-d '{"logGroupSuffix": "-TypeScript-PR-${{ github.event.pull_request.number }}"}' \
37+
-d '{"logGroupSuffix": "-NodeJS-PR-${{ github.event.pull_request.number }}"}' \
3938
"${{ secrets.LOG_GROUP_CLEANUP_WEBHOOK }}"
Lines changed: 36 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,84 @@
11
name: Integration Tests
22

33
on:
4-
push:
5-
branches: ["main", "development"]
6-
paths:
7-
- "packages/aws-durable-execution-**"
8-
- "packages/client-lambda/**"
9-
- ".github/workflows/integration-tests.yml"
10-
- ".github/workflows/scripts/integration-test/**"
11-
- ".github/model/**"
12-
pull_request:
13-
branches: ["main", "development"]
14-
paths:
15-
- "packages/aws-durable-execution-**"
16-
- "packages/client-lambda/**"
17-
- ".github/workflows/integration-tests.yml"
18-
- ".github/workflows/scripts/integration-test/**"
19-
- ".github/model/**"
20-
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
node-version:
7+
required: true
8+
type: string
219

22-
env:
23-
AWS_REGION: ${{ vars.AWS_REGION }}
24-
25-
# permission can be added at job level or workflow level
26-
permissions:
27-
id-token: write # This is required for requesting the JWT
28-
contents: read # This is required for actions/checkout
10+
# Cancel when pull request is updated for this node version
11+
concurrency:
12+
group: ${{ github.head_ref }}-${{ github.run_id }}-${{ inputs.node-version }}-integ
13+
cancel-in-progress: true
2914

3015
jobs:
31-
setup:
16+
deploy:
17+
permissions:
18+
contents: read
19+
id-token: write # Required for AWS credentials
3220
runs-on: ubuntu-latest
33-
outputs:
34-
function-name-map: ${{ steps.deploy-functions.outputs.function-name-map }}
3521
steps:
3622
- uses: actions/checkout@v4
3723

3824
- name: Setup Node.js
3925
uses: actions/setup-node@v4
4026
with:
41-
node-version: "22.x"
27+
node-version: ${{ inputs.node-version }}
4228
cache: "npm"
4329

44-
- name: Configure AWS credentials (OIDC for main workflow)
45-
if: github.event_name != 'workflow_dispatch' || github.actor != 'nektos/act'
30+
- name: Get AWS Credentials
31+
id: credentials
32+
if: github.actor != 'nektos/act'
4633
uses: aws-actions/configure-aws-credentials@v4
4734
with:
4835
role-to-assume: "${{ secrets.ACTIONS_INTEGRATION_ROLE_NAME }}"
4936
role-session-name: githubIntegrationTest
50-
aws-region: ${{ env.AWS_REGION }}
37+
aws-region: ${{ vars.AWS_REGION }}
5138

52-
- name: Install custom Lambda model
53-
run: |
54-
aws configure add-model --service-model file://.github/model/lambda.json --service-name lambda
39+
- name: Download build artifacts
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: built-artifacts
43+
path: .
5544

5645
- name: Install dependencies
5746
run: npm run install-all
5847

59-
- name: Build project
60-
run: npm run build
61-
62-
- name: Upload build artifacts
63-
uses: actions/upload-artifact@v4
64-
with:
65-
name: built-artifacts
66-
path: |
67-
packages/**/dist*/*
68-
package.json
69-
7048
- name: Deploy functions
49+
id: deploy-functions
7150
env:
72-
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
7351
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }}
74-
INVOKE_ACCOUNT_ID: ${{ secrets.INVOKE_ACCOUNT_ID_BETA }}
75-
KMS_KEY_ARN: ${{ secrets.KMS_KEY_ARN }}
7652
GITHUB_EVENT_NAME: ${{ github.event_name }}
7753
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
78-
run: node .github/workflows/scripts/integration-test/integration-test.js --deploy-only
54+
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
55+
run: node .github/workflows/scripts/integration-test/integration-test.js --deploy-only --runtime ${{ inputs.node-version }}
7956

8057
jest-integration-test:
81-
needs: setup
58+
needs: deploy
8259
runs-on: ubuntu-latest
8360
name: Jest Integration Tests
61+
permissions:
62+
contents: read
63+
id-token: write # Required for AWS credentials
8464

8565
steps:
8666
- uses: actions/checkout@v4
8767

8868
- name: Setup Node.js
8969
uses: actions/setup-node@v4
9070
with:
91-
node-version: "22.x"
71+
node-version: ${{ inputs.node-version }}
9272
cache: "npm"
9373

94-
- name: Configure AWS credentials (OIDC for main workflow)
95-
if: github.event_name != 'workflow_dispatch' || github.actor != 'nektos/act'
74+
- name: Get AWS Credentials
75+
id: credentials
76+
if: github.actor != 'nektos/act'
9677
uses: aws-actions/configure-aws-credentials@v4
9778
with:
9879
role-to-assume: "${{ secrets.ACTIONS_INTEGRATION_ROLE_NAME }}"
9980
role-session-name: githubIntegrationTest
100-
aws-region: ${{ env.AWS_REGION }}
81+
aws-region: ${{ vars.AWS_REGION }}
10182

10283
- name: Download build artifacts
10384
uses: actions/download-artifact@v4
@@ -112,51 +93,7 @@ jobs:
11293
- name: Run Jest integration tests
11394
env:
11495
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }}
115-
FUNCTION_NAME_MAP: ${{ needs.setup.outputs.function-name-map }}
116-
GITHUB_EVENT_NAME: ${{ github.event_name }}
117-
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
118-
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
119-
run: |
120-
node .github/workflows/scripts/integration-test/integration-test.js --test-only
121-
122-
cleanup:
123-
needs: [setup, jest-integration-test]
124-
runs-on: ubuntu-latest
125-
if: ${{ !failure() }}
126-
127-
steps:
128-
- uses: actions/checkout@v4
129-
130-
- name: Setup Node.js
131-
uses: actions/setup-node@v4
132-
with:
133-
node-version: "22.x"
134-
cache: "npm"
135-
136-
- name: Download build artifacts
137-
uses: actions/download-artifact@v4
138-
with:
139-
name: built-artifacts
140-
path: .
141-
142-
- name: Install dependencies
143-
run: |
144-
npm run install-all
145-
146-
- name: Configure AWS credentials (OIDC for main workflow)
147-
if: github.event_name != 'workflow_dispatch' || github.actor != 'nektos/act'
148-
uses: aws-actions/configure-aws-credentials@v4
149-
with:
150-
role-to-assume: "${{ secrets.ACTIONS_INTEGRATION_ROLE_NAME }}"
151-
role-session-name: githubIntegrationTest
152-
aws-region: ${{ env.AWS_REGION }}
153-
154-
- name: Cleanup Lambda functions
155-
env:
156-
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }}
157-
FUNCTION_NAME_MAP: ${{ needs.setup.outputs.function-name-map }}
15896
GITHUB_EVENT_NAME: ${{ github.event_name }}
15997
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
160-
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
16198
run: |
162-
node .github/workflows/scripts/integration-test/integration-test.js --cleanup-only
99+
node .github/workflows/scripts/integration-test/integration-test.js --test-only --runtime ${{ inputs.node-version }}

0 commit comments

Comments
 (0)