Skip to content

Commit c003499

Browse files
author
Lucas McDonald
committed
m
1 parent cdd94f2 commit c003499

File tree

3 files changed

+111
-176
lines changed

3 files changed

+111
-176
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,5 @@ name: ESDK JavaScript CI Tests
44
on: [pull_request, workflow_call]
55

66
jobs:
7-
CI:
8-
strategy:
9-
matrix:
10-
node: [18.x, 20.x, 22.x, latest]
11-
fail-fast: false
12-
runs-on: codebuild-AWS-ESDK-JS-Release-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-5.0-large
13-
permissions:
14-
id-token: write
15-
contents: read
16-
defaults:
17-
run:
18-
shell: bash
19-
steps:
20-
- uses: actions/checkout@v4
21-
with:
22-
submodules: true
23-
- uses: actions/setup-node@v4
24-
with:
25-
node-version: ${{matrix.node}}
26-
- name: Configure AWS Credentials for Tests
27-
uses: aws-actions/configure-aws-credentials@v4
28-
with:
29-
aws-region: us-west-2
30-
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
31-
role-session-name: JavaScriptTests
32-
- name: Test Coverage Node ${{matrix.node}}
33-
env:
34-
NODE_OPTIONS: "--max-old-space-size=4096"
35-
run: |
36-
npm ci
37-
npm run build
38-
npm run coverage-node
39-
- name: Test Coverage Browser ${{matrix.node}}
40-
env:
41-
NODE_OPTIONS: "--max-old-space-size=4096"
42-
run: |
43-
npm run coverage-browser
44-
- name: Test compliance
45-
env:
46-
NODE_OPTIONS: "--max-old-space-size=4096"
47-
run: |
48-
npm run lint
49-
npm run test_conditions
50-
- name: Run Test Vectors Node ${{matrix.node}}
51-
env:
52-
NODE_OPTIONS: "--max-old-space-size=4096"
53-
NPM_CONFIG_UNSAFE_PERM: true
54-
PUBLISH_LOCAL: true
55-
run: |
56-
npm run verdaccio-publish
57-
npm run verdaccio-node-decrypt
58-
npm run verdaccio-node-encrypt
59-
- name: Run Test Vectors Browser node ${{matrix.node}}
60-
env:
61-
NODE_OPTIONS: "--max-old-space-size=4096"
62-
NPM_CONFIG_UNSAFE_PERM: true
63-
PUBLISH_LOCAL: true
64-
run: |
65-
npm run verdaccio-publish
66-
npm run verdaccio-browser-decrypt
67-
npm run verdaccio-browser-encrypt
7+
shared-ci:
8+
uses: ./.github/workflows/shared-ci.yml

.github/workflows/prod-release.yml

Lines changed: 6 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -23,83 +23,13 @@ env:
2323
NPM_CONFIG_UNSAFE_PERM: true
2424

2525
jobs:
26-
compliance:
27-
runs-on: ubuntu-latest
28-
steps:
29-
- name: Checkout code
30-
uses: actions/checkout@v4
31-
with:
32-
fetch-depth: 0
33-
submodules: true
34-
35-
- name: Setup Node.js 18
36-
uses: actions/setup-node@v4
37-
with:
38-
node-version: '18'
39-
cache: 'npm'
40-
41-
- name: Install dependencies
42-
run: npm ci --unsafe-perm
43-
44-
- name: Run compliance checks
45-
run: |
46-
npm run lint
47-
npm run test_conditions
48-
49-
test:
50-
runs-on: ubuntu-latest
51-
permissions:
52-
id-token: write
53-
contents: read
54-
strategy:
55-
fail-fast: false
56-
matrix:
57-
node-version: ['18', '20', '22']
58-
test-type: ['node', 'browser']
59-
test-category: ['coverage', 'vectors']
60-
name: test-${{ matrix.test-category }}-${{ matrix.test-type }}${{ matrix.node-version }}
61-
steps:
62-
- name: Checkout code
63-
uses: actions/checkout@v4
64-
with:
65-
fetch-depth: 0
66-
submodules: true
67-
68-
- name: Setup Node.js ${{ matrix.node-version }}
69-
uses: actions/setup-node@v4
70-
with:
71-
node-version: ${{ matrix.node-version }}
72-
cache: 'npm'
73-
74-
- name: Configure AWS Credentials for Tests
75-
uses: aws-actions/configure-aws-credentials@v4
76-
with:
77-
aws-region: us-west-2
78-
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
79-
role-session-name: JavaScriptTests
80-
81-
- name: Install dependencies and build
82-
run: |
83-
npm ci --unsafe-perm
84-
npm run build
85-
86-
- name: Run ${{ matrix.test-category }} tests (${{ matrix.test-type }})
87-
run: |
88-
if [ "${{ matrix.test-category }}" = "coverage" ]; then
89-
npm run coverage-${{ matrix.test-type }}
90-
elif [ "${{ matrix.test-category }}" = "vectors" ]; then
91-
npm run verdaccio-publish
92-
npm run verdaccio-${{ matrix.test-type }}-decrypt
93-
npm run verdaccio-${{ matrix.test-type }}-encrypt
94-
else
95-
echo "Error: Unrecognized test category '${{ matrix.test-category }}'"
96-
exit 1
97-
fi
26+
pre-release-ci:
27+
uses: ./.github/workflows/shared-ci.yml
9828

9929
# Once all tests have passed, run semantic versioning
10030
version:
10131
runs-on: ubuntu-latest
102-
needs: [compliance, test]
32+
needs: [pre-release-ci]
10333
steps:
10434
- name: Checkout code
10535
uses: actions/checkout@v4
@@ -138,47 +68,8 @@ jobs:
13868

13969
# Once publishing is complete, validate that the published packages are useable
14070
validate:
141-
runs-on: ubuntu-latest
71+
uses: ./.github/workflows/shared-ci.yml
14272
# TODO: Uncomment when adding publish step
14373
# needs: [publish]
144-
permissions:
145-
id-token: write
146-
contents: read
147-
strategy:
148-
fail-fast: false
149-
matrix:
150-
node-version: ['18', '20', '22']
151-
test-type: ['node', 'browser']
152-
name: validate-${{ matrix.test-type }}${{ matrix.node-version }}
153-
steps:
154-
- name: Checkout code
155-
uses: actions/checkout@v4
156-
with:
157-
fetch-depth: 0
158-
submodules: true
159-
160-
- name: Setup Node.js ${{ matrix.node-version }}
161-
uses: actions/setup-node@v4
162-
with:
163-
node-version: ${{ matrix.node-version }}
164-
cache: 'npm'
165-
166-
- name: Configure AWS Credentials for Tests
167-
uses: aws-actions/configure-aws-credentials@v4
168-
with:
169-
aws-region: us-west-2
170-
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
171-
role-session-name: JavaScriptTests
172-
173-
- name: Install dependencies
174-
run: npm ci --unsafe-perm
175-
176-
- name: Validate published packages - ${{ matrix.test-type }}
177-
# This will fail until the publish step is run for the first time.
178-
# A dependency change broke the browser tests.
179-
# Commit fb10180dfb451ff5359ebc703c58eaf5393971ac fixes this.
180-
# The first publish step for v4.2.2+ should make this pass.
181-
# TODO: Remove this comment block after first successful publish of v4.2.2+.
182-
run: |
183-
npm run verdaccio-${{ matrix.test-type }}-decrypt
184-
npm run verdaccio-${{ matrix.test-type }}-encrypt
74+
with:
75+
test-published-packages: true

.github/workflows/shared-ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Shared CI Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
test-published-packages:
7+
description: 'Test against published packages instead of checked out code'
8+
required: false
9+
type: boolean
10+
default: false
11+
12+
env:
13+
NODE_OPTIONS: "--max-old-space-size=4096"
14+
NPM_CONFIG_UNSAFE_PERM: true
15+
16+
jobs:
17+
compliance:
18+
# Don't lint or check Duvet annotations on already-published code
19+
if: ${{ !inputs.test-published-packages }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
submodules: true
27+
28+
- name: Setup Node.js 18
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '18'
32+
cache: 'npm'
33+
34+
- name: Install dependencies
35+
run: npm ci --unsafe-perm
36+
37+
- name: Run compliance checks
38+
run: |
39+
npm run lint
40+
npm run test_conditions
41+
42+
test:
43+
runs-on: ubuntu-latest
44+
permissions:
45+
id-token: write
46+
contents: read
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
node-version: ['18', '20', '22']
51+
test-type: ['node', 'browser']
52+
test-category: ['coverage', 'vectors']
53+
name: test-${{ matrix.test-category }}-${{ matrix.test-type }}${{ matrix.node-version }}
54+
steps:
55+
- name: Checkout code
56+
# Always need repo for test scripts and configuration, even when testing published packages
57+
uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
60+
submodules: true
61+
62+
- name: Setup Node.js ${{ matrix.node-version }}
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: ${{ matrix.node-version }}
66+
cache: 'npm'
67+
68+
- name: Configure AWS Credentials for Tests
69+
uses: aws-actions/configure-aws-credentials@v4
70+
with:
71+
aws-region: us-west-2
72+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
73+
role-session-name: JavaScriptTests
74+
75+
- name: Install dependencies
76+
run: npm ci --unsafe-perm
77+
78+
- name: Build (for source code testing)
79+
if: ${{ !inputs.test-published-packages }}
80+
run: npm run build
81+
82+
- name: Run ${{ matrix.test-category }} tests (${{ matrix.test-type }})
83+
run: |
84+
# Skip coverage tests when testing published packages
85+
if [ "${{ inputs.test-published-packages }}" = "true" ] && [ "${{ matrix.test-category }}" = "coverage" ]; then
86+
echo "Skipping coverage tests for published packages validation"
87+
exit 0
88+
fi
89+
90+
# Run the appropriate test
91+
if [ "${{ matrix.test-category }}" = "coverage" ]; then
92+
npm run coverage-${{ matrix.test-type }}
93+
elif [ "${{ matrix.test-category }}" = "vectors" ]; then
94+
# Only publish locally when testing source code
95+
if [ "${{ inputs.test-published-packages }}" != "true" ]; then
96+
npm run verdaccio-publish
97+
fi
98+
npm run verdaccio-${{ matrix.test-type }}-decrypt
99+
npm run verdaccio-${{ matrix.test-type }}-encrypt
100+
else
101+
echo "Error: Unrecognized test category '${{ matrix.test-category }}'"
102+
exit 1
103+
fi

0 commit comments

Comments
 (0)