Skip to content

Commit 203dab3

Browse files
fix: CICD tests
1 parent e0b933a commit 203dab3

File tree

4 files changed

+58
-13
lines changed

4 files changed

+58
-13
lines changed

.github/workflows/common-test.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ jobs:
3737
node-version: ${{ env.node_version }}
3838
registry-url: 'https://registry.npmjs.org'
3939
- name: Install dependencies
40-
run: npm ci
40+
run: |
41+
node prepareForTest.js cdk-basic
42+
npm i
4143
- name: Download build artifact
4244
uses: actions/download-artifact@v4
4345
if: ${{ inputs.mode == 'build' }}
@@ -84,7 +86,9 @@ jobs:
8486
node-version: ${{ env.node_version }}
8587
registry-url: 'https://registry.npmjs.org'
8688
- name: Install dependencies
87-
run: npm ci
89+
run: |
90+
node prepareForTest.js cdk-esm
91+
npm i
8892
- name: Download build artifact
8993
uses: actions/download-artifact@v4
9094
if: ${{ inputs.mode == 'build' }}
@@ -131,7 +135,9 @@ jobs:
131135
node-version: ${{ env.node_version }}
132136
registry-url: 'https://registry.npmjs.org'
133137
- name: Install dependencies
134-
run: npm ci
138+
run: |
139+
node prepareForTest.js sls-basic
140+
npm i
135141
- name: Download build artifact
136142
uses: actions/download-artifact@v4
137143
if: ${{ inputs.mode == 'build' }}
@@ -179,7 +185,9 @@ jobs:
179185
node-version: ${{ env.node_version }}
180186
registry-url: 'https://registry.npmjs.org'
181187
- name: Install dependencies
182-
run: npm ci
188+
run: |
189+
node prepareForTest.js sls-esbuild-cjs
190+
npm i
183191
- name: Download build artifact
184192
uses: actions/download-artifact@v4
185193
if: ${{ inputs.mode == 'build' }}
@@ -227,7 +235,9 @@ jobs:
227235
node-version: ${{ env.node_version }}
228236
registry-url: 'https://registry.npmjs.org'
229237
- name: Install dependencies
230-
run: npm ci
238+
run: |
239+
node prepareForTest.js sls-esbuild-esm
240+
npm i
231241
- name: Download build artifact
232242
uses: actions/download-artifact@v4
233243
if: ${{ inputs.mode == 'build' }}
@@ -275,9 +285,9 @@ jobs:
275285
node-version: ${{ env.node_version }}
276286
registry-url: 'https://registry.npmjs.org'
277287
- name: Install dependencies
278-
run: npm ci
279-
- name: Uninstall serverless
280-
run: npm uninstall serverless
288+
run: |
289+
node prepareForTest.js osls-basic
290+
npm i
281291
- name: Download build artifact
282292
uses: actions/download-artifact@v4
283293
if: ${{ inputs.mode == 'build' }}
@@ -329,7 +339,9 @@ jobs:
329339
node-version: ${{ env.node_version }}
330340
registry-url: 'https://registry.npmjs.org'
331341
- name: Install dependencies
332-
run: npm ci
342+
run: |
343+
node prepareForTest.js sam-basic
344+
npm i
333345
- name: Download build artifact
334346
uses: actions/download-artifact@v4
335347
if: ${{ inputs.mode == 'build' }}
@@ -380,7 +392,9 @@ jobs:
380392
node-version: ${{ env.node_version }}
381393
registry-url: 'https://registry.npmjs.org'
382394
- name: Install dependencies
383-
run: npm ci
395+
run: |
396+
node prepareForTest.js sam-alt
397+
npm i
384398
- name: Download build artifact
385399
uses: actions/download-artifact@v4
386400
if: ${{ inputs.mode == 'build' }}
@@ -427,7 +441,9 @@ jobs:
427441
node-version: ${{ env.node_version }}
428442
registry-url: 'https://registry.npmjs.org'
429443
- name: Install dependencies
430-
run: npm ci
444+
run: |
445+
node prepareForTest.js terraform-basic
446+
npm i
431447
- name: Download build artifact
432448
uses: actions/download-artifact@v4
433449
if: ${{ inputs.mode == 'build' }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This tool offers similar functionality to [SST](https://sst.dev/) and [Serverles
77
It supports the following frameworks:
88

99
- AWS CDK v2
10-
- Serverless Framework v3 (SLS)
10+
- Serverless Framework v3 (SLS) and [`osls` fork](https://github.com/oss-serverless/serverless)
1111
- AWS Serverless Application Model (SAM)
1212
- Terraform
1313
- Any other framework or setup by implementing a simple function in TypeScript

prepareForTest.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { readFile, writeFile } from 'fs/promises';
2+
import { argv } from 'process';
3+
4+
async function modifyPackageJson(testCase) {
5+
const filePath = 'package.json';
6+
7+
const data = await readFile(filePath, 'utf-8');
8+
const packageJson = JSON.parse(data);
9+
10+
// Delete scripts and devDependencies nodes
11+
delete packageJson.scripts;
12+
delete packageJson.devDependencies;
13+
14+
// Replace workspaces node with specified values
15+
packageJson.workspaces = ['test', `test/${testCase}`];
16+
17+
// Write the modified package.json back to the file
18+
await writeFile(filePath, JSON.stringify(packageJson, null, 2), 'utf-8');
19+
console.log(`Modified ${filePath} successfully!`);
20+
}
21+
22+
// Run the function with the provided file path and argument
23+
const [testCase] = argv.slice(1);
24+
if (!testCase) {
25+
console.error('Usage: node prepareForTest.js <workspace-arg>');
26+
process.exit(1);
27+
}
28+
29+
modifyPackageJson(filePath, testCase);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"outDir": "./dist"
77
},
88
"include": ["src/**/*", "test/**/*", "*.*", ".vitepress/**/*"],
9-
"exclude": ["node_modules", "dist"]
9+
"exclude": ["node_modules", "dist", "prepareForTest.js"]
1010
}

0 commit comments

Comments
 (0)