This page explains how to install Elm tools from
elm-tooling.json in a Continuous Integration (CI) scenario, such as GitHub Actions.
See the Example GitHub Actions workflow for inspiration. Even if you don’t use GitHub Actions it’s still a good resource – there’s a lot of comments and the concepts and steps should be fairly similar regardless of what CI you use.
Basically, you need to:
Install npm packages, with
NO_ELM_TOOLING_INSTALLset. It’s nice to cache
node_modules(based on your
package-lock.json) for speed and reliability.
NO_ELM_TOOLING_INSTALLenvironment variable turns
elm-tooling installinto a no-op, in case you have a
"postinstall": "elm-tooling install"script in your
package.json. In CI it’s better to install npm packages and
elm-tooling.jsontools separately so you can cache
Install tools from
npx --no-install elm-tooling install. Make sure that
~/.elmis cached (or
ELM_HOMEif you’ve set it), based on
elm.json(because it lists your Elm dependencies and the Elm compiler installs packages into
elm-tooling.json(because it lists your tools and
elm-toolingdownloads them into
~/.elm) as well as
review/elm.jsonif you use elm-review or whatever other
elm.jsonfiles you might have.
Note that Windows uses
~/.elm. If you need to run the same CI workflow both Windows and some other OS, set
ELM_HOMEto a directory that works everywhere.
Run whatever commands you want.
mpizenberg/elm-tooling-action is a GitHub Action that:
- Contains its own copy of
elm-tooling installfor you.
~/.elmfor you (in a way that works on both Windows and other operating systems).
It’s primarily made for projects that don’t have a
package.json (it’s up to every contributor to install Elm and elm-format etc themselves). Such projects still need to install the tools in CI somehow, and elm-tooling-action fits exactly that need.
You can use elm-tooling-action even if you have a
package.json and have
elm-tooling in there. But beware that you might not be running exactly the same version of
elm-tooling locally and in CI! So if something works locally but not in CI (or vice versa), that could be the culprit. You don’t save super much YAML config by using the action in this case, so it’s currently not recommended. But you decide!