Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Feb 10, 2024
1 parent 8d25176 commit 649c703
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/exec-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ExecStack {
}

async upgrade(): Promise<number> {
return await exec.exec("stack", ["upgrade"]);
return await exec.exec("stack", ["upgrade"], { ignoreReturnCode: true });
}

async exec(args: string[], options?: exec.ExecOptions): Promise<number> {
Expand Down
8 changes: 3 additions & 5 deletions src/hash-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ export type Hashes = {
};

export async function hashProject(stackYaml: string): Promise<Hashes> {
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),
};
}
35 changes: 18 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
await stack.exec(["setup"].concat(inputs.stackSetupArguments));
await stack.exec(
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 649c703

Please sign in to comment.