Skip to content
Merged
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
18 changes: 18 additions & 0 deletions change/change-8ebf3c51-ac8a-4a5c-915d-693ba8507fe0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"changes": [
{
"type": "none",
"comment": "Fix lint issues",
"packageName": "@lage-run/cli",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
},
{
"type": "none",
"comment": "Fix lint issues",
"packageName": "@lage-run/scheduler",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
}
]
}
10 changes: 4 additions & 6 deletions packages/cache/tests/BackfillCacheProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Target } from "@lage-run/target-graph";

import { BackfillCacheProvider, BackfillCacheProviderOptions } from "../src/providers/BackfillCacheProvider";
import createLogger from "@lage-run/logger";
import { Monorepo } from "@lage-run/monorepo-fixture";
import { _testResetEnvHash } from "../src/salt";
import type { Target } from "@lage-run/target-graph";
import path from "path";
import createLogger from "@lage-run/logger";
import { getCacheDirectory, getLogsCacheDirectory } from "../src/getCacheDirectory";
import { getCacheDirectory } from "../src/getCacheDirectory.js";
import { BackfillCacheProvider, type BackfillCacheProviderOptions } from "../src/providers/BackfillCacheProvider.js";

describe("BackfillCacheProvider", () => {
it("should fetch a cache of the outputs as specified in the outputs folder in target", async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/cache/tests/RemoteFallbackCacheProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CacheProvider } from "../src/types/CacheProvider";
import { Logger } from "@lage-run/logger";
import { RemoteFallbackCacheProvider, RemoteFallbackCacheProviderOptions } from "../src/providers/RemoteFallbackCacheProvider";
import path from "path";
import type { Target } from "@lage-run/target-graph";
import path from "path";
import { RemoteFallbackCacheProvider, type RemoteFallbackCacheProviderOptions } from "../src/providers/RemoteFallbackCacheProvider.js";
import type { CacheProvider } from "../src/types/CacheProvider.js";

describe("RemoteFallbackCacheProvider", () => {
it("should fetch from local cache first", async () => {
Expand Down
9 changes: 5 additions & 4 deletions packages/cache/tests/backfillWrapper.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AzureBlobCacheStorageConfig } from "backfill-config";
import type { AzureBlobCacheStorageConfig, AzureBlobCacheStorageConnectionStringOptions } from "backfill-config";
import path from "path";
import { createBackfillLogger, createBackfillCacheConfig } from "../src/backfillWrapper";
import { createBackfillLogger, createBackfillCacheConfig } from "../src/backfillWrapper.js";

describe("backfill-config", () => {
it("should read values from environment variables", () => {
Expand All @@ -14,8 +14,9 @@ describe("backfill-config", () => {
expect(config.cacheStorageConfig.provider).toBe("azure-blob");

const cacheStorageConfig = config.cacheStorageConfig as AzureBlobCacheStorageConfig;
expect(cacheStorageConfig.options.connectionString).toBe("somestring");
expect(cacheStorageConfig.options.container).toBe("somecontainer");
const cacheOptions = cacheStorageConfig.options as AzureBlobCacheStorageConnectionStringOptions;
expect(cacheOptions.connectionString).toBe("somestring");
expect(cacheOptions.container).toBe("somecontainer");

delete process.env.BACKFILL_CACHE_PROVIDER;
delete process.env.BACKFILL_CACHE_PROVIDER_OPTIONS;
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/tests/chunkPromise.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chunkPromise } from "../src/chunkPromise";
import { chunkPromise } from "../src/chunkPromise.js";

describe("chunking promises", () => {
it("should chunk promises", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/info/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface InfoActionOptions extends ReporterInitOptions {
optimizeGraph: boolean;
}

interface PackageTask {
export interface PackageTask {
id: string;
command: string[];
dependencies: string[];
Expand Down
30 changes: 15 additions & 15 deletions packages/cli/tests/createTargetGraph.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { getConfig, PipelineDefinition } from "@lage-run/config";
import { getConfig, type PipelineDefinition } from "@lage-run/config";
import createLogger from "@lage-run/logger";
import type { PackageInfo, PackageInfos } from "workspace-tools";
import { generatePackageTask, type InfoActionOptions, type PackageTask } from "../src/commands/info/action.js";
import { initializeReporters } from "../src/commands/initializeReporters.js";
import { generatePackageTask, type InfoActionOptions } from "../src/commands/info/action.js";
import { PackageInfo, PackageInfos } from "workspace-tools";
import { createTargetGraph } from "../src/commands/run/createTargetGraph.js";
import { getFilteredPackages } from "../src/filter/getFilteredPackages.js";
import { getBinPaths } from "../src/getBinPaths.js";

describe("createTargetGraph", () => {
Expand Down Expand Up @@ -141,17 +140,18 @@ async function createPackageTasks(tasks: string[], packageInfos: PackageInfos, p
priorities: config.priorities,
});

const scope = getFilteredPackages({
root,
packageInfos,
logger,
includeDependencies: options.dependencies,
includeDependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents
since: options.since,
scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents
repoWideChanges: config.repoWideChanges,
sinceIgnoreGlobs: options.ignore.concat(config.ignore),
});
// unused?
// const scope = getFilteredPackages({
// root,
// packageInfos,
// logger,
// includeDependencies: options.dependencies,
// includeDependents: options.dependents && !options.to, // --to is a short hand for --scope + --no-dependents
// since: options.since,
// scope: (options.scope ?? []).concat(options.to ?? []), // --to is a short hand for --scope + --no-dependents
// repoWideChanges: config.repoWideChanges,
// sinceIgnoreGlobs: options.ignore.concat(config.ignore),
// });

const binPaths = getBinPaths();
const targets = [...targetGraph.targets.values()];
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/tests/filterPackages.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filterPackages } from "../src/filter/getFilteredPackages";
import { PackageInfos, PackageInfo } from "workspace-tools";
import { Logger } from "@lage-run/logger";
import type { PackageInfo, PackageInfos } from "workspace-tools";
import { filterPackages } from "../src/filter/getFilteredPackages.js";

describe("filterPackages", () => {
const logger = new Logger();
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/tests/getFilteredPackages.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createLogger from "@lage-run/logger";
import { Monorepo } from "@lage-run/monorepo-fixture";
import { getPackageInfosAsync } from "workspace-tools";
import { getFilteredPackages } from "../src/filter/getFilteredPackages";
import { getFilteredPackages } from "../src/filter/getFilteredPackages.js";

describe("getFilteredPackages", () => {
it("should respect the ignore flag when since flag is used", async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/tests/initializeReporters.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Logger, type Reporter } from "@lage-run/logger";
import { AdoReporter, BasicReporter, ChromeTraceEventsReporter, LogReporter } from "@lage-run/reporters";
import fs from "fs";
import path from "path";
import isInteractive from "is-interactive";
import os from "os";
import { Logger, Reporter } from "@lage-run/logger";
import { AdoReporter, BasicReporter, ChromeTraceEventsReporter, LogReporter } from "@lage-run/reporters";
import path from "path";
import { initializeReporters } from "../src/commands/initializeReporters.js";
import isInteractive from "is-interactive";

jest.mock("is-interactive", () => jest.fn(() => true));

Expand Down
35 changes: 16 additions & 19 deletions packages/cli/tests/jsonReporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ describe("json reporter", () => {
logger.info("test Json", testObject);

expect(logSpy).toHaveBeenCalledWith(
'{"timestamp":0,"level":30,"msg":"test Json","data":{"x":"field x","number":1,"array":[1,2,3],"object":{"a":1,"b":2}}}'
JSON.stringify({
timestamp: 0,
level: 30,
msg: "test Json",
data: testObject,
})
);
jest.clearAllMocks();
});
Expand All @@ -57,24 +62,16 @@ describe("json reporter", () => {
logger.info("test Json", testObject);

expect(logSpy).toHaveBeenCalledWith(
`{
\"timestamp\": 0,
\"level\": 30,
\"msg\": \"test Json\",
\"data\": {
\"x\": \"field x\",
\"number\": 1,
\"array\": [
1,
2,
3
],
\"object\": {
\"a\": 1,
\"b\": 2
}
}
}`
JSON.stringify(
{
timestamp: 0,
level: 30,
msg: "test Json",
data: testObject,
},
null,
2
)
);
jest.clearAllMocks();
});
Expand Down
31 changes: 16 additions & 15 deletions packages/cli/tests/simulateFileAccess.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { simulateFileAccess } from "../src/commands/exec/simulateFileAccess";
import fs from "fs";
import path from "path";
import { Logger } from "@lage-run/logger";
import fs, { type Stats } from "fs";
import os from "os";
import path from "path";
import { simulateFileAccess } from "../src/commands/exec/simulateFileAccess.js";

jest.mock("fs");

// Mock the logger
const mockSilly = jest.fn();
const mockLogger = {
silly: mockSilly,
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
verbose: jest.fn(),
debug: jest.fn(),
};
class MockLogger extends Logger {
override silly = mockSilly;
// do nothing
override log() {}
override stream() {
return () => {};
}
}
const mockLogger = new MockLogger();

describe("simulateFileAccess", () => {
let mockRoot: string;
Expand All @@ -23,7 +25,6 @@ describe("simulateFileAccess", () => {
let mockCloseSync: jest.SpyInstance;
let mockReaddirSync: jest.SpyInstance;
let mockUtimesSync: jest.SpyInstance;
let mockLstatSync: jest.SpyInstance;

beforeEach(() => {
mockRoot = path.join(os.tmpdir(), "lage-test-root");
Expand All @@ -33,11 +34,11 @@ describe("simulateFileAccess", () => {
mockCloseSync = jest.spyOn(fs, "closeSync").mockImplementation(() => {});
mockReaddirSync = jest.spyOn(fs, "readdirSync").mockImplementation(() => []);
mockUtimesSync = jest.spyOn(fs, "utimesSync").mockImplementation(() => {});
mockLstatSync = jest.spyOn(fs, "lstatSync").mockImplementation((inputPath: any) => {
jest.spyOn(fs, "lstatSync").mockImplementation((inputPath: any) => {
const strPath = Buffer.isBuffer(inputPath) ? inputPath.toString() : String(inputPath);
return {
isDirectory: () => strPath.endsWith(path.sep),
};
} as Stats;
});
});

Expand Down Expand Up @@ -134,7 +135,7 @@ describe("simulateFileAccess", () => {

// Set up a mock that fails for a specific file path
const failingPath = path.join(mockRoot, "src/components/Missing.tsx");
jest.spyOn(fs, "openSync").mockImplementation((filePath, mode) => {
jest.spyOn(fs, "openSync").mockImplementation((filePath) => {
if (filePath === failingPath) {
throw new Error("ENOENT: File not found");
}
Expand Down
2 changes: 1 addition & 1 deletion packages/config/tests/getConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getConfig } from "../src/getConfig";
import path from "path";
import { getConfig } from "../src/getConfig.js";

describe("getConfig", () => {
it("should read from an asynchronous config file", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/config/tests/getMaxWorkersPerTask.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMaxWorkersPerTask } from "../src/getMaxWorkersPerTask";
import { getMaxWorkersPerTask } from "../src/getMaxWorkersPerTask.js";

describe("getMaxWorkersPerTask", () => {
it("parses the pipeline config for maxWorkers", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/format-hrtime/tests/formatDuration.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hrtimeDiff, hrToSeconds } from "../src/formatDuration";
import { hrtimeDiff, hrToSeconds } from "../src/formatDuration.js";

describe("hrtimeDiff", () => {
it("should calulate diffs between two hrtime", () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/hasher/src/__tests__/PackageTree.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import path from "path";

import { PackageTree } from "../index";
import { Monorepo } from "@lage-run/monorepo-fixture";
import path from "path";
import { getPackageInfos } from "workspace-tools";
import { PackageTree } from "../index.js";

const fixturesPath = path.join(__dirname, "..", "__fixtures__");

Expand Down
Loading