Skip to content

Commit 25634b0

Browse files
authored
test(): test dynamic max workers and improve CI (medusajs#13516)
* test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * test(): test dynamic max workers * Clarify test description and improve CI
1 parent b6d96a1 commit 25634b0

File tree

47 files changed

+131
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+131
-113
lines changed

.changeset/lucky-shrimps-hang.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
"@medusajs/medusa": patch
3+
"@medusajs/analytics": patch
4+
"@medusajs/api-key": patch
5+
"@medusajs/auth": patch
6+
"@medusajs/cart": patch
7+
"@medusajs/currency": patch
8+
"@medusajs/customer": patch
9+
"@medusajs/event-bus-local": patch
10+
"@medusajs/event-bus-redis": patch
11+
"@medusajs/file": patch
12+
"@medusajs/fulfillment": patch
13+
"@medusajs/index": patch
14+
"@medusajs/inventory": patch
15+
"@medusajs/link-modules": patch
16+
"@medusajs/core-flows": patch
17+
"@medusajs/framework": patch
18+
"@medusajs/js-sdk": patch
19+
"@medusajs/modules-sdk": patch
20+
"@medusajs/orchestration": patch
21+
"@medusajs/utils": patch
22+
"@medusajs/workflows-sdk": patch
23+
---
24+
25+
test(): test dynamic max workers and improve CI
26+

.github/actions/cache-deps/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ inputs:
66
runs:
77
using: composite
88
steps:
9-
- uses: actions/cache@v3
9+
- uses: actions/cache@v4
1010
id: cache
1111
with:
1212
path: |
@@ -15,7 +15,7 @@ runs:
1515
restore-keys: |
1616
${{ runner.os }}-yarn-${{inputs.extension}}-v8-3
1717
# We want to only bootstrap and install if no cache is found.
18-
- run: yarn install --immutable
18+
- run: yarn install --immutable --inline-builds
1919
shell: bash
2020

2121
- run: yarn build

.github/workflows/action.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ jobs:
2222
access_token: ${{ github.token }}
2323

2424
- name: Checkout
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2626
with:
2727
fetch-depth: 0
2828

2929
- name: Setup Node.js environment
3030
uses: actions/setup-node@v4
3131
with:
3232
node-version: 20
33-
cache: "yarn"
3433

3534
- name: Assert changed
3635
run: ./scripts/assert-changed-files-actions.sh "packages"
@@ -50,20 +49,21 @@ jobs:
5049
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
5150
steps:
5251
- name: Checkout
53-
uses: actions/checkout@v3
52+
uses: actions/checkout@v4
5453
with:
55-
fetch-depth: 0
54+
fetch-depth: 100
5655

57-
- name: Assert changed
58-
run: ./scripts/assert-changed-files-actions.sh "packages"
56+
- name: Get number of CPU cores
57+
id: cpu-cores
58+
uses: SimenB/github-actions-cpu-cores@v2
5959

6060
- name: Install dependencies
6161
uses: ./.github/actions/cache-deps
6262
with:
6363
extension: pipeline
6464

6565
- name: Run unit tests
66-
run: yarn test:chunk
66+
run: yarn test:chunk -- --maxWorkers=${{ steps.cpu-cores.outputs.count }}
6767

6868
integration-tests-packages-matrix:
6969
needs: setup
@@ -102,17 +102,21 @@ jobs:
102102

103103
steps:
104104
- name: Checkout
105-
uses: actions/checkout@v3
105+
uses: actions/checkout@v4
106106
with:
107-
fetch-depth: 0
107+
fetch-depth: 100
108+
109+
- name: Get number of CPU cores
110+
id: cpu-cores
111+
uses: SimenB/github-actions-cpu-cores@v2
108112

109113
- name: Install dependencies
110114
uses: ./.github/actions/cache-deps
111115
with:
112116
extension: pipeline
113117

114118
- name: Run integration tests
115-
run: yarn test:integration:packages:${{ matrix.group }}
119+
run: yarn test:integration:packages:${{ matrix.group }} -- --maxWorkers=${{ steps.cpu-cores.outputs.count }}
116120
env:
117121
DB_PASSWORD: postgres
118122
DB_USERNAME: postgres
@@ -169,17 +173,21 @@ jobs:
169173

170174
steps:
171175
- name: Checkout
172-
uses: actions/checkout@v3
176+
uses: actions/checkout@v4
173177
with:
174-
fetch-depth: 0
178+
fetch-depth: 100
179+
180+
- name: Get number of CPU cores
181+
id: cpu-cores
182+
uses: SimenB/github-actions-cpu-cores@v2
175183

176184
- name: Install dependencies
177185
uses: ./.github/actions/cache-deps
178186
with:
179187
extension: pipeline
180188

181189
- name: Run HTTP integration tests
182-
run: yarn test:integration:http -- --shard=${{ matrix.shard_index }}/3
190+
run: yarn test:integration:http -- --shard=${{ matrix.shard_index }}/3 --maxWorkers=${{ steps.cpu-cores.outputs.count }}
183191
env:
184192
DB_USERNAME: postgres
185193
DB_PASSWORD: postgres
@@ -236,17 +244,21 @@ jobs:
236244

237245
steps:
238246
- name: Checkout
239-
uses: actions/checkout@v3
247+
uses: actions/checkout@v4
240248
with:
241-
fetch-depth: 0
249+
fetch-depth: 100
250+
251+
- name: Get number of CPU cores
252+
id: cpu-cores
253+
uses: SimenB/github-actions-cpu-cores@v2
242254

243255
- name: Install dependencies
244256
uses: ./.github/actions/cache-deps
245257
with:
246258
extension: pipeline
247259

248260
- name: Run Modules integration tests
249-
run: yarn test:integration:modules -- --shard=${{ matrix.shard_index }}/3
261+
run: yarn test:integration:modules -- --shard=${{ matrix.shard_index }}/3 --maxWorkers=${{ steps.cpu-cores.outputs.count }}
250262
env:
251263
DB_USERNAME: postgres
252264
DB_PASSWORD: postgres

.github/workflows/test-cli-with-database.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,46 @@ jobs:
1010
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
1111
REDIS_URL: redis://localhost:6379
1212
DATABASE_URL: "postgres://postgres:postgres@localhost/cli-test"
13+
NPM_CONFIG_LOGLEVEL: error
14+
NPM_CONFIG_AUDIT: false
15+
NPM_CONFIG_FUND: false
16+
NPM_CONFIG_UPDATE_NOTIFIER: false
1317
services:
1418
redis:
1519
image: redis
1620
options: >-
1721
--health-cmd "redis-cli ping"
18-
--health-interval 10s
19-
--health-timeout 5s
20-
--health-retries 5
22+
--health-interval 1s
23+
--health-timeout 10s
24+
--health-retries 10
2125
ports:
2226
- 6379:6379
2327

2428
postgres:
25-
image: postgres
29+
image: postgres:15-alpine
2630
env:
2731
POSTGRES_PASSWORD: postgres
2832
POSTGRES_USER: postgres
2933
POSTGRES_DB: cli-test
3034
options: >-
3135
--health-cmd pg_isready
32-
--health-interval 10s
33-
--health-timeout 5s
34-
--health-retries 5
36+
--health-interval 1s
37+
--health-timeout 10s
38+
--health-retries 10
3539
ports:
3640
- 5432:5432
3741

3842
runs-on: ubuntu-latest
3943
steps:
4044
- name: Checkout
41-
uses: actions/checkout@v3
45+
uses: actions/checkout@v4
4246
with:
43-
fetch-depth: 0
47+
fetch-depth: 100
4448

4549
- name: Setup Node.js environment
4650
uses: actions/setup-node@v4
4751
with:
4852
node-version: 20
49-
cache: "yarn"
5053

5154
- name: Install dependencies
5255
uses: ./.github/actions/cache-deps
@@ -65,7 +68,7 @@ jobs:
6568
run: corepack enable
6669

6770
- name: Install new app dependencies (via resolutions)
68-
run: rm -f package-lock.json && yarn install --no-immutable
71+
run: rm -f package-lock.json && yarn install --inline-builds --silent
6972
env:
7073
YARN_ENABLE_IMMUTABLE_INSTALLS: false
7174
working-directory: ../cli-test

integration-tests/api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": "MIT",
66
"private": true,
77
"scripts": {
8-
"test:integration": "jest --silent=false --no-cache --maxWorkers=50% --bail --detectOpenHandles --forceExit --logHeapUsage",
9-
"test:integration:chunk": "jest --silent --no-cache --bail --maxWorkers=50% --forceExit --detectOpenHandles --testPathPattern=$(echo $CHUNKS | jq -r \".[${CHUNK}] | .[]\")",
8+
"test:integration": "jest --silent=false --no-cache --bail --detectOpenHandles --forceExit --logHeapUsage",
9+
"test:integration:chunk": "jest --silent --no-cache --bail --forceExit --detectOpenHandles --testPathPattern=$(echo $CHUNKS | jq -r \".[${CHUNK}] | .[]\")",
1010
"build": "tsc ./src/* --allowJs --outDir ./dist"
1111
},
1212
"dependencies": {

integration-tests/http/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": "MIT",
66
"private": true,
77
"scripts": {
8-
"test:integration": "jest --no-cache --maxWorkers=50% --bail --detectOpenHandles --forceExit --logHeapUsage",
9-
"test:integration:chunk": "jest --silent --no-cache --bail --maxWorkers=50% --forceExit",
8+
"test:integration": "jest --no-cache --bail --detectOpenHandles --forceExit --logHeapUsage",
9+
"test:integration:chunk": "jest --silent --no-cache --bail --forceExit",
1010
"build": "tsc --allowJs --outDir ./dist"
1111
},
1212
"dependencies": {

integration-tests/modules/__tests__/index/query-index.spec.ts

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async function populateData(api: any) {
9191
)
9292
const products = response.data.created
9393

94-
await setTimeout(10000)
94+
await setTimeout(5000)
9595

9696
return products
9797
}
@@ -144,6 +144,8 @@ medusaIntegrationTestRunner({
144144
},
145145
})
146146

147+
await setTimeout(1000)
148+
147149
const query = appContainer.resolve(
148150
ContainerRegistrationKeys.QUERY
149151
) as RemoteQueryFunction
@@ -200,11 +202,7 @@ medusaIntegrationTestRunner({
200202
},
201203
},
202204
}),
203-
({ data }) => data.length > 0,
204-
{
205-
retries: 3,
206-
waitSeconds: 3,
207-
}
205+
({ data }) => data.length > 0
208206
)
209207

210208
expect(resultset.metadata).toEqual({
@@ -366,11 +364,7 @@ medusaIntegrationTestRunner({
366364
},
367365
},
368366
}),
369-
({ data }) => data.length > 0,
370-
{
371-
retries: 3,
372-
waitSeconds: 3,
373-
}
367+
({ data }) => data.length > 0
374368
)
375369

376370
// Limiting to 1 on purpose to keep it simple and check the correct order is maintained
@@ -424,11 +418,7 @@ medusaIntegrationTestRunner({
424418
},
425419
},
426420
}),
427-
({ data }) => data.length > 0,
428-
{
429-
retries: 3,
430-
waitSeconds: 3,
431-
}
421+
({ data }) => data.length > 0
432422
)
433423

434424
// Limiting to 1 on purpose to keep it simple and check the correct order is maintained
@@ -478,11 +468,7 @@ medusaIntegrationTestRunner({
478468
},
479469
},
480470
}),
481-
({ data }) => data.length > 0,
482-
{
483-
retries: 3,
484-
waitSeconds: 3,
485-
}
471+
({ data }) => data.length > 0
486472
)
487473

488474
expect(resultset.data.length).toEqual(2)
@@ -504,11 +490,7 @@ medusaIntegrationTestRunner({
504490
origin_country: ["USA"],
505491
},
506492
}),
507-
({ data }) => data.length > 0,
508-
{
509-
retries: 3,
510-
waitSeconds: 3,
511-
}
493+
({ data }) => data.length > 0
512494
)
513495

514496
expect(resultset.data.length).toEqual(1)
@@ -533,6 +515,8 @@ medusaIntegrationTestRunner({
533515
},
534516
})
535517

518+
await setTimeout(1000)
519+
536520
const query = appContainer.resolve(
537521
ContainerRegistrationKeys.QUERY
538522
) as RemoteQueryFunction
@@ -551,8 +535,8 @@ medusaIntegrationTestRunner({
551535
}),
552536
({ data }) => data.length > 0,
553537
{
554-
retries: 3,
555-
waitSeconds: 3,
538+
retries: 5,
539+
waitSeconds: 1.5,
556540
}
557541
)
558542
expect(resultset.data.length).toEqual(1)

integration-tests/modules/__tests__/index/search.spec.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ medusaIntegrationTestRunner({
113113
},
114114
},
115115
}),
116-
({ data }) => data.length > 0,
117-
{
118-
retries: 3,
119-
waitSeconds: 3,
120-
}
116+
({ data }) => data.length > 0
121117
)
122118

123119
expect(results.length).toBe(1)
@@ -171,11 +167,7 @@ medusaIntegrationTestRunner({
171167
},
172168
},
173169
}),
174-
({ data }) => data.length > 0,
175-
{
176-
retries: 3,
177-
waitSeconds: 3,
178-
}
170+
({ data }) => data.length > 0
179171
)
180172

181173
expect(results.length).toBe(1)

integration-tests/modules/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": "MIT",
66
"private": true,
77
"scripts": {
8-
"test:integration": "jest --no-cache --maxWorkers=50% --bail --detectOpenHandles --forceExit --logHeapUsage",
9-
"test:integration:chunk": "jest --silent --no-cache --bail --maxWorkers=50% --forceExit",
8+
"test:integration": "jest --no-cache --bail --detectOpenHandles --forceExit --logHeapUsage",
9+
"test:integration:chunk": "jest --silent --no-cache --bail --forceExit",
1010
"build": "tsc --allowJs --outDir ./dist"
1111
},
1212
"dependencies": {

packages/core/core-flows/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@
5252
"scripts": {
5353
"build": "rimraf dist && tsc --build",
5454
"watch": "tsc --build --watch",
55-
"test": "jest --runInBand --bail --forceExit --passWithNoTests"
55+
"test": "jest --bail --forceExit --passWithNoTests"
5656
}
5757
}

0 commit comments

Comments
 (0)