diff --git a/README.md b/README.md
index 6790d06..ce1226e 100644
--- a/README.md
+++ b/README.md
@@ -66,22 +66,23 @@ jobs:
## Inputs
-| name | description | required | default |
-| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------- |
-| `working-directory` |
Working directory for run commands
| `false` | `""` |
-| `test` | Whether to run tests
| `false` | `true` |
-| `stack-arguments` | Additional arguments for all top-level stack
command invocations.
| `false` | `--no-terminal` |
-| `stack-query-arguments` | Additional arguments in stack query
invocations.
| `false` | `""` |
-| `stack-path-arguments` | Additional arguments in stack path
invocations.
| `false` | `""` |
-| `stack-setup-arguments` | Additional arguments in stack setup
invocations.
| `false` | `""` |
-| `stack-build-arguments` | Additional arguments for all stack build
invocations.
| `false` | `--fast --pedantic` |
-| `stack-build-arguments-dependencies` | Additional arguments passed after stack-build-arguments
in stack build
invocations on the Dependencies step.
| `false` | `""` |
-| `stack-build-arguments-build` | Additional arguments passed after stack-build-arguments
in stack build
invocations on the Build step.
| `false` | `""` |
-| `stack-build-arguments-test` | Additional arguments passed after stack-build-arguments
in stack build
invocations on the Test step.
| `false` | `""` |
-| `cache-prefix` | Prefix applied to all cache keys. This can be any value you like, but teams often use v{N}
and bump it to v{N+1}
when/if they need to explicitly bust caches.
| `false` | `""` |
-| `cache-save-always` | Save artifacts to the cache even if the build fails. This may speed up builds in subsequent runs at the expense of slightly-longer builds when a full cache-hit occurs. Since @v4.2.0
| `false` | `false` |
-| `upgrade-stack` | Upgrade stack
| `false` | `true` |
-| `stack-yaml` | Deprecated use env.STACK_YAML
or stack-arguments
instead.
| `false` | `""` |
+| name | description | required | default |
+| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------- |
+| `working-directory` | Working directory for run commands
| `false` | `""` |
+| `test` | Whether to run tests
| `false` | `true` |
+| `stack-arguments` | Additional arguments for all top-level stack
command invocations.
| `false` | `--no-terminal` |
+| `stack-query-arguments` | Additional arguments in stack query
invocations.
| `false` | `""` |
+| `stack-path-arguments` | Additional arguments in stack path
invocations.
| `false` | `""` |
+| `stack-setup-arguments` | Additional arguments in stack setup
invocations.
| `false` | `""` |
+| `stack-build-arguments` | Additional arguments for all stack build
invocations.
| `false` | `--fast --pedantic` |
+| `stack-build-arguments-dependencies` | Additional arguments passed after stack-build-arguments
in stack build
invocations on the Dependencies step.
| `false` | `""` |
+| `stack-build-arguments-build` | Additional arguments passed after stack-build-arguments
in stack build
invocations on the Build step.
| `false` | `""` |
+| `stack-build-arguments-test` | Additional arguments passed after stack-build-arguments
in stack build
invocations on the Test step.
| `false` | `""` |
+| `cache-prefix` | Prefix applied to all cache keys. This can be any value you like, but teams often use v{N}
and bump it to v{N+1}
when/if they need to explicitly bust caches.
| `false` | `""` |
+| `cache-save-always` | Save artifacts to the cache even if the build fails. This may speed up builds in subsequent runs at the expense of slightly-longer builds when a full cache-hit occurs. Since @v4.2.0
.
| `false` | `false` |
+| `upgrade-stack` | Upgrade stack
| `false` | `true` |
+| `compiler-tools` | A list of packages to install as compiler tools, one per line. This is useful to do here rather than separate run
commands so that their installation is incorporated in the dependency cache. Since @v5.2.0
.
| `false` | `""` |
+| `stack-yaml` | Deprecated use env.STACK_YAML
or stack-arguments
instead.
| `false` | `""` |
@@ -114,6 +115,32 @@ jobs:
| `dist-dir` | dist-dir
value from stack path
|
| `local-hpc-root` | local-hpc-root
value from stack path
|
+## Installing Compiler Tools
+
+The `compiler-tools` input can be used to install packages (with
+`--copy-compiler-tool`) as part of the _Dependencies_ step. The installed tools
+can be used by other parts of the build via `stack exec`, such as to reformat
+and upload coverage:
+
+```yaml
+- id: stack
+ uses: freckle/stack-action@v5
+ with:
+ compiler-tools: hpc-lcov
+ stack-build-arguments: --coverage
+
+- run: stack --no-terminal exec -- hpc-lcov --file "$HPC_ROOT"/combined/all/all.tix
+ env:
+ HPC_ROOT: ${{ steps.stack.outputs.local-hpc-root }}
+
+- uses: codecov/codecov-action@v2
+ with:
+ files: ./lcov.info
+```
+
+Doing it this way, vs a separate `run: stack install...`, means the building of
+these tools will be included in the dependencies cache.
+
## Generating a Build Matrix of `stack.yaml`s
The following automatically discovers all files matching `stack*.yaml` and runs
diff --git a/action.yml b/action.yml
index a4676c9..80d4bb6 100644
--- a/action.yml
+++ b/action.yml
@@ -46,12 +46,17 @@ inputs:
description: |
Save artifacts to the cache even if the build fails. This may speed up
builds in subsequent runs at the expense of slightly-longer builds when a
- full cache-hit occurs. Since `@v4.2.0`
+ full cache-hit occurs. Since `@v4.2.0`.
default: false
upgrade-stack:
description: |
Upgrade stack
default: true
+ compiler-tools:
+ description: |
+ A list of packages to install as compiler tools, one per line. This is
+ useful to do here rather than separate `run` commands so that their
+ installation is incorporated in the dependency cache. Since `@v5.2.0`.
stack-yaml:
description: |
**Deprecated** use `env.STACK_YAML` or `stack-arguments` instead.
diff --git a/dist/index.js b/dist/index.js
index cf07964..43a4060 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -137,6 +137,7 @@ function getInputs() {
cachePrefix: core.getInput("cache-prefix"),
cacheSaveAlways: core.getBooleanInput("cache-save-always"),
upgradeStack: core.getBooleanInput("upgrade-stack"),
+ compilerTools: core.getMultilineInput("compiler-tools"),
stackYaml: getInputDefault("stack-yaml", null),
};
}
@@ -230,6 +231,7 @@ async function run() {
await (0, with_cache_1.withCache)([stackRoot, stackPrograms].concat(stackWorks), (0, get_cache_keys_1.getCacheKeys)([`${cachePrefix}/deps`, hashes.snapshot, hashes.package]), async () => {
await stack.setup(inputs.stackSetupArguments);
await stack.buildDependencies(inputs.stackBuildArgumentsDependencies);
+ await stack.installCompilerTools(inputs.compilerTools);
}, {
...with_cache_1.DEFAULT_CACHE_OPTIONS,
saveOnError: inputs.cacheSaveAlways,
@@ -432,6 +434,12 @@ class StackCLI {
async setup(args) {
return await this.exec(["setup"].concat(args));
}
+ async installCompilerTools(tools) {
+ if (tools.length > 0) {
+ return await this.exec(["install", "--copy-compiler-tool"].concat(tools));
+ }
+ return 0;
+ }
async buildDependencies(args) {
return await this.buildNoTest(["--dependencies-only"].concat(args));
}
diff --git a/src/inputs.ts b/src/inputs.ts
index 542aeae..43a8995 100644
--- a/src/inputs.ts
+++ b/src/inputs.ts
@@ -14,6 +14,7 @@ export type Inputs = {
cachePrefix: string;
cacheSaveAlways: boolean;
upgradeStack: boolean;
+ compilerTools: string[];
// Deprecated
stackYaml: string | null;
@@ -38,6 +39,7 @@ export function getInputs(): Inputs {
cachePrefix: core.getInput("cache-prefix"),
cacheSaveAlways: core.getBooleanInput("cache-save-always"),
upgradeStack: core.getBooleanInput("upgrade-stack"),
+ compilerTools: core.getMultilineInput("compiler-tools"),
stackYaml: getInputDefault("stack-yaml", null),
};
}
diff --git a/src/main.ts b/src/main.ts
index 9c0cd32..acd41dd 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -78,6 +78,7 @@ async function run() {
async () => {
await stack.setup(inputs.stackSetupArguments);
await stack.buildDependencies(inputs.stackBuildArgumentsDependencies);
+ await stack.installCompilerTools(inputs.compilerTools);
},
{
...DEFAULT_CACHE_OPTIONS,
diff --git a/src/stack-cli.test.ts b/src/stack-cli.test.ts
index bda02b5..f142206 100644
--- a/src/stack-cli.test.ts
+++ b/src/stack-cli.test.ts
@@ -64,6 +64,24 @@ describe("StackCLI", () => {
);
});
+ test("installCompilerTools", async () => {
+ const stackCLI = new StackCLI([], false);
+ await stackCLI.installCompilerTools(["hlint", "weeder"]);
+
+ expect(exec.exec).toHaveBeenCalledWith(
+ "stack",
+ ["install", "--copy-compiler-tool", "hlint", "weeder"],
+ undefined,
+ );
+ });
+
+ test("installCompilerTools with empty arguments", async () => {
+ const stackCLI = new StackCLI([], false);
+ await stackCLI.installCompilerTools([]);
+
+ expect(exec.exec).not.toHaveBeenCalled();
+ });
+
test("buildDependencies", async () => {
const stackCLI = new StackCLI([], false);
diff --git a/src/stack-cli.ts b/src/stack-cli.ts
index 5c88afa..d7999a5 100644
--- a/src/stack-cli.ts
+++ b/src/stack-cli.ts
@@ -57,6 +57,15 @@ export class StackCLI {
return await this.exec(["setup"].concat(args));
}
+ async installCompilerTools(tools: string[]): Promise {
+ if (tools.length > 0) {
+ return await this.exec(["install", "--copy-compiler-tool"].concat(tools));
+ }
+
+ // No tools to install
+ return 0;
+ }
+
async buildDependencies(args: string[]): Promise {
return await this.buildNoTest(["--dependencies-only"].concat(args));
}