Files
setup-elixir/README.md

150 lines
4.1 KiB
Markdown
Raw Permalink Normal View History

2019-08-28 00:00:01 -04:00
# setup-elixir
2021-01-19 16:04:46 -05:00
**Please note: This repository is currently unmaintained by a team of developers at GitHub. It is now maintained by the [Erlang Ecosystem Foundation](https://erlef.org) at [erlef/setup-elixir](https://github.com/erlef/setup-elixir). Rather than using actions/setup-elixir, please begin referring to that action in your workflows, instead.**
2019-08-28 00:00:01 -04:00
[![](https://github.com/actions/setup-elixir/workflows/Test/badge.svg)](https://github.com/actions/setup-elixir/actions)
2019-08-28 17:25:36 -04:00
[![](https://github.com/actions/setup-elixir/workflows/Licensed/badge.svg)](https://github.com/actions/setup-elixir/actions)
2019-08-28 00:00:01 -04:00
2020-01-08 13:55:53 -05:00
This action sets up an Elixir environment for use in a GitHub Actions
workflow by:
2019-08-28 00:00:01 -04:00
- Installing OTP
- Installing Elixir
**Note** Currently, this action currently only supports Actions' `ubuntu-` runtimes.
## Usage
See [action.yml](action.yml).
**Note** The OTP release version specification is [relatively
complex](http://erlang.org/doc/system_principles/versions.html#version-scheme).
For best results, we recommend specifying exact OTP and Elixir versions.
However, values like `22.x` are also accepted, and we attempt to resolve them
according to semantic versioning rules.
2019-08-28 00:00:01 -04:00
Additionally, it is recommended that one specifies OTP and Elixir versions
using YAML strings, as these examples do, so that numbers like `23.0` don't
end up being parsed as `23`, which is not equivalent.
2020-09-17 12:14:31 -04:00
For pre-release Elixir versions, such as `1.11.0-rc.0`, use the full version
specifier (`1.11.0-rc.0`). Pre-release versions are opt-in, so `1.11.x` will
not match a pre-release.
2019-08-28 00:00:01 -04:00
### Basic example
```yaml
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
2020-01-05 14:30:47 -08:00
- uses: actions/checkout@v2
2019-11-08 16:38:58 +00:00
- uses: actions/setup-elixir@v1
2019-08-28 00:00:01 -04:00
with:
otp-version: '22.2'
elixir-version: '1.9.4'
2019-08-28 00:00:01 -04:00
- run: mix deps.get
- run: mix test
```
### Matrix example
```yaml
on: push
jobs:
test:
runs-on: ubuntu-latest
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: ['20.3', '21.3', '22.2']
elixir: ['1.8.2', '1.9.4']
2019-08-28 00:00:01 -04:00
steps:
2020-01-05 14:30:47 -08:00
- uses: actions/checkout@v2
2019-11-08 16:38:58 +00:00
- uses: actions/setup-elixir@v1
2019-08-28 00:00:01 -04:00
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- run: mix deps.get
- run: mix test
```
2019-08-28 17:54:06 -04:00
### Phoenix example
```yaml
on: push
jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:11
ports: ['5432:5432']
env:
POSTGRES_PASSWORD: postgres
2019-08-28 17:54:06 -04:00
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
2020-01-05 14:30:47 -08:00
- uses: actions/checkout@v2
2019-11-08 16:38:58 +00:00
- uses: actions/setup-elixir@v1
2019-08-28 17:54:06 -04:00
with:
otp-version: '22.2'
elixir-version: '1.9.4'
2019-08-28 17:54:06 -04:00
- run: mix deps.get
- run: mix test
```
2020-01-08 14:05:40 -05:00
#### Authenticating with Postgres in Phoenix
When using the Phoenix example above, the `postgres` container has some
default authentication set up. Specifically, it expects a username of
"postgres", and a password of "postgres". It will be available at
`localhost:5432`.
The simplest way of setting these auth values in CI is by checking for the
`GITHUB_ACTIONS` environment variable that is set in all workflows:
```elixir
# config/test.exs
use Mix.Config
# Configure the database for local testing
config :app, App.Repo,
database: "my_app_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox
# Configure the database for GitHub Actions
if System.get_env("GITHUB_ACTIONS") do
config :app, App.Repo,
username: "postgres",
password: "postgres"
end
```
2020-08-05 13:08:02 -04:00
## Matchers
2020-08-05 14:06:40 -04:00
The problem matchers in this repository are adapted from [here](https://github.com/fr1zle/vscode-elixir/blob/45eddb589acd7ac98e0c7305d1c2b24668ca709a/package.json#L70-L118). See [MATCHER_NOTICE](MATCHER_NOTICE.md) for license details.
2020-08-05 13:08:02 -04:00
2019-08-28 00:00:01 -04:00
## License
The scripts and documentation in this project are released under the [MIT license](LICENSE.md).
## Contributing
Check out [this doc](CONTRIBUTING.md).
## Current Status
This action is in active development.