[Bug] Use silent mode during tests (unless debugging!) + test workflow optimization (#4154)
* add :silent to all tests but disable it if the runner is in debug mode! * fix: use `--silent` instead of `:silent` Cause the previous was npm scrpt specific (whops) * remove env and replace with logic in each call * reduce redundancy by checking out once * move pre-test into `needs` after `checkout` * use cache approach in pre-test * add node.js install step to `setup` job * WIP: setup -> pre-test -> all other tests with using cache * use matrix approach for tests * fix matrix approach for tests * fix wrong use of env var in `run-test-template.yml` * test: out-comment `run-tests` to see whats wrong * test: see if this works * let's try using matrix again... * make `node-version` input a string * remove `node-version` input for now * test: without a matrix fornow * change usage of reuseable workflow call * fix call of matrix.project * try using working-dir * try setup for pre-tests * remove `runs-on` from run-tests * fix some identations for run-tests * add pre-test as requirement for running tests * use `1` instead of `'1'` to check `runner.debug` * add `options` input. Possible fix for debug = not silent * try again... * not as an ENV but inside * move 2nd ${{ !runner.debug && '--silent' }} check into test-template * fix printing `false` instead of empty-string on runner-debug check * try a yml array approach * test running with file include path * make `project` always `main` for now * remove all extra vitest workspaces * adopt `shards` workflow in vitest * fix workflow reference in tests.yml * add missing `$` in test-shard-template.yml` * chore: fix vitest.config.ts after merge man.. cant trust these machines * make `project` a variable. try to use inputs on job names * adjust `test-shard-template` job name
This commit is contained in:
parent
14ace40634
commit
e17bf592c2
|
@ -0,0 +1,30 @@
|
||||||
|
name: Test Template
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
project:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
shard:
|
||||||
|
required: true
|
||||||
|
type: number
|
||||||
|
totalShards:
|
||||||
|
required: true
|
||||||
|
type: number
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Shard ${{ inputs.shard }} of ${{ inputs.totalShards }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out Git repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
- name: Install Node.js dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Run tests
|
||||||
|
run: npx vitest --project ${{ inputs.project }} --shard=${{ inputs.shard }}/${{ inputs.totalShards }} ${{ !runner.debug && '--silent' || '' }}
|
|
@ -15,91 +15,33 @@ on:
|
||||||
types: [checks_requested]
|
types: [checks_requested]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run-misc-tests: # Define a job named "run-tests"
|
pre-test:
|
||||||
name: Run misc tests # Human-readable name for the job
|
name: Run Pre-test
|
||||||
runs-on: ubuntu-latest # Specify the latest Ubuntu runner for the job
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out Git repository # Step to check out the repository
|
|
||||||
uses: actions/checkout@v4 # Use the checkout action version 4
|
|
||||||
|
|
||||||
- name: Set up Node.js # Step to set up Node.js environment
|
|
||||||
uses: actions/setup-node@v4 # Use the setup-node action version 4
|
|
||||||
with:
|
|
||||||
node-version: 20 # Specify Node.js version 20
|
|
||||||
|
|
||||||
- name: Install Node.js dependencies # Step to install Node.js dependencies
|
|
||||||
run: npm ci # Use 'npm ci' to install dependencies
|
|
||||||
|
|
||||||
- name: pre-test # pre-test to check overrides
|
|
||||||
run: npx vitest run --project pre
|
|
||||||
- name: test misc
|
|
||||||
run: npx vitest --project misc
|
|
||||||
|
|
||||||
run-abilities-tests:
|
|
||||||
name: Run abilities tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out Git repository
|
- name: Check out Git repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: tests-action
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
- name: Install Node.js dependencies
|
- name: Install Node.js dependencies
|
||||||
|
working-directory: tests-action
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: pre-test
|
- name: Run Pre-test
|
||||||
run: npx vitest run --project pre
|
working-directory: tests-action
|
||||||
- name: test abilities
|
run: npx vitest run --project pre ${{ !runner.debug && '--silent' || '' }}
|
||||||
run: npx vitest --project abilities
|
|
||||||
|
|
||||||
run-items-tests:
|
run-tests:
|
||||||
name: Run items tests
|
name: Run Tests
|
||||||
runs-on: ubuntu-latest
|
needs: [pre-test]
|
||||||
steps:
|
strategy:
|
||||||
- name: Check out Git repository
|
matrix:
|
||||||
uses: actions/checkout@v4
|
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
- name: Set up Node.js
|
uses: ./.github/workflows/test-shard-template.yml
|
||||||
uses: actions/setup-node@v4
|
with:
|
||||||
with:
|
project: main
|
||||||
node-version: 20
|
shard: ${{ matrix.shard }}
|
||||||
- name: Install Node.js dependencies
|
totalShards: 10
|
||||||
run: npm ci
|
|
||||||
- name: pre-test
|
|
||||||
run: npx vitest run --project pre
|
|
||||||
- name: test items
|
|
||||||
run: npx vitest --project items
|
|
||||||
|
|
||||||
run-moves-tests:
|
|
||||||
name: Run moves tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out Git repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
- name: Install Node.js dependencies
|
|
||||||
run: npm ci
|
|
||||||
- name: pre-test
|
|
||||||
run: npx vitest run --project pre
|
|
||||||
- name: test moves
|
|
||||||
run: npx vitest --project moves
|
|
||||||
|
|
||||||
run-battle-tests:
|
|
||||||
name: Run battle tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out Git repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
- name: Install Node.js dependencies
|
|
||||||
run: npm ci
|
|
||||||
- name: pre-test
|
|
||||||
run: npx vitest run --project pre
|
|
||||||
- name: test battle
|
|
||||||
run: npx vitest --project battle
|
|
|
@ -1,46 +1,42 @@
|
||||||
import { defineProject, UserWorkspaceConfig } from 'vitest/config';
|
import { defineProject } from "vitest/config";
|
||||||
import { defaultConfig } from './vite.config';
|
import { defaultConfig } from "./vite.config";
|
||||||
|
|
||||||
export const defaultProjectTestConfig: UserWorkspaceConfig["test"] = {
|
|
||||||
setupFiles: ['./src/test/fontFace.setup.ts', './src/test/vitest.setup.ts'],
|
|
||||||
server: {
|
|
||||||
deps: {
|
|
||||||
inline: ['vitest-canvas-mock'],
|
|
||||||
//@ts-ignore
|
|
||||||
optimizer: {
|
|
||||||
web: {
|
|
||||||
include: ['vitest-canvas-mock'],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
environment: 'jsdom' as const,
|
|
||||||
environmentOptions: {
|
|
||||||
jsdom: {
|
|
||||||
resources: 'usable',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
threads: false,
|
|
||||||
trace: true,
|
|
||||||
restoreMocks: true,
|
|
||||||
watch: false,
|
|
||||||
coverage: {
|
|
||||||
provider: 'istanbul' as const,
|
|
||||||
reportsDirectory: 'coverage' as const,
|
|
||||||
reporters: ['text-summary', 'html'],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineProject(({ mode }) => ({
|
export default defineProject(({ mode }) => ({
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
test: {
|
test: {
|
||||||
...defaultProjectTestConfig,
|
setupFiles: ["./src/test/fontFace.setup.ts", "./src/test/vitest.setup.ts"],
|
||||||
name: "main",
|
server: {
|
||||||
include: ["./src/test/**/*.{test,spec}.ts"],
|
deps: {
|
||||||
exclude: ["./src/test/pre.test.ts"],
|
inline: ["vitest-canvas-mock"],
|
||||||
},
|
//@ts-ignore
|
||||||
esbuild: {
|
optimizer: {
|
||||||
pure: mode === 'production' ? [ 'console.log' ] : [],
|
web: {
|
||||||
keepNames: true,
|
include: ["vitest-canvas-mock"],
|
||||||
},
|
},
|
||||||
}))
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
environment: "jsdom" as const,
|
||||||
|
environmentOptions: {
|
||||||
|
jsdom: {
|
||||||
|
resources: "usable",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
threads: false,
|
||||||
|
trace: true,
|
||||||
|
restoreMocks: true,
|
||||||
|
watch: false,
|
||||||
|
coverage: {
|
||||||
|
provider: "istanbul" as const,
|
||||||
|
reportsDirectory: "coverage" as const,
|
||||||
|
reporters: ["text-summary", "html"],
|
||||||
|
},
|
||||||
|
name: "main",
|
||||||
|
include: ["./src/test/**/*.{test,spec}.ts"],
|
||||||
|
exclude: ["./src/test/pre.test.ts"],
|
||||||
|
},
|
||||||
|
esbuild: {
|
||||||
|
pure: mode === "production" ? ["console.log"] : [],
|
||||||
|
keepNames: true,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { defineWorkspace } from "vitest/config";
|
import { defineWorkspace } from "vitest/config";
|
||||||
import { defaultConfig } from "./vite.config";
|
import { defaultConfig } from "./vite.config";
|
||||||
import { defaultProjectTestConfig } from "./vitest.config";
|
|
||||||
|
|
||||||
export default defineWorkspace([
|
export default defineWorkspace([
|
||||||
{
|
{
|
||||||
|
@ -11,58 +10,5 @@ export default defineWorkspace([
|
||||||
environment: "jsdom",
|
environment: "jsdom",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
...defaultConfig,
|
|
||||||
test: {
|
|
||||||
...defaultProjectTestConfig,
|
|
||||||
name: "misc",
|
|
||||||
include: [
|
|
||||||
"src/test/achievements/**/*.{test,spec}.ts",
|
|
||||||
"src/test/arena/**/*.{test,spec}.ts",
|
|
||||||
"src/test/battlerTags/**/*.{test,spec}.ts",
|
|
||||||
"src/test/eggs/**/*.{test,spec}.ts",
|
|
||||||
"src/test/field/**/*.{test,spec}.ts",
|
|
||||||
"src/test/inputs/**/*.{test,spec}.ts",
|
|
||||||
"src/test/localization/**/*.{test,spec}.ts",
|
|
||||||
"src/test/phases/**/*.{test,spec}.ts",
|
|
||||||
"src/test/settingMenu/**/*.{test,spec}.ts",
|
|
||||||
"src/test/sprites/**/*.{test,spec}.ts",
|
|
||||||
"src/test/ui/**/*.{test,spec}.ts",
|
|
||||||
"src/test/*.{test,spec}.ts",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...defaultConfig,
|
|
||||||
test: {
|
|
||||||
...defaultProjectTestConfig,
|
|
||||||
name: "abilities",
|
|
||||||
include: ["src/test/abilities/**/*.{test,spec}.ts"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...defaultConfig,
|
|
||||||
test: {
|
|
||||||
...defaultProjectTestConfig,
|
|
||||||
name: "battle",
|
|
||||||
include: ["src/test/battle/**/*.{test,spec}.ts"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...defaultConfig,
|
|
||||||
test: {
|
|
||||||
...defaultProjectTestConfig,
|
|
||||||
name: "items",
|
|
||||||
include: ["src/test/items/**/*.{test,spec}.ts"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...defaultConfig,
|
|
||||||
test: {
|
|
||||||
...defaultProjectTestConfig,
|
|
||||||
name: "moves",
|
|
||||||
include: ["src/test/moves/**/*.{test,spec}.ts"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"./vitest.config.ts",
|
"./vitest.config.ts",
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue