Skip to content

Commit 53f07cc

Browse files
chore: Migrate CodeBuild release to GHA (without publishing step) (#1614)
1 parent fb10180 commit 53f07cc

File tree

4 files changed

+169
-60
lines changed

4 files changed

+169
-60
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,21 @@
11
# This workflow performs tests in JavaScript.
22
name: ESDK JavaScript CI Tests
3+
permissions:
4+
contents: read
5+
id-token: write
36

47
on: [pull_request, workflow_call]
58

69
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
10+
shared-ci:
11+
uses: ./.github/workflows/shared-ci.yml
12+
pr-ci-all-required:
13+
if: always()
14+
needs:
15+
- shared-ci
16+
runs-on: ubuntu-22.04
1917
steps:
20-
- uses: actions/checkout@v4
18+
- name: Verify all required jobs passed
19+
uses: re-actors/alls-green@release/v1
2120
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
21+
jobs: ${{ toJSON(needs) }}

.github/workflows/prod-release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release
2+
permissions:
3+
contents: read
4+
id-token: write
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
version_bump:
10+
required: false
11+
description: '[Optional] Override semantic versioning with explict version (allowed values: "patch", "minor", "major", or explicit version)'
12+
default: ''
13+
dist_tag:
14+
description: 'NPM distribution tag'
15+
required: false
16+
default: 'latest'
17+
branch:
18+
description: 'The branch to release from'
19+
required: false
20+
default: 'master'
21+
22+
env:
23+
NODE_OPTIONS: "--max-old-space-size=4096"
24+
NPM_CONFIG_UNSAFE_PERM: true
25+
26+
jobs:
27+
pre-release-ci:
28+
uses: ./.github/workflows/shared-ci.yml
29+
30+
# Once all tests have passed, run semantic versioning
31+
version:
32+
runs-on: ubuntu-latest
33+
needs: [pre-release-ci]
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
submodules: true
40+
41+
- name: Setup Node.js 16
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: '16'
45+
cache: 'npm'
46+
47+
- name: Install dependencies
48+
run: npm ci --unsafe-perm
49+
50+
- name: Configure git
51+
env:
52+
BRANCH: ${{ github.event.inputs.branch }}
53+
VERSION_BUMP: ${{ github.event.inputs.version_bump }}
54+
run: |
55+
git config --global user.name "aws-crypto-tools-ci-bot"
56+
git config --global user.email "no-reply@noemail.local"
57+
git checkout $BRANCH
58+
59+
- name: Version packages (dry run - no push)
60+
run: |
61+
# Generate new version and CHANGELOG entry and push it
62+
npx lerna version --conventional-commits --git-remote origin --yes ${VERSION_BUMP:+$VERSION_BUMP --force-publish}
63+
# Log the commit for posterity
64+
git log -n 1
65+
66+
# Once semantic versioning has run and bumped versions, publish to npm
67+
# TODO: Publish step that doesn't use OTP but instead follows
68+
# https://docs.npmjs.com/trusted-publishers
69+
70+
# Once publishing is complete, validate that the published packages are useable
71+
validate:
72+
uses: ./.github/workflows/shared-ci.yml
73+
# TODO: Uncomment when adding publish step
74+
# needs: [publish]
75+
with:
76+
test-published-packages: true

.github/workflows/shared-ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
test:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
id-token: write
21+
contents: read
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
node-version: ['18.x', '20.x', '22.x', 'latest']
26+
test-type: ['node', 'browser']
27+
# Determine test categories based on whether testing published packages or source code:
28+
# - Testing published packages: only run vector tests (don't have build artifacts to test coverage or compliance)
29+
# - Testing source code: run coverage, vector, and compliance tests
30+
test-category: ${{ fromJSON(inputs['test-published-packages'] && '["vectors"]' || '["coverage", "vectors", "compliance"]') }}
31+
name: test-${{ matrix.test-category }}-${{ matrix.test-type }}-${{ matrix.node-version }}
32+
steps:
33+
- name: Checkout code
34+
# Always need repo for test scripts and configuration, even when testing published packages
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
submodules: true
39+
40+
- name: Setup Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
cache: 'npm'
45+
46+
- name: Configure AWS Credentials for Tests
47+
uses: aws-actions/configure-aws-credentials@v4
48+
with:
49+
aws-region: us-west-2
50+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
51+
role-session-name: JavaScriptTests
52+
53+
- name: Install dependencies
54+
run: npm ci --unsafe-perm
55+
56+
- name: Build (for source code testing)
57+
if: ${{ !inputs.test-published-packages }}
58+
run: npm run build
59+
60+
- name: Run coverage tests (${{ matrix.test-type }})
61+
if: ${{ matrix.test-category == 'coverage' }}
62+
run: npm run coverage-${{ matrix.test-type }}
63+
64+
- name: Publish locally for vector tests
65+
if: ${{ matrix.test-category == 'vectors' && !inputs.test-published-packages }}
66+
run: npm run verdaccio-publish
67+
68+
- name: Run vector tests (${{ matrix.test-type }})
69+
if: ${{ matrix.test-category == 'vectors' }}
70+
run: |
71+
npm run verdaccio-${{ matrix.test-type }}-decrypt
72+
npm run verdaccio-${{ matrix.test-type }}-encrypt
73+
74+
- name: Run compliance tests
75+
# Don't run linting or check Duvet requirements for published packages
76+
if: ${{ matrix.test-category == 'compliance'}}
77+
run: |
78+
npm run lint
79+
npm run test_conditions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"build-browser": "tsc -b tsconfig.module.json",
2727
"build": "run-s build-*",
2828
"karma": "NODE_OPTIONS=--max-old-space-size=4096 karma start karma.conf.js",
29-
"mocha": "mocha --exclude 'modules/*-+(browser|backend)/build/main/test/*.js' modules/**/build/main/test/*test.js",
29+
"mocha": "mocha --timeout 5000 --exclude 'modules/*-+(browser|backend)/build/main/test/*.js' modules/**/build/main/test/*test.js",
3030
"coverage-browser": "npm run karma && nyc report -t .karma_output --check-coverage",
3131
"coverage-node": "nyc --instrument --all --check-coverage -n 'modules/**/build/main/src/*.js' -x 'modules/**/build/main/test/*.js' -x 'modules/*-+(browser|backend)/**/*.js' npm run mocha",
3232
"coverage-merge": "nyc merge .karma_output .nyc_output/browser.json",

0 commit comments

Comments
 (0)