From b66107229c677dd3badd560598599184c84e2d00 Mon Sep 17 00:00:00 2001 From: Jacob Steves Date: Thu, 12 Nov 2026 13:49:38 -0500 Subject: [PATCH] Run CI tests on Linux, Windows, and macOS --- .github/workflows/test.yml | 7 ++++++- tests/codegen.test.cjs | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d11fc5d..1310a0c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,12 @@ permissions: jobs: test: - runs-on: ubuntu-latest + name: test (${{ matrix.os }}) + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/tests/codegen.test.cjs b/tests/codegen.test.cjs index 71850f4..c0a6986 100644 --- a/tests/codegen.test.cjs +++ b/tests/codegen.test.cjs @@ -95,7 +95,8 @@ test("generated types have no type errors when a query uses enums and input obje fs.mkdirSync(path.join(dir, "src")); fs.writeFileSync(path.join(dir, "src", "run.graphql"), inputQuery); // Codegen resolves its plugins from the function directory, as in an installed function. - fs.symlinkSync(path.join(root, "node_modules"), path.join(dir, "node_modules"), "dir"); + // A junction on Windows, which needs no extra privileges; the type is ignored elsewhere. + fs.symlinkSync(path.join(root, "node_modules"), path.join(dir, "node_modules"), "junction"); const configPath = path.join(configDir, "codegen.json"); fs.writeFileSync( @@ -105,7 +106,13 @@ test("generated types have no type errors when a query uses enums and input obje config: { ...cliDefaults, ...templateCodegen.config, scalars: cliDefaults.scalars }, }), ); - const bin = fs.realpathSync(path.join(root, "node_modules", ".bin", "graphql-code-generator")); + // Resolve the bin script from the package itself: on Windows, node_modules/.bin + // holds shell and cmd shims rather than symlinks to the JavaScript entry point. + const cliPackageJson = require.resolve("@graphql-codegen/cli/package.json"); + const bin = path.join( + path.dirname(cliPackageJson), + require(cliPackageJson).bin["graphql-code-generator"], + ); execFileSync(process.execPath, [bin, "--config", configPath], { cwd: dir, stdio: "pipe" }); const program = ts.createProgram([path.join(dir, "generated", "api.ts")], {