From bbc08e0ff783369ad76387896effd44eebbb919b Mon Sep 17 00:00:00 2001 From: electrovir Date: Wed, 11 Sep 2024 12:59:25 +0000 Subject: [PATCH] [patch] try fixing tests on windows --- .github/workflows/tests.yml | 4 ++-- packages/docs/src/docs.ts | 12 +++++++++--- packages/frontend/src/frontend.ts | 5 ++++- .../init/configs/github/workflows/tests-node.yml | 4 ++-- packages/init/configs/github/workflows/tests-web.yml | 4 ++-- packages/test/src/test.ts | 3 ++- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5b4cfa54..c536bde4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [macos-latest, ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v4.1.7 - name: Use Node.js ${{ matrix.node-version }} @@ -26,7 +26,7 @@ jobs: - if: runner.os == 'Windows' shell: bash run: | - npm install npm + npm i npm --no-save - name: run test shell: bash run: | diff --git a/packages/docs/src/docs.ts b/packages/docs/src/docs.ts index a704adb5..46d31a4d 100644 --- a/packages/docs/src/docs.ts +++ b/packages/docs/src/docs.ts @@ -12,6 +12,7 @@ import { import {ChalkInstance} from 'chalk'; import mri from 'mri'; import {basename, join} from 'node:path'; +import {pathToFileURL} from 'node:url'; import type * as Typedoc from 'typedoc'; /** A virmator plugin for checking and generating documentation. */ @@ -160,9 +161,14 @@ export const virmatorDocsPlugin = defineVirmatorPlugin( } // dynamic imports are not branches - /* node:coverage ignore next 2 */ - const config = (await import(join(packageDir, configs.docs.configs.typedoc.copyToPath))) - .typeDocConfig as Typedoc.TypeDocOptions; + /* node:coverage ignore next 7 */ + const config = ( + await import( + pathToFileURL( + join(packageDir, configs.docs.configs.typedoc.copyToPath), + ).toString() + ) + ).typeDocConfig as Typedoc.TypeDocOptions; await runTypedoc({ checkOnly, diff --git a/packages/frontend/src/frontend.ts b/packages/frontend/src/frontend.ts index 58a9b918..9097c3e2 100644 --- a/packages/frontend/src/frontend.ts +++ b/packages/frontend/src/frontend.ts @@ -4,6 +4,7 @@ import {defineVirmatorPlugin, NpmDepType, PackageType, VirmatorEnv} from '@virma import mri from 'mri'; import {cp, rm} from 'node:fs/promises'; import {join, relative, resolve} from 'node:path'; +import {pathToFileURL} from 'node:url'; import type {UserConfig} from 'vite'; /** A virmator plugin for running and building frontend packages. */ @@ -109,7 +110,9 @@ export const virmatorFrontendPlugin = defineVirmatorPlugin( usedCommands.frontend?.subCommands.build || usedCommands.frontend?.subCommands.preview; const configPath = args.config || configs.frontend.configs.vite.fullCopyToPath; - const viteConfig = await ((await import(configPath)).default as MaybePromise); + const viteConfig = await (( + await import(pathToFileURL(configPath).toString()) + ).default as MaybePromise); const rootDir: string = viteConfig.root ? resolve(cwd, viteConfig.root) : cwd; const outDir: string = resolve(rootDir, viteConfig.build?.outDir || 'dist'); diff --git a/packages/init/configs/github/workflows/tests-node.yml b/packages/init/configs/github/workflows/tests-node.yml index 715c29f9..3a6e808e 100644 --- a/packages/init/configs/github/workflows/tests-node.yml +++ b/packages/init/configs/github/workflows/tests-node.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [macos-latest, ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v4.1.7 - name: Use Node.js ${{ matrix.node-version }} @@ -26,7 +26,7 @@ jobs: - if: runner.os == 'Windows' shell: bash run: | - npm install npm + npm i npm --no-save - name: run test shell: bash run: | diff --git a/packages/init/configs/github/workflows/tests-web.yml b/packages/init/configs/github/workflows/tests-web.yml index c88bd0ff..024b215e 100644 --- a/packages/init/configs/github/workflows/tests-web.yml +++ b/packages/init/configs/github/workflows/tests-web.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [macos-latest, ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v4.1.7 - name: Use Node.js ${{ matrix.node-version }} @@ -26,7 +26,7 @@ jobs: - if: runner.os == 'Windows' shell: bash run: | - npm install npm + npm i npm --no-save - name: run test shell: bash run: | diff --git a/packages/test/src/test.ts b/packages/test/src/test.ts index 32a13478..ce5f1c82 100644 --- a/packages/test/src/test.ts +++ b/packages/test/src/test.ts @@ -12,6 +12,7 @@ import {glob} from 'glob'; import mri from 'mri'; import {rm, writeFile} from 'node:fs/promises'; import {join, relative} from 'node:path'; +import {pathToFileURL} from 'node:url'; /** A virmator plugin for running tests. */ export const virmatorTestPlugin = defineVirmatorPlugin( @@ -282,7 +283,7 @@ export const virmatorTestPlugin = defineVirmatorPlugin( configPath, ]; - const webTestRunnerConfig = (await import(configPath)) + const webTestRunnerConfig = (await import(pathToFileURL(configPath).toString())) .default as Partial; const includeCoverage = usedCommands.test.subCommands.web.subCommands.coverage;