Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freckle/stack-action
GitHub Action to build, test, and lint Stack-based Haskell projects
https://github.com/freckle/stack-action
github-actions haskell stack
Last synced: about 1 month ago
JSON representation
GitHub Action to build, test, and lint Stack-based Haskell projects
- Host: GitHub
- URL: https://github.com/freckle/stack-action
- Owner: freckle
- License: mit
- Created: 2021-01-19T15:50:44.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-16T19:52:02.000Z (about 2 months ago)
- Last Synced: 2024-12-16T19:52:21.290Z (about 2 months ago)
- Topics: github-actions, haskell, stack
- Language: TypeScript
- Homepage:
- Size: 2.29 MB
- Stars: 20
- Watchers: 17
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stack Action
GitHub Action to build and test a stack-based Haskell project.
## Usage
```yaml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: freckle/stack-action@v5
```## Notable Changes in v5
As of version 5, the single `stack-arguments` input has been broken up into
various, distinct `stack-[*-]arguments[-*]` inputs that are used in more
specific ways. See the _Inputs_ section, or `action.yml` for documentation of
the new options.The `fast` and `pedantic` inputs were removed. Use a ternary operator (see
[Operators](https://docs.github.com/en/actions/learn-github-actions/expressions#operators))
to pass a flag conditionally. Example:```yaml
stack-build-arguments: ${{ github.ref_name != 'main' && '--fast' || '' }} --pedantic
```## Notable Changes in v4
As of version 4, this action automatically handles caching. You do not need to
use a separate `stack-cache-action` step any more.## Notable Changes in v3
Previous versions of this Action ran HLint and Weeder for you. We recommend
doing that as separate actions now, so, as of `v3`, those options have been
removed.Here is an example of running separate Actions:
```yaml
jobs:
test:
# ...
steps:
- uses: actions/checkout@v4
- id: stack
uses: freckle/stack-action@v5# Weeder requires running in the same Job (to access .hie artifacts)
- uses: freckle/weeder-action@v2
with:
ghc-version: ${{ steps.stack.outputs.compiler-version }}# HLint can be a distinct Job, possibly limited to changed files
hlint:
# ...
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/hlint-setup@v1
- uses: haskell-actions/hlint-run@v2
```## 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
| `false` | `--no-terminal` |stack
command invocations.
| `stack-query-arguments` |Additional arguments in
| `false` | `""` |stack query
invocations.
| `stack-path-arguments` |Additional arguments in
| `false` | `""` |stack path
invocations.
| `stack-setup-arguments` |Additional arguments in
| `false` | `""` |stack setup
invocations.
| `stack-build-arguments` |Additional arguments for all
| `false` | `--fast --pedantic` |stack build
invocations.
| `stack-build-arguments-dependencies` |Additional arguments passed after
| `false` | `""` |stack-build-arguments
instack build
invocations on the Dependencies step.
| `stack-build-arguments-build` |Additional arguments passed after
| `false` | `""` |stack-build-arguments
instack build
invocations on the Build step.
| `stack-build-arguments-test` |Additional arguments passed after
| `false` | `""` |stack-build-arguments
instack build
invocations on the Test step.
| `cache-prefix` |Prefix applied to all cache keys. This can be any value you like, but teams often use
| `false` | `""` |v{N}
and bump it tov{N+1}
when/if they need to explicitly bust caches.
| `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
| `false` | `false` |@v4.2.0
.
| `on-dirty-files` |What to do if we find changes to the cabal or lock file after a build. Value can be
| `false` | `warn` |warn
, orerror
. Default iswarn
.
| `install-stack` |Install stack, if necessary
| `false` | `true` |
| `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
| `false` | `""` |run
commands so that their installation is incorporated in the dependency cache. Since@v5.2.0
.
| `stack-yaml` |Deprecated use
| `false` | `""` |env.STACK_YAML
orstack-arguments
instead.## Outputs
| name | description |
| ----------------------- | ---------------------------------------------------------------------------- |
| `compiler` ||
compiler.actual
value from stack query
| `compiler-version` |The GHC version part of compiler
|
| `snapshot-doc-root` ||
snapshot-doc-root
value fromstack path
| `local-doc-root` ||
local-doc-root
value fromstack path
| `local-hoogle-root` ||
local-hoogle-root
value fromstack path
| `stack-root` ||
stack-root
value fromstack path
| `project-root` ||
project-root
value fromstack path
| `config-location` ||
config-location
value fromstack path
| `bin-path` ||
bin-path
value fromstack path
| `programs` ||
programs
value fromstack path
| `compiler-exe` ||
compiler-exe
value fromstack path
| `compiler-bin` ||
compiler-bin
value fromstack path
| `compiler-tools-bin` ||
compiler-tools-bin
value fromstack path
| `local-bin` ||
local-bin
value fromstack path
| `extra-include-dirs` ||
extra-include-dirs
value fromstack path
| `extra-library-dirs` ||
extra-library-dirs
value fromstack path
| `snapshot-pkg-db` ||
snapshot-pkg-db
value fromstack path
| `local-pkg-db` ||
local-pkg-db
value fromstack path
| `global-pkg-db` ||
global-pkg-db
value fromstack path
| `ghc-package-path` ||
ghc-package-path
value fromstack path
| `snapshot-install-root` ||
snapshot-install-root
value fromstack path
| `local-install-root` ||
local-install-root
value fromstack path
| `dist-dir` ||
dist-dir
value fromstack path
| `local-hpc-root` ||
local-hpc-root
value fromstack 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
this action with each of them:```yaml
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: generate
uses: freckle/stack-action/generate-matrix@v5
outputs:
stack-yamls: ${{ steps.generate.outputs.stack-yamls }}test:
needs: generate
strategy:
matrix:
stack-yaml: ${{ fromJSON(needs.generate.outputs.stack-yamls) }}
fail-fast: falseruns-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: freckle/stack-action@v5
with:
stack-arguments: --stack-yaml ${{ matrix.stack-yaml }}
```See [generate-matrix/action.yml](./generate-matrix/action.yml) for more details.
This has been available since version 4 of this action.---
[LICENSE](./LICENSE)