lage/packages/scheduler
Ken Chau 905eb5b360 applying package updates 2022-10-01 06:41:42 +00:00
..
src Worker pool that accounts for stdio (#388) 2022-10-01 05:19:57 +00:00
tests Add aggregate prioritization to the target graph (#389) 2022-10-01 06:36:12 +00:00
CHANGELOG.json applying package updates 2022-10-01 06:41:42 +00:00
CHANGELOG.md applying package updates 2022-10-01 06:41:42 +00:00
README.md [lage v2] Worker Runner (#336) 2022-09-04 15:55:42 -07:00
jest.config.js @lage-run/scheduler (#320) 2022-08-09 12:10:23 -07:00
package.json applying package updates 2022-10-01 06:41:42 +00:00
tsconfig.json Update jest monorepo to v29 (major) (#346) 2022-09-16 03:53:50 +00: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();