Use all available CPUs to run tests on CI (#6138)
* Use all available CPUs to run tests on CI * Use less than 100% based on research * Ensure proper types for worker value
This commit is contained in:
18
Makefile
18
Makefile
@ -87,7 +87,7 @@ lint: install ## Lint the code
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# RUN
|
# RUN
|
||||||
|
|
||||||
TARGET ?= web
|
TARGET ?= desktop
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: run-$(TARGET)
|
run: run-$(TARGET)
|
||||||
@ -103,9 +103,9 @@ run-desktop: install build-desktop ## Start the desktop app
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# TEST
|
# TEST
|
||||||
|
|
||||||
E2E_WORKERS ?= 1
|
E2E_GREP ?=
|
||||||
|
E2E_WORKERS ?=
|
||||||
E2E_FAILURES ?= 1
|
E2E_FAILURES ?= 1
|
||||||
E2E_GREP ?= ""
|
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: test-unit test-e2e
|
test: test-unit test-e2e
|
||||||
@ -121,11 +121,19 @@ test-e2e: test-e2e-$(TARGET)
|
|||||||
.PHONY: test-e2e-web
|
.PHONY: test-e2e-web
|
||||||
test-e2e-web: install build-web ## Run the web e2e tests
|
test-e2e-web: install build-web ## Run the web e2e tests
|
||||||
@ curl -fs localhost:3000 >/dev/null || ( echo "Error: localhost:3000 not available, 'make run-web' first" && exit 1 )
|
@ curl -fs localhost:3000 >/dev/null || ( echo "Error: localhost:3000 not available, 'make run-web' first" && exit 1 )
|
||||||
yarn chrome:test --headed --workers=$(E2E_WORKERS) --max-failures=$(E2E_FAILURES) --grep=$(E2E_GREP)
|
ifdef E2E_GREP
|
||||||
|
yarn chrome:test --headed --grep="$(E2E_GREP)" --max-failures=$(E2E_FAILURES)
|
||||||
|
else
|
||||||
|
yarn chrome:test --headed --workers='100%'
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: test-e2e-desktop
|
.PHONY: test-e2e-desktop
|
||||||
test-e2e-desktop: install build-desktop ## Run the desktop e2e tests
|
test-e2e-desktop: install build-desktop ## Run the desktop e2e tests
|
||||||
yarn test:playwright:electron --workers=$(E2E_WORKERS) --max-failures=$(E2E_FAILURES) --grep="$(E2E_GREP)"
|
ifdef E2E_GREP
|
||||||
|
yarn test:playwright:electron --grep="$(E2E_GREP)" --max-failures=$(E2E_FAILURES)
|
||||||
|
else
|
||||||
|
yarn test:playwright:electron --workers='100%'
|
||||||
|
endif
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# CLEAN
|
# CLEAN
|
||||||
|
@ -1,10 +1,29 @@
|
|||||||
import { defineConfig, devices } from '@playwright/test'
|
import { defineConfig, devices } from '@playwright/test'
|
||||||
|
import os from 'os'
|
||||||
|
|
||||||
/**
|
const platform = os.platform() // 'linux' (Ubuntu), 'darwin' (macOS), 'win32' (Windows)
|
||||||
* Read environment variables from file.
|
|
||||||
* https://github.com/motdotla/dotenv
|
let workers: number | string
|
||||||
*/
|
|
||||||
// require('dotenv').config();
|
if (process.env.E2E_WORKERS) {
|
||||||
|
workers = process.env.E2E_WORKERS.includes('%')
|
||||||
|
? process.env.E2E_WORKERS
|
||||||
|
: parseInt(process.env.E2E_WORKERS)
|
||||||
|
} else if (!process.env.CI) {
|
||||||
|
workers = 1 // Local dev: keep things simple and deterministic by default
|
||||||
|
} else {
|
||||||
|
// On CI: adjust based on OS
|
||||||
|
switch (platform) {
|
||||||
|
case 'linux':
|
||||||
|
workers = '100%' // CI Linux runners are generally beefier
|
||||||
|
break
|
||||||
|
case 'darwin':
|
||||||
|
case 'win32':
|
||||||
|
default:
|
||||||
|
workers = '75%' // Slightly conservative for GUI-based OSes
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See https://playwright.dev/docs/test-configuration.
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
@ -19,8 +38,8 @@ export default defineConfig({
|
|||||||
forbidOnly: !!process.env.CI,
|
forbidOnly: !!process.env.CI,
|
||||||
/* Do not retry */
|
/* Do not retry */
|
||||||
retries: process.env.CI ? 0 : 0,
|
retries: process.env.CI ? 0 : 0,
|
||||||
/* Different amount of parallelism on CI and local. */
|
/* Use all available CPU cores */
|
||||||
workers: process.env.CI ? 1 : 4,
|
workers: workers,
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: [
|
reporter: [
|
||||||
[process.env.CI ? 'dot' : 'list'],
|
[process.env.CI ? 'dot' : 'list'],
|
||||||
|
@ -1,5 +1,29 @@
|
|||||||
import { defineConfig, devices } from '@playwright/test'
|
import { defineConfig, devices } from '@playwright/test'
|
||||||
import { platform } from 'os'
|
import os from 'os'
|
||||||
|
|
||||||
|
const platform = os.platform() // 'linux' (Ubuntu), 'darwin' (macOS), 'win32' (Windows)
|
||||||
|
|
||||||
|
let workers: number | string
|
||||||
|
|
||||||
|
if (process.env.E2E_WORKERS) {
|
||||||
|
workers = process.env.E2E_WORKERS.includes('%')
|
||||||
|
? process.env.E2E_WORKERS
|
||||||
|
: parseInt(process.env.E2E_WORKERS)
|
||||||
|
} else if (!process.env.CI) {
|
||||||
|
workers = 1 // Local dev: keep things simple and deterministic by default
|
||||||
|
} else {
|
||||||
|
// On CI: adjust based on OS
|
||||||
|
switch (platform) {
|
||||||
|
case 'linux':
|
||||||
|
workers = '50%' // CI Linux runners are generally beefier
|
||||||
|
break
|
||||||
|
case 'darwin':
|
||||||
|
case 'win32':
|
||||||
|
default:
|
||||||
|
workers = '25%' // Lower concurrency for heavier Electron processes
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See https://playwright.dev/docs/test-configuration.
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
@ -14,8 +38,8 @@ export default defineConfig({
|
|||||||
forbidOnly: true,
|
forbidOnly: true,
|
||||||
/* Do not retry */
|
/* Do not retry */
|
||||||
retries: 0,
|
retries: 0,
|
||||||
/* Different amount of parallelism on CI and local. */
|
/* Use all available CPU cores */
|
||||||
workers: platform() === 'win32' ? 1 : 2,
|
workers: workers,
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: [
|
reporter: [
|
||||||
['dot'],
|
['dot'],
|
||||||
|
Reference in New Issue
Block a user