lage/packages/scheduler
Ken Chau 089fedf9a5 applying package updates 2024-11-20 02:43:43 +00:00
..
src Escape ADO cache write to remote cache with env.LAGE_WRITE_CACHE=false (#820) 2024-11-08 11:24:18 -08:00
tests Runner refactor - in preparation for exec and server commands (#770) 2024-08-28 14:09:49 -07:00
CHANGELOG.json applying package updates 2024-11-20 02:43:43 +00:00
CHANGELOG.md applying package updates 2024-11-20 02:43:43 +00:00
README.md [lage v2] Worker Runner (#336) 2022-09-04 15:55:42 -07:00
jest.config.js Unpin devDependencies (#654) 2023-12-21 00:35:03 -08:00
package.json applying package updates 2024-11-20 02:43:43 +00:00
tsconfig.json cleaning up the tsconfig files (#470) 2022-11-01 13:38:56 -07:00

README.md

@lage-run/scheduler

This package provides:

  1. Scheduler interface
  2. `
  3. a default cache provider that uses backfill

Usage

import { Logger } from "@lage-run/logger";
import { RemoteFallbackCacheProvider, TargetHasher } from "@lage-run/cache";
import { SimpleScheduler } from "@lage-run/scheduler";
import { TargetGraph } from "@lage-run/target-graph";

const root = "/root-of-repo";
const logger = new Logger();
const cacheProvider = new RemoteFallbackCacheProvider({ root, logger, ... });
const hasher = new TargetHasher({ root, ... });

const runner = new NpmScriptRunner({
  logger,
  ...
})

const runnerPicker = new TargetRunnerPicker({
  runners: {
    npmScript: runner
  }
})

const scheduler = new SimpleScheduler({
  logger,
  concurrency,
  cacheProvider,
  hasher,
  continueOnError: true,
  shouldCache: true,
  shouldResetCache: false,
  runner
});

const targetGraphBuilder = new TargetGraphBuilder();
const packageInfos = getPackageInfos(rootDir);

const builder = new TargetGraphBuilder(rootDir, packageInfos);

// these would normally come from the CLI
const tasks = ["build", "test"];
const packages = ["package-a", "package-b"];

const targetGraph = builder.buildTargetGraph(tasks, packages);

await scheduler.run(root, targetGraph);

// If an error happened...
scheduler.abort();