diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b9a9c3f0..fe3e38fe 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -36,6 +36,9 @@ jobs: - name: Install mise uses: jdx/mise-action@f8dfbcc150159126838e44b882bf34bd98fd90f3 # v2.1.0 with: + # backends are required to run mise list + install_args: bun node + cache_key_prefix: mise-v0-bun-node experimental: true - name: Install package.json dependencies @@ -70,6 +73,8 @@ jobs: - name: Install mise uses: jdx/mise-action@f8dfbcc150159126838e44b882bf34bd98fd90f3 # v2.1.0 with: + install_args: ${{ matrix.tools }} + cache_key_prefix: mise-v0-${{ matrix.toolsHash }} experimental: true - name: Run ${{ matrix.name }} @@ -90,6 +95,8 @@ jobs: - name: Install mise uses: jdx/mise-action@f8dfbcc150159126838e44b882bf34bd98fd90f3 # v2.1.0 with: + install_args: bun node + cache_key_prefix: mise-v0-bun-node experimental: true - name: Install package.json dependencies diff --git a/.github/workflows/scripts/list-mise-tasks.ts b/.github/workflows/scripts/list-mise-tasks.ts index a7d45938..08911bcc 100644 --- a/.github/workflows/scripts/list-mise-tasks.ts +++ b/.github/workflows/scripts/list-mise-tasks.ts @@ -1,3 +1,4 @@ +import { createHash } from "node:crypto"; import { $ } from "bun"; import { type EdgeModel, @@ -10,6 +11,10 @@ $.throws(true); const ciTaskDepsDot = await $`mise tasks deps ci --dot`.text(); +const miseTools = Object.keys( + (await $`mise list --current --json`.json()) as Record, +); + const ciTasks = fromDot(ciTaskDepsDot); const rootNode = ciTasks.nodes.find( @@ -58,9 +63,19 @@ const getNodeLabel = (node: NodeModel): string => { return label; }; +const getDependencies = ({ id }: NodeRef): NodeRef[] => { + return ciTasks.edges + .map(getEdgeTargets) + .filter(({ from }) => from.id === id) + .flatMap(({ to }) => [to, ...getDependencies(to)]); +}; + const tasks: { name: string; task: string; + // space separated list to use in `mise install` command + tools: string; + toolsHash: string; }[] = ciTasks.edges .map(getEdgeTargets) .filter(({ from }) => from.id === rootNode.id) @@ -68,9 +83,29 @@ const tasks: { const taskName = getNodeLabel(getNodeFromRef(to)); // remove prefix if exists const name = taskName.split(":")[1] ?? taskName; + const tool = miseTools.find((tool) => tool.includes(name)); + + const tools: string[] = tool ? [tool] : []; + + if (tool?.startsWith("npm")) { + tools.push("node"); + } + + const dependencies = getDependencies(to).map((node) => + getNodeLabel(getNodeFromRef(node)), + ); + // cspell:ignore buni + if (dependencies.some((dependency) => dependency.startsWith("buni"))) { + tools.push("bun", "node"); + } + return { name: name, task: taskName, + tools: tools.join(" "), + toolsHash: createHash("sha256") + .update(tools.sort().join("-")) + .digest("hex"), }; });