1- name : Common CI
1+ name : Common CI tests
2+
3+ run-name : " Test: mode=${{ inputs.mode }}, testMonorepo=${{ inputs.testMonorepo }}"
24
35on :
46 workflow_call :
7+ inputs :
8+ mode :
9+ description : " 'build' (just builded code, used while publishing) or 'global' (real NPM installed globally) or 'local' (real NPM installed locally)"
10+ type : string
11+ required : true
12+ testMonorepo :
13+ description : " Test monorepo by specifying folder in config"
14+ type : string
15+ required : true
516
617permissions :
718 id-token : write
819 contents : write
920
1021env :
1122 DISABLE_PARALLEL_DEPLOY : false
23+ REAL_NPM : ${{ inputs.mode == 'global' || inputs.mode == 'local' }}
24+ TEST_MONOREPO : ${{ github.event.inputs.testMonorepo }}
1225 node_version : 20
1326
1427jobs :
15- build :
16- runs-on : ubuntu-latest
17- concurrency :
18- group : build
19- steps :
20- - uses : actions/checkout@v4
21- - name : Use Node.js
22- uses : actions/setup-node@v4
23- with :
24- node-version : ${{ env.node_version }}
25- registry-url : " https://registry.npmjs.org"
26- - name : Install dependencies
27- run : npm ci
28- - name : Typecheck
29- run : npm run typecheck
30- - name : Build
31- run : npm run build
32- - name : Configure AWS Credentials
33- uses : aws-actions/configure-aws-credentials@v4
34- with :
35- aws-region : eu-west-1
36- role-to-assume : ${{ secrets.AWS_ROLE }}
37- role-session-name : GitHubActions
38- - name : Bootstrap CDK
39- # so I do not have to do it manually when CDK is updated
40- run : npx cdk bootstrap aws://${{secrets.AWS_ACCOUNT_ID}}/eu-west-1
41- - uses : actions/upload-artifact@v4
42- with :
43- name : dist
44- path : dist
45-
4628 test-cdk-basic :
47- needs :
48- - build
4929 runs-on : ubuntu-latest
5030 concurrency :
5131 group : test-cdk-basic
@@ -58,10 +38,22 @@ jobs:
5838 registry-url : " https://registry.npmjs.org"
5939 - name : Install dependencies
6040 run : npm ci
61- - uses : actions/download-artifact@v4
41+ - name : Download build artifact
42+ uses : actions/download-artifact@v4
43+ if : ${{ inputs.mode == 'build' }}
6244 with :
6345 name : dist
6446 path : dist
47+ - name : Install lambda-live-debugger globally
48+ if : ${{ inputs.mode == 'global' }}
49+ run : |
50+ npm i lambda-live-debugger -g
51+ working-directory : test
52+ - name : Install lambda-live-debugger locally
53+ if : ${{ inputs.mode == 'local' }}
54+ run : |
55+ npm i lambda-live-debugger
56+ working-directory : test
6557 - name : Configure AWS Credentials
6658 uses : aws-actions/configure-aws-credentials@v4
6759 with :
8173 run : OBSERVABLE_MODE=true npx vitest --retry 1 test/cdk-basic.test.ts
8274
8375 test-sls-basic :
84- needs :
85- - build
8676 runs-on : ubuntu-latest
8777 concurrency :
8878 group : test-sls-basic
@@ -95,10 +85,23 @@ jobs:
9585 registry-url : " https://registry.npmjs.org"
9686 - name : Install dependencies
9787 run : npm ci
98- - uses : actions/download-artifact@v4
88+ - name : Download build artifact
89+ uses : actions/download-artifact@v4
90+ if : ${{ inputs.mode == 'build' }}
9991 with :
10092 name : dist
10193 path : dist
94+ - name : Install lambda-live-debugger globally
95+ if : ${{ inputs.mode == 'global' }}
96+ run : |
97+ npm i lambda-live-debugger -g
98+ 99+ working-directory : test
100+ - name : Install lambda-live-debugger locally
101+ if : ${{ inputs.mode == 'local' }}
102+ run : |
103+ npm i lambda-live-debugger
104+ working-directory : test
102105 - name : Configure AWS Credentials
103106 uses : aws-actions/configure-aws-credentials@v4
104107 with :
@@ -118,8 +121,6 @@ jobs:
118121 run : OBSERVABLE_MODE=true npx vitest --retry 1 test/sls-basic.test.ts
119122
120123 test-sls-esbuild-cjs :
121- needs :
122- - build
123124 runs-on : ubuntu-latest
124125 concurrency :
125126 group : test-sls-esbuild-cjs
@@ -132,10 +133,23 @@ jobs:
132133 registry-url : " https://registry.npmjs.org"
133134 - name : Install dependencies
134135 run : npm ci
135- - uses : actions/download-artifact@v4
136+ - name : Download build artifact
137+ uses : actions/download-artifact@v4
138+ if : ${{ inputs.mode == 'build' }}
136139 with :
137140 name : dist
138141 path : dist
142+ - name : Install lambda-live-debugger globally
143+ if : ${{ inputs.mode == 'global' }}
144+ run : |
145+ npm i lambda-live-debugger -g
146+ 147+ working-directory : test
148+ - name : Install lambda-live-debugger locally
149+ if : ${{ inputs.mode == 'local' }}
150+ run : |
151+ npm i lambda-live-debugger
152+ working-directory : test
139153 - name : Configure AWS Credentials
140154 uses : aws-actions/configure-aws-credentials@v4
141155 with :
@@ -155,8 +169,6 @@ jobs:
155169 run : OBSERVABLE_MODE=true npx vitest --retry 1 test/sls-esbuild-cjs.test.ts
156170
157171 test-sls-esbuild-esm :
158- needs :
159- - build
160172 runs-on : ubuntu-latest
161173 concurrency :
162174 group : test-sls-esbuild-esm
@@ -169,10 +181,23 @@ jobs:
169181 registry-url : " https://registry.npmjs.org"
170182 - name : Install dependencies
171183 run : npm ci
172- - uses : actions/download-artifact@v4
184+ - name : Download build artifact
185+ uses : actions/download-artifact@v4
186+ if : ${{ inputs.mode == 'build' }}
173187 with :
174188 name : dist
175189 path : dist
190+ - name : Install lambda-live-debugger globally
191+ if : ${{ inputs.mode == 'global' }}
192+ run : |
193+ npm i lambda-live-debugger -g
194+ 195+ working-directory : test
196+ - name : Install lambda-live-debugger locally
197+ if : ${{ inputs.mode == 'local' }}
198+ run : |
199+ npm i lambda-live-debugger
200+ working-directory : test
176201 - name : Configure AWS Credentials
177202 uses : aws-actions/configure-aws-credentials@v4
178203 with :
@@ -192,8 +217,6 @@ jobs:
192217 run : OBSERVABLE_MODE=true npx vitest --retry 1 test/sls-esbuild-esm.test.ts
193218
194219 test-sam-basic :
195- needs :
196- - build
197220 runs-on : ubuntu-latest
198221 concurrency :
199222 group : test-sam-basic
@@ -210,10 +233,22 @@ jobs:
210233 registry-url : " https://registry.npmjs.org"
211234 - name : Install dependencies
212235 run : npm ci
213- - uses : actions/download-artifact@v4
236+ - name : Download build artifact
237+ uses : actions/download-artifact@v4
238+ if : ${{ inputs.mode == 'build' }}
214239 with :
215240 name : dist
216241 path : dist
242+ - name : Install lambda-live-debugger globally
243+ if : ${{ inputs.mode == 'global' }}
244+ run : |
245+ npm i lambda-live-debugger -g
246+ working-directory : test
247+ - name : Install lambda-live-debugger locally
248+ if : ${{ inputs.mode == 'local' }}
249+ run : |
250+ npm i lambda-live-debugger
251+ working-directory : test
217252 - name : Configure AWS Credentials
218253 uses : aws-actions/configure-aws-credentials@v4
219254 with :
@@ -233,8 +268,6 @@ jobs:
233268 run : OBSERVABLE_MODE=true npx vitest --retry 1 test/sam-basic.test.ts
234269
235270 test-terraform-basic :
236- needs :
237- - build
238271 runs-on : ubuntu-latest
239272 concurrency :
240273 group : test-terraform-basic
@@ -247,10 +280,22 @@ jobs:
247280 registry-url : " https://registry.npmjs.org"
248281 - name : Install dependencies
249282 run : npm ci
250- - uses : actions/download-artifact@v4
283+ - name : Download build artifact
284+ uses : actions/download-artifact@v4
285+ if : ${{ inputs.mode == 'build' }}
251286 with :
252287 name : dist
253288 path : dist
289+ - name : Install lambda-live-debugger globally
290+ if : ${{ inputs.mode == 'global' }}
291+ run : |
292+ npm i lambda-live-debugger -g
293+ working-directory : test
294+ - name : Install lambda-live-debugger locally
295+ if : ${{ inputs.mode == 'local' }}
296+ run : |
297+ npm i lambda-live-debugger
298+ working-directory : test
254299 - name : Configure AWS Credentials
255300 uses : aws-actions/configure-aws-credentials@v4
256301 with :
@@ -275,37 +320,3 @@ jobs:
275320 run : npx vitest --retry 1 test/terraform-basic.test.ts
276321 - name : Test - observable mode
277322 run : OBSERVABLE_MODE=true npx vitest --retry 1 test/terraform-basic.test.ts
278-
279- publish :
280- needs :
281- - test-cdk-basic
282- - test-sls-basic
283- - test-sls-esbuild-cjs
284- - test-sls-esbuild-esm
285- - test-sam-basic
286- - test-terraform-basic
287- if : github.event_name == 'workflow_dispatch'
288- runs-on : ubuntu-latest
289- concurrency :
290- group : publish
291- steps :
292- - uses : actions/checkout@v4
293- - name : Use Node.js
294- uses : actions/setup-node@v4
295- with :
296- node-version : ${{ env.node_version }}
297- registry-url : " https://registry.npmjs.org"
298- - name : Install dependencies
299- run : npm ci
300- - uses : actions/download-artifact@v4
301- with :
302- name : dist
303- path : dist
304- - name : Semantic Release
305- run : |
306- npm whoami
307- npx semantic-release
308- env :
309- GITHUB_TOKEN : ${{ secrets.PRIVATE_GITHUB_TOKEN }}
310- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
311- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments