Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mpizenberg/elm-tooling-action
GitHub action to install Elm tools and cache ELM_HOME
https://github.com/mpizenberg/elm-tooling-action
action elm
Last synced: about 2 months ago
JSON representation
GitHub action to install Elm tools and cache ELM_HOME
- Host: GitHub
- URL: https://github.com/mpizenberg/elm-tooling-action
- Owner: mpizenberg
- Created: 2021-02-21T19:11:06.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-26T16:49:19.000Z (11 months ago)
- Last Synced: 2024-10-13T06:18:33.389Z (2 months ago)
- Topics: action, elm
- Language: JavaScript
- Homepage:
- Size: 1.24 MB
- Stars: 11
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elm tooling action
> Warning: do not use this if you have a JavaScript `package.json` already.
> In such cases, follow instead the default npm-based CI setup as described here:
> https://elm-tooling.github.io/elm-tooling-cli/ci/This action lets you install tools supported by elm-tooling,
such as elm, elm-format, elm-json and elm-test-rs in your GitHub CI,
without the need of npm and `package.json`.It will also cache your home Elm directory,
as defined by the `ELM_HOME` environment variable,
for more efficient builds! You can use this action as follows.```yaml
- name: Install elm, elm-format and cache the ELM_HOME directory
uses: mpizenberg/[email protected]
with:
cache-key: elm-home-${{ hashFiles('elm-tooling.json', 'elm.json') }}- name: Making sure the installation worked
run: elm --version
```Where your `elm-tooling.json` file states your elm and tools versions
as specified in the [elm-tooling.json][spec].
It should look like follows.```json
{
"tools": {
"elm": "0.19.1",
"elm-format": "0.8.5"
}
}
```[spec]: https://elm-tooling.github.io/elm-tooling-cli/spec/
## Advanced usage
There are two additional keys providing more flexibility for some use cases.
1. `cache-restore-key`: A key for restoring the cache if no cache hit occurred for cache-key.
2. `elm-tooling-dir`: The directory containing the `elm-tooling.json` file. If not provided, it defaults to the project root.```yaml
- uses: mpizenberg/[email protected]
with:
cache-key: elm-home-${{ hashFiles('elm-tooling.json', 'elm.json') }}
cache-restore-key: elm-home
elm-tooling-dir: some/sub/directory
```## Caching effectively
For security reasons, GitHub actions only have access to caches created
in the current branch, a parent branch or the main branch.
So if you want cache hits in the first push of your PR branches,
a matching cache (primary or restoration key) must have been created
in the main branch before.
So I'd suggest running your CI both on PR and on a push to the main branch.More info regarding cache restriction is available on [GitHub docs][cache].
[cache]: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
## Notes
Internally, what this does is calling `elm-tooling install`
from the `elm-tooling-dir` directory or the root directory
if that is not defined.
This means it will install the tools somewhere in `ELM_HOME/elm-tooling/`,
add links to those tools in `elm-tooling-dir/node_modules/.bin/`,
and then we add `elm-tooling-dir/node_modules/.bin` to the `PATH`
so that the executables become available to you.