Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/go-conditional-tests/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apps/go-conditional-tests/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as core from "@actions/core";
import * as github from "@actions/github";
import * as cache from "@actions/cache";
import * as fs from "fs";
import * as path from "path";

function getCacheKey(testSuite: string, branch: string, commitSha?: string) {
const key = `go-test-hashes-${testSuite}-${branch}`;
Expand Down
4 changes: 2 additions & 2 deletions apps/go-conditional-tests/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ async function runStep(
const packages = await pipeline.processChangedPackages(inputs, pkgs);

const changedPkgs = Object.fromEntries(
Object.entries(packages).filter(([_, pkg]) => pkg.shouldRun),
Object.entries(packages).filter(([, pkg]) => pkg.shouldRun),
);
logObject("Changed Test Packages", changedPkgs);

const maybeExecdPkgs = await pipeline.runTestBinaries(inputs, packages);
const execdPkgs = Object.fromEntries(
Object.entries(maybeExecdPkgs).filter(([_, pkg]) => !!pkg.run),
Object.entries(maybeExecdPkgs).filter(([, pkg]) => !!pkg.run),
);
logObject("Executed Test Packages", execdPkgs);

Expand Down
2 changes: 0 additions & 2 deletions apps/go-conditional-tests/src/pipeline/filter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as path from "path";

import * as core from "@actions/core";
import { execa } from "execa";

Expand Down
18 changes: 9 additions & 9 deletions apps/go-conditional-tests/test/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("getTestHashIndex", () => {
});

it("should return empty object when no cache hit", async () => {
(cache.restoreCache as any).mockResolvedValue(null);
vi.mocked(cache.restoreCache).mockResolvedValue(undefined);

const result = await getTestHashIndex("unit");

Expand All @@ -62,8 +62,8 @@ describe("getTestHashIndex", () => {
base: { ref: "main" },
head: { ref: "feature", sha: "abcdef1" },
};
(cache.restoreCache as any).mockResolvedValue("some-cache-key");
(fs.promises.readFile as any).mockResolvedValue('{"pkg1": "hash1"}');
vi.mocked(cache.restoreCache).mockResolvedValue("some-cache-key");
vi.mocked(fs.promises.readFile).mockResolvedValue('{"pkg1": "hash1"}');

await getTestHashIndex("unit");

Expand All @@ -90,8 +90,8 @@ describe("getTestHashIndex", () => {
},
},
};
(cache.restoreCache as any).mockResolvedValue("some-cache-key");
(fs.promises.readFile as any).mockResolvedValue('{"pkg1": "hash1"}');
vi.mocked(cache.restoreCache).mockResolvedValue("some-cache-key");
vi.mocked(fs.promises.readFile).mockResolvedValue('{"pkg1": "hash1"}');

await getTestHashIndex("unit");

Expand All @@ -106,8 +106,8 @@ describe("getTestHashIndex", () => {
});

it("should handle file read errors", async () => {
(cache.restoreCache as any).mockResolvedValue("some-cache-key");
(fs.promises.readFile as any).mockRejectedValue(new Error("read error"));
vi.mocked(cache.restoreCache).mockResolvedValue("some-cache-key");
vi.mocked(fs.promises.readFile).mockRejectedValue(new Error("read error"));

const result = await getTestHashIndex("unit");

Expand Down Expand Up @@ -186,7 +186,7 @@ describe("saveTestHashIndex", () => {
});

it("should handle cache reservation errors", async () => {
(cache.saveCache as any).mockRejectedValue(
vi.mocked(cache.saveCache).mockRejectedValue(
new cache.ReserveCacheError("already reserved"),
);

Expand All @@ -198,7 +198,7 @@ describe("saveTestHashIndex", () => {
});

it("should throw non-reservation errors", async () => {
(cache.saveCache as any).mockRejectedValue(new Error("network error"));
vi.mocked(cache.saveCache).mockRejectedValue(new Error("network error"));

await expect(saveTestHashIndex("unit", { pkg1: "hash1" })).rejects.toThrow(
"network error",
Expand Down
7 changes: 5 additions & 2 deletions apps/go-conditional-tests/test/pipeline.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, it, expect, vi, beforeEach, Mock } from "vitest";
import * as core from "@actions/core";
import * as github from "@actions/github";

import { Inputs } from "../src/main.js";
import { saveTestHashIndex } from "../src/github.js";
Expand Down Expand Up @@ -256,7 +255,11 @@ describe("runTestBinaries", () => {
directory: "/path/pkg1",
hash: "hash1",
shouldRun: true,
compile: { binary: "bin1", log: "log1", execution: {} as any },
compile: {
binary: "bin1",
log: "log1",
execution: { command: "", exitCode: 0, cwd: "", durationMs: 0 },
},
},
};

Expand Down
3 changes: 2 additions & 1 deletion apps/go-conditional-tests/test/pipeline/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ describe("validateCompilationResultsOrThrow", () => {
isCanceled: false,
killed: false,
pid: 1234,
} as any,
pipe: vi.fn(),
},
};

readdirSyncMock.mockReturnValue(["github.com-example-pkg-test"]);
Expand Down
6 changes: 4 additions & 2 deletions apps/go-conditional-tests/test/pipeline/filter.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { describe, it, expect, vi, beforeEach, Mock } from "vitest";

import { execa } from "execa";

Expand All @@ -17,6 +17,8 @@ vi.mock("@actions/core", () => ({
debug: vi.fn(),
}));

const execaMock = execa as unknown as Mock;

describe("listPackages", () => {
beforeEach(() => {
vi.clearAllMocks();
Expand All @@ -29,7 +31,7 @@ describe("listPackages", () => {
];

// Mock execa for 'go list' command
(execa as any).mockResolvedValueOnce({
execaMock.mockResolvedValueOnce({
stdout: mockedStdout,
});

Expand Down
10 changes: 8 additions & 2 deletions apps/go-conditional-tests/test/pipeline/hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ describe("hashFile", () => {
},
});

vi.spyOn(fs, "createReadStream").mockReturnValue(readableStream as any);
vi.spyOn(fs, "createReadStream").mockReturnValue(
readableStream as fs.ReadStream,
);

// Act
const hash = await hashFile(testFilePath);
Expand Down Expand Up @@ -177,7 +179,11 @@ function createPackageEntry(
return {
importPath: "foo.com/bar/baz/v2/qux",
directory: "baz/qux",
compile: { binary: "", log: "", execution: null as any },
compile: {
binary: "",
log: "",
execution: { command: "", exitCode: 0, cwd: "", durationMs: 0 },
},
hash,
};
}
6 changes: 3 additions & 3 deletions apps/go-conditional-tests/test/pipeline/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as path from "path";
import * as fs from "fs";

import { describe, it, expect, vi, beforeEach, Mock } from "vitest";
Expand Down Expand Up @@ -146,7 +145,7 @@ describe("runTestBinary", () => {
directory: "/path/to/pkg",
};
const binaryPath = "/path/to/binary";
const runFlags = [];
const runFlags: string[] = [];
const coverageDir = "/coverage";

const executionResult = {
Expand Down Expand Up @@ -327,6 +326,7 @@ describe("validateRunResultsOrThrow", () => {
isCanceled: false,
killed: false,
pid: 1234,
pipe: vi.fn(),
};

const results = [
Expand All @@ -339,7 +339,7 @@ describe("validateRunResultsOrThrow", () => {
importPath: "github.com/example/pkg",
directory: "/path/to/pkg",
},
execution: executionResult as any,
execution: executionResult,
},
] satisfies RunResult[];

Expand Down
2 changes: 1 addition & 1 deletion apps/go-mod-validator/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/go-mod-validator/src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export function goModsToGoModules(
})
.map((d: GoMod): GoModule => {
// repo format github.com/smartcontractkit/chainlink
const [_, owner, repo, ...subModulePathElements] = d.Path.split("/");
const [, owner, repo, ...subModulePathElements] = d.Path.split("/");
const baseModule: BaseGoModule = {
owner,
repo,
Expand Down
50 changes: 28 additions & 22 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import { FlatCompat } from "@eslint/eslintrc";
import { dirname } from "path";
import { fileURLToPath } from "url";
import eslintConfigPrettier from "eslint-config-prettier";
import js from "@eslint/js";
import * as jsoncEslintParser from "jsonc-eslint-parser";
import nx from "@nx/eslint-plugin";
import tseslint from "typescript-eslint";

const compat = new FlatCompat({
baseDirectory: dirname(fileURLToPath(import.meta.url)),
recommendedConfig: js.configs.recommended,
});

const prettierCompat = (files, config = {}) =>
compat
.config({ extends: ["prettier"], ...config })
.map((flatConfig) => ({ ...flatConfig, files }));

export default [
...compat.extends("prettier"),
export default tseslint.config(
...nx.configs["flat/base"],
{
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
Expand All @@ -35,10 +24,27 @@ export default [
],
},
},
...nx.configs["flat/typescript"],
...prettierCompat(["**/*.ts", "**/*.tsx"]),
...nx.configs["flat/javascript"],
...prettierCompat(["**/*.js", "**/*.jsx"]),
...prettierCompat(["**/*.json"], { parser: "jsonc-eslint-parser" }),
...prettierCompat(["**/*.yaml", "**/*.yml"]),
];
{
files: ["**/*.ts", "**/*.tsx"],
extends: [tseslint.configs.recommended],
languageOptions: {
parser: tseslint.parser,
ecmaVersion: 2020,
sourceType: "module",
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ["**/*.js", "**/*.jsx"],
...js.configs.recommended,
},
{
files: ["**/*.json"],
languageOptions: {
parser: jsoncEslintParser,
},
},
eslintConfigPrettier,
);
Loading
Loading