From 649c703c0a2a5d0a5c521ec0d3b2c0962a99d21f Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sat, 10 Feb 2024 10:26:06 -0500 Subject: [PATCH] WIP --- src/exec-stack.ts | 2 +- src/hash-project.ts | 8 +++----- src/main.ts | 35 ++++++++++++++++++----------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/exec-stack.ts b/src/exec-stack.ts index a049586..c08d9e4 100644 --- a/src/exec-stack.ts +++ b/src/exec-stack.ts @@ -16,7 +16,7 @@ export class ExecStack { } async upgrade(): Promise { - return await exec.exec("stack", ["upgrade"]); + return await exec.exec("stack", ["upgrade"], { ignoreReturnCode: true }); } async exec(args: string[], options?: exec.ExecOptions): Promise { diff --git a/src/hash-project.ts b/src/hash-project.ts index 4070cac..3f75b30 100644 --- a/src/hash-project.ts +++ b/src/hash-project.ts @@ -11,11 +11,9 @@ export type Hashes = { }; export async function hashProject(stackYaml: string): Promise { - const workspace = process.cwd(); - return { - snapshot: await hashFiles(stackYaml, workspace), - package: await hashFiles(BUILD_FILES_PATTERNS, workspace), - sources: await hashFiles(ALL_SOURCES_PATTERNS, workspace), + snapshot: await hashFiles(stackYaml), + package: await hashFiles(BUILD_FILES_PATTERNS), + sources: await hashFiles(ALL_SOURCES_PATTERNS), }; } diff --git a/src/main.ts b/src/main.ts index d9a834a..e40ce80 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,14 +10,6 @@ import { parseStackQuery } from "./parse-stack-query"; import { readStackYamlSync, packagesStackWorks } from "./stack-yaml"; import { DEFAULT_CACHE_OPTIONS, withCache } from "./with-cache"; -// function setOutputs(stackQuery: StackQuery, stackPath: StackPath): void { -// core.setOutput("compiler", stackQuery.compiler.actual); -// core.setOutput( -// "compiler-version", -// stackQuery.compiler.actual.replace(/^ghc-/, ""), -// ); -// } - async function dependencies(stack: ExecStack, inputs: Inputs): Promise { await stack.exec(["setup"].concat(inputs.stackSetupArguments)); await stack.exec( @@ -70,9 +62,13 @@ async function run() { await stack.parse(["path", "--stack-root]"], parseStackPath) )["stack-root"]; + core.info(`Stack root: ${stackRoot}`); + const stackYaml = readStackYamlSync(inputs.stackYaml); const stackWorks = packagesStackWorks(stackYaml); + core.info(`Stack works:\n - ${stackWorks.join("\n - ")}`); + await core.group("Dependencies", async () => { const cacheKeys = getCacheKeys([ inputs.cachePrefix("stack-deps", stackYaml.resolver), @@ -102,25 +98,30 @@ async function run() { }); }); - if (inputs.test) { - await core.group("Test", async () => await test(stack, inputs)); - } + await core.group("Test", async () => { + if (inputs.test) { + await test(stack, inputs); + } + }); const stackQuery = await stack.parse( ["query", "compiler"], parseStackQuery, ); - core.setOutput("compiler", stackQuery.compiler.actual); - core.setOutput( - "compiler-version", - stackQuery.compiler.actual.replace(/^ghc-/, ""), - ); + const compiler = stackQuery.compiler.actual; + const compilerVersion = compiler.replace(/^ghc-/, ""); + + core.debug(`Setting compiler outputs: ${compiler} / ${compilerVersion}`); + core.setOutput("compiler", compiler); + core.setOutput("compiler-version", compilerVersion); const stackPath = await stack.parse(["path"], parseStackPath); for (const k in stackPath) { - core.setOutput(k, stackPath[k]); + const v = stackPath[k]; + core.debug(`Setting stack-path output: ${k}=${v}`); + core.setOutput(k, v); } } catch (error) { if (error instanceof Error) {