@@ -3,6 +3,7 @@ permissions:
33 contents : read
44
55on :
6+ pull_request :
67 workflow_dispatch :
78 inputs :
89 version_bump :
@@ -46,22 +47,28 @@ jobs:
4647 npm run lint
4748 npm run test_conditions
4849
49- test-nodejs20 :
50+ test :
5051 runs-on : ubuntu-latest
5152 permissions :
5253 id-token : write
5354 contents : read
55+ strategy :
56+ matrix :
57+ node-version : ['18', '20']
58+ test-type : ['node', 'browser']
59+ test-category : ['coverage', 'vectors']
60+ name : test-${{ matrix.test-category }}-${{ matrix.test-type }}${{ matrix.node-version }}
5461 steps :
5562 - name : Checkout code
5663 uses : actions/checkout@v4
5764 with :
5865 fetch-depth : 0
5966 submodules : true
6067
61- - name : Setup Node.js 20
68+ - name : Setup Node.js ${{ matrix.node-version }}
6269 uses : actions/setup-node@v4
6370 with :
64- node-version : ' 20 '
71+ node-version : ${{ matrix.node-version }}
6572 cache : ' npm'
6673
6774 - name : Configure AWS Credentials for Tests
@@ -76,118 +83,23 @@ jobs:
7683 npm ci --unsafe-perm
7784 npm run build
7885
79- - name : Run Node.js tests
80- run : npm run coverage-node
81-
82- test-browser18 :
83- runs-on : ubuntu-latest
84- permissions :
85- id-token : write
86- contents : read
87- steps :
88- - name : Checkout code
89- uses : actions/checkout@v4
90- with :
91- fetch-depth : 0
92- submodules : true
93-
94- - name : Setup Node.js 18
95- uses : actions/setup-node@v4
96- with :
97- node-version : ' 18'
98- cache : ' npm'
99-
100- - name : Configure AWS Credentials for Tests
101- uses : aws-actions/configure-aws-credentials@v4
102- with :
103- aws-region : us-west-2
104- role-to-assume : arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
105- role-session-name : JavaScriptTests
106-
107- - name : Install dependencies and build
108- run : |
109- npm ci --unsafe-perm
110- npm run build
111-
112- - name : Run browser tests
113- run : npm run coverage-browser
114-
115- test-vectors-nodejs20 :
116- runs-on : ubuntu-latest
117- permissions :
118- id-token : write
119- contents : read
120- steps :
121- - name : Checkout code
122- uses : actions/checkout@v4
123- with :
124- fetch-depth : 0
125- submodules : true
126-
127- - name : Setup Node.js 20
128- uses : actions/setup-node@v4
129- with :
130- node-version : ' 20'
131- cache : ' npm'
132-
133- - name : Configure AWS Credentials for Tests
134- uses : aws-actions/configure-aws-credentials@v4
135- with :
136- aws-region : us-west-2
137- role-to-assume : arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
138- role-session-name : JavaScriptTests
139-
140- - name : Install dependencies and build
141- run : |
142- npm ci --unsafe-perm
143- npm run build
144-
145- - name : Run integration tests with local publish
146- run : |
147- npm run verdaccio-publish
148- npm run verdaccio-node-decrypt
149- npm run verdaccio-node-encrypt
150-
151- test-vectors-browser18 :
152- runs-on : ubuntu-latest
153- permissions :
154- id-token : write
155- contents : read
156- steps :
157- - name : Checkout code
158- uses : actions/checkout@v4
159- with :
160- fetch-depth : 0
161- submodules : true
162-
163- - name : Setup Node.js 18
164- uses : actions/setup-node@v4
165- with :
166- node-version : ' 18'
167- cache : ' npm'
168-
169- - name : Configure AWS Credentials for Tests
170- uses : aws-actions/configure-aws-credentials@v4
171- with :
172- aws-region : us-west-2
173- role-to-assume : arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
174- role-session-name : JavaScriptTests
175-
176- - name : Install dependencies and build
86+ - name : Run ${{ matrix.test-category }} tests (${{ matrix.test-type }})
17787 run : |
178- npm ci --unsafe-perm
179- npm run build
180-
181- - name : Run integration tests with local publish
182- run : |
183- npm run verdaccio-publish
184- npm run verdaccio-browser-decrypt
185- npm run verdaccio-browser-encrypt
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
18698
18799 # Once all tests have passed, run semantic versioning
188100 version :
189101 runs-on : ubuntu-latest
190- needs : [compliance, test-nodejs20, test-browser18, test-vectors-nodejs20, test-vectors-browser18 ]
102+ needs : [compliance, test]
191103 steps :
192104 - name : Checkout code
193105 uses : actions/checkout@v4
@@ -211,73 +123,44 @@ jobs:
211123 run : |
212124 git config --global user.name "aws-crypto-tools-ci-bot"
213125 git config --global user.email "[email protected] " 214- git checkout $BRANCH
126+ git checkout ${{ github.head_ref }} # Use PR branch or current branch
215127
216128 - name : Version packages (dry run - no push)
217129 run : |
218- # Generate new version and CHANGELOG entry and push it
219- npx lerna version --conventional-commits --git-remote origin --yes ${VERSION_BUMP:+$VERSION_BUMP --force-publish}
220- # Log the commit for posterity
130+ # For testing: no push to avoid modifying master branch
131+ npx lerna version --conventional-commits --no-push --yes ${VERSION_BUMP:+$VERSION_BUMP --force-publish}
132+ # TODO: uncomment line below and remove line above when adding publish step
133+ # npx lerna version --conventional-commits --git-remote origin --yes ${VERSION_BUMP:+$VERSION_BUMP --force-publish}
221134 git log -n 1
222135
223136 # Once semantic versioning has run and bumped versions, publish to npm
224137 # TODO: Publish step that doesn't use OTP but instead follows
225138 # https://docs.npmjs.com/trusted-publishers
226139
227140 # Once publishing is complete, validate that the published packages are useable
228- validate-nodejs :
229- runs-on : ubuntu-latest
230- # TODO: Uncomment when adding publish step
231- # needs: [publish]
232- permissions :
233- id-token : write
234- contents : read
235- steps :
236- - name : Checkout code
237- uses : actions/checkout@v4
238- with :
239- fetch-depth : 0
240- submodules : true
241-
242- - name : Setup Node.js 20
243- uses : actions/setup-node@v4
244- with :
245- node-version : ' 20'
246- cache : ' npm'
247-
248- - name : Configure AWS Credentials for Tests
249- uses : aws-actions/configure-aws-credentials@v4
250- with :
251- aws-region : us-west-2
252- role-to-assume : arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
253- role-session-name : JavaScriptTests
254-
255- - name : Install dependencies
256- run : npm ci --unsafe-perm
257-
258- - name : Validate published packages - Node.js
259- run : |
260- npm run verdaccio-node-decrypt
261- npm run verdaccio-node-encrypt
262-
263- validate-browser :
141+ validate :
264142 runs-on : ubuntu-latest
265143 # TODO: Uncomment when adding publish step
266144 # needs: [publish]
267145 permissions :
268146 id-token : write
269147 contents : read
148+ strategy :
149+ matrix :
150+ node-version : ['18', '20']
151+ test-type : ['node', 'browser']
152+ name : validate-${{ matrix.test-type }}${{ matrix.node-version }}
270153 steps :
271154 - name : Checkout code
272155 uses : actions/checkout@v4
273156 with :
274157 fetch-depth : 0
275158 submodules : true
276159
277- - name : Setup Node.js 18
160+ - name : Setup Node.js ${{ matrix.node-version }}
278161 uses : actions/setup-node@v4
279162 with :
280- node-version : ' 18 '
163+ node-version : ${{ matrix.node-version }}
281164 cache : ' npm'
282165
283166 - name : Configure AWS Credentials for Tests
@@ -290,12 +173,12 @@ jobs:
290173 - name : Install dependencies
291174 run : npm ci --unsafe-perm
292175
293- - name : Validate published packages - Browser
176+ - name : Validate published packages - ${{ matrix.test-type }}
294177 # This will fail until the publish step is run for the first time.
295178 # A dependency change broke the browser tests.
296179 # Commit fb10180dfb451ff5359ebc703c58eaf5393971ac fixes this.
297180 # The first publish step for v4.2.2+ should make this pass.
298181 # TODO: Remove this comment block after first successful publish of v4.2.2+.
299182 run : |
300- npm run verdaccio-browser -decrypt
301- npm run verdaccio-browser -encrypt
183+ npm run verdaccio-${{ matrix.test-type }} -decrypt
184+ npm run verdaccio-${{ matrix.test-type }} -encrypt
0 commit comments