Skip to content

Commit 7e97834

Browse files
fix: vite v6 + vitest 3
1 parent fde284b commit 7e97834

7 files changed

+1439
-442
lines changed

package-lock.json

+1,398-428
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"cargo"
3838
],
3939
"bugs": {
40-
"url": "https://github.com/actions-rs-plus/core/issues"
40+
"url": "https://github.com/actions-rs-plus/clippy-check/issues"
4141
},
4242
"devDependencies": {
4343
"@codecov/vite-plugin": "1.7.0",
@@ -47,8 +47,8 @@
4747
"@types/node": "20.17.12",
4848
"@types/semver": "7.5.8",
4949
"@vercel/ncc": "0.38.3",
50-
"@vitest/coverage-v8": "2.1.8",
51-
"@vitest/ui": "2.1.8",
50+
"@vitest/coverage-v8": "3.0.0-beta.4",
51+
"@vitest/ui": "3.0.0-beta.4",
5252
"conventional-changelog-conventionalcommits": "8.0.0",
5353
"dependency-cruiser": "16.9.0",
5454
"eslint": "9.18.0",
@@ -69,9 +69,10 @@
6969
"semantic-release": "24.2.1",
7070
"typescript": "5.7.3",
7171
"typescript-eslint": "8.19.1",
72-
"vite": "5.4.11",
72+
"vite": "6.0.7",
73+
"vite-plugin-checker": "0.8.0",
7374
"vite-tsconfig-paths": "5.1.4",
74-
"vitest": "2.1.8"
75+
"vitest": "3.0.0-beta.4"
7576
},
7677
"lint-staged": {
7778
"*.{ts,tsx}": [
@@ -80,7 +81,7 @@
8081
]
8182
},
8283
"dependencies": {
83-
"@actions-rs-plus/core": "0.2.4",
84+
"@actions-rs-plus/core": "0.2.5",
8485
"@actions/core": "1.11.1",
8586
"@actions/exec": "1.1.1",
8687
"string-argv": "0.3.2"

src/clippy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as core from "@actions/core";
44
import * as exec from "@actions/exec";
55
import { Cargo, Cross } from "@actions-rs-plus/core";
66

7-
import type { BaseProgram } from "@actions-rs-plus/core/dist/commands/base-program";
7+
import type { BaseProgram } from "@actions-rs-plus/core";
88

99
import type * as input from "@/input";
1010
import { OutputParser } from "@/output-parser";

src/tests/clippy.test.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import * as core from "@actions/core";
12
import * as exec from "@actions/exec";
2-
3-
import { describe, expect, it, vi } from "vitest";
3+
import { beforeEach, describe, expect, it, vi } from "vitest";
44

55
import { run } from "@/clippy";
66
import type { ParsedInput } from "@/input";
@@ -10,8 +10,15 @@ import type { CompilerMessage } from "@/schema";
1010
vi.mock("@actions/core");
1111

1212
describe("clippy", () => {
13+
beforeEach(() => {
14+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
15+
vi.spyOn(core, "startGroup").mockImplementation(() => {});
16+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
17+
vi.spyOn(core, "endGroup").mockImplementation(() => {});
18+
});
19+
1320
it("runs with cargo", async () => {
14-
vi.spyOn(exec, "exec").mockResolvedValue(0);
21+
const execSpy = vi.spyOn(exec, "exec").mockResolvedValue(0);
1522

1623
const actionInput: ParsedInput = {
1724
toolchain: "stable",
@@ -21,10 +28,13 @@ describe("clippy", () => {
2128
};
2229

2330
await expect(run(actionInput)).resolves.toBeUndefined();
31+
expect(execSpy).toBeCalledTimes(4);
2432
});
2533

2634
it("runs with cross", async () => {
27-
vi.spyOn(exec, "exec").mockResolvedValue(0);
35+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
36+
const debugSpy = vi.spyOn(core, "debug").mockImplementation((_s: string) => {});
37+
const execSpy = vi.spyOn(exec, "exec").mockResolvedValue(0);
2838

2939
const actionInput: ParsedInput = {
3040
toolchain: "stable",
@@ -34,6 +44,8 @@ describe("clippy", () => {
3444
};
3545

3646
await expect(run(actionInput)).resolves.toBeUndefined();
47+
expect(execSpy).toBeCalledTimes(5);
48+
expect(debugSpy).toBeCalledTimes(1);
3749
});
3850

3951
it("reports when clippy fails", async () => {

src/tests/index.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ describe("index", () => {
2222
it("catches Error", async () => {
2323
vi.spyOn(clippy, "run").mockRejectedValue(new Error("It looks like you're running a test"));
2424

25-
const setFailedSpy = vi.spyOn(core, "setFailed");
25+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
26+
const setFailedSpy = vi.spyOn(core, "setFailed").mockImplementation((_s: Error | string) => {});
2627

2728
await vi.importActual("@/index");
2829

@@ -34,7 +35,8 @@ describe("index", () => {
3435
"It looks like you're trying to write a test, would you like some assistance? [YES / NO]",
3536
);
3637

37-
const setFailedSpy = vi.spyOn(core, "setFailed");
38+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
39+
const setFailedSpy = vi.spyOn(core, "setFailed").mockImplementation((_s: Error | string) => {});
3840

3941
await vi.importActual("@/index");
4042

src/tests/output-parser.test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { describe, expect, it } from "vitest";
1+
import core from "@actions/core";
2+
import { describe, expect, it, vi } from "vitest";
23

34
import { OutputParser } from "@/output-parser";
45
import type { CargoMessage, CompilerMessage, Stats } from "@/schema";
@@ -33,6 +34,9 @@ describe("outputParser", () => {
3334
};
3435

3536
it("ignores invalid json", () => {
37+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
38+
vi.spyOn(core, "debug").mockImplementation(() => {});
39+
3640
const outputParser = new OutputParser();
3741

3842
outputParser.tryParseClippyLine("I am not valid json");
@@ -41,6 +45,9 @@ describe("outputParser", () => {
4145
});
4246

4347
it("ignores non-compiler-messages", () => {
48+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
49+
vi.spyOn(core, "debug").mockImplementation(() => {});
50+
4451
const outputParser = new OutputParser();
4552

4653
const output: CargoMessage = {
@@ -53,6 +60,9 @@ describe("outputParser", () => {
5360
});
5461

5562
it("ignores when compiler-message doesn't have a code", () => {
63+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- mock
64+
vi.spyOn(core, "debug").mockImplementation(() => {});
65+
5666
const outputParser = new OutputParser();
5767

5868
const output: CargoMessage = {

vite.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { codecovVitePlugin } from "@codecov/vite-plugin";
22
import type { UserConfig } from "vite";
3+
import { checker } from "vite-plugin-checker";
34
import viteTsConfigPaths from "vite-tsconfig-paths";
45
import { coverageConfigDefaults, defineConfig } from "vitest/config";
56

@@ -10,6 +11,7 @@ export default defineConfig(() => {
1011
const config: UserConfig = {
1112
appType: "custom",
1213
plugins: [
14+
checker({ typescript: true }),
1315
viteTsConfigPaths(),
1416
codecovVitePlugin({
1517
enableBundleAnalysis: process.env["CODECOV_TOKEN"] !== undefined,

0 commit comments

Comments
 (0)