Skip to content

Commit

Permalink
ci: enable tests on windows (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Dec 27, 2024
1 parent cf98e6c commit 87a1aa9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ on:

jobs:
ci:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- run: corepack enable
Expand All @@ -20,6 +23,9 @@ jobs:
cache: "pnpm"
- run: pnpm install
- run: pnpm lint
if: matrix.os == 'ubuntu-latest'
- run: pnpm build
if: matrix.os == 'ubuntu-latest'
- run: pnpm vitest --typecheck --coverage
- uses: codecov/codecov-action@v5
if: matrix.os == 'ubuntu-latest'
16 changes: 12 additions & 4 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const fixtureDir = resolve(dirname(fileURLToPath(import.meta.url)), "fixture");

const rFixture = (...p: string[]) => resolve(fixtureDir, ...p);

const normalizeWinLines = (s: string) => s.replace(/\r\n/g, "\n");

async function expectToReject(p: Promise<any>) {
return expect(
await p.then(() => {}).catch((error: Error) => error.toString()),
Expand Down Expand Up @@ -98,15 +100,18 @@ describe("package.json", () => {
});

it("styles are preserved", async () => {
const originalContent = await readFile(rFixture("package.json"), "utf8");
const originalContent = await readFile(
rFixture("package.json"),
"utf8",
).then(normalizeWinLines);
await writePackageJSON(
rFixture("package.json") + ".tmp",
await readPackageJSON(rFixture("package.json")),
);
const newContent = await readFile(
rFixture("package.json") + ".tmp",
"utf8",
);
).then(normalizeWinLines);
expect(newContent).toBe(originalContent);
});
});
Expand All @@ -133,15 +138,18 @@ describe("tsconfig.json", () => {
});

it("styles are preserved", async () => {
const originalContent = await readFile(rFixture("tsconfig.json"), "utf8");
const originalContent = await readFile(
rFixture("tsconfig.json"),
"utf8",
).then(normalizeWinLines);
await writeTSConfig(
rFixture("tsconfig.json") + ".tmp",
await readTSConfig(rFixture("tsconfig.json")),
);
const newContent = await readFile(
rFixture("tsconfig.json") + ".tmp",
"utf8",
);
).then(normalizeWinLines);
expect(newContent).toBe(originalContent.replace(/\s*\/\/\s*.+/g, ""));
});
});
Expand Down

0 comments on commit 87a1aa9

Please sign in to comment.