Giter VIP home page Giter VIP logo

setup-elixir's Introduction

setup-elixir

Please note: This repository is currently unmaintained by a team of developers at GitHub. It is now maintained by the Erlang Ecosystem Foundation at erlef/setup-elixir. Rather than using actions/setup-elixir, please begin referring to that action in your workflows, instead.

This action sets up an Elixir environment for use in a GitHub Actions workflow by:

  • Installing OTP
  • Installing Elixir

Note Currently, this action currently only supports Actions' ubuntu- runtimes.

Usage

See action.yml.

Note The OTP release version specification is relatively complex. 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.

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.

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.

Basic example

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-elixir@v1
        with:
          otp-version: '22.2'
          elixir-version: '1.9.4'
      - run: mix deps.get
      - run: mix test

Matrix example

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']
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-elixir@v1
        with:
          otp-version: ${{matrix.otp}}
          elixir-version: ${{matrix.elixir}}
      - run: mix deps.get
      - run: mix test

Phoenix example

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    services:
      db:
        image: postgres:11
        ports: ['5432:5432']
        env:
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-elixir@v1
        with:
          otp-version: '22.2'
          elixir-version: '1.9.4'
      - run: mix deps.get
      - run: mix test

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:

# 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

Matchers

The problem matchers in this repository are adapted from here. See MATCHER_NOTICE for license details.

License

The scripts and documentation in this project are released under the MIT license.

Contributing

Check out this doc.

Current Status

This action is in active development.

setup-elixir's People

Contributors

deniskulicek avatar doughsay avatar ericmj avatar ethomson avatar jclem avatar mijailr avatar myobie avatar nathany avatar thboop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

setup-elixir's Issues

libcrypto.so.1.0.0 error on Ubuntu 20.04

I am still receiving the libcrypto.so.1.0.0 error referenced in #31 when running the action against Ubuntu-20.04. The project is a bare generated Phoenix application requiring Elixir 1.11.2 and OTP 23.1. Is there a specific way I need to specify the runs-on value to use the container from bob?

 /home/runner/work/_temp/.setup-elixir/elixir/bin/mix local.rebar --force

Error: 7.344 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library /home/runner/work/_temp/.setup-elixir/otp/lib/crypto-4.8/priv/lib/crypto: 'libcrypto.so.1.0.0: cannot open shared object file: No such file or directory'"
OpenSSL might not be installed on this system.


14:05:07.351 [warn]  The on_load function for module crypto returned:
{:error,
 {:load_failed,
  'Failed to load NIF library /home/runner/work/_temp/.setup-elixir/otp/lib/crypto-4.8/priv/lib/crypto: \'libcrypto.so.1.0.0: cannot open shared object file: No such file or directory\''}}

** (Mix) httpc request failed with: {:failed_connect, [{:to_address, {'repo.hex.pm', 443}}, {:inet, [:inet], {:eoptions, {:undef, [{:crypto, :supports, [], []}, {:tls_record, :sufficient_support, 1, [file: 'tls_record.erl', line: 743]}, {:tls_record, :supported_protocol_versions, 1, [file: 'tls_record.erl', line: 370]}, {:tls_record, :supported_protocol_versions, 0, [file: 'tls_record.erl', line: 358]}, {:ssl, :handle_option, 4, [file: 'ssl.erl', line: 1920]}, {:ssl, :process_options, 3, [file: 'ssl.erl', line: 1644]}, {:ssl, :handle_options, 3, [file: 'ssl.erl', line: 1598]}, {:ssl, :connect, 4, [file: 'ssl.erl', line: 600]}]}}}]}

Could not install Rebar because Mix could not download metadata at https://repo.hex.pm/installs/rebar-1.x.csv.

Error: The process '/home/runner/work/_temp/.setup-elixir/elixir/bin/mix' failed with exit code 1
name: Elixir CI

on: [push, pull_request]

jobs:
  build:

    name: Build and test
    runs-on: ubuntu-20.04

    steps:
    - uses: actions/checkout@v2
    - name: Set up Elixir
      uses: actions/setup-elixir@v1
      with:
        elixir-version: '1.11.2' # Define the elixir version [required]
        otp-version: '23.1' # Define the OTP version [required]
    - name: Restore dependencies cache
      uses: actions/cache@v2
      with:
        path: deps
        key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
        restore-keys: ${{ runner.os }}-mix-
    - name: Install dependencies
      run: mix deps.get
    - name: Run tests
      run: mix test

Running setup-elixir step on self-hosted runner

Hi ๐Ÿ‘‹

I'm trying to run this step on a a self-hosted worker.

Installing OTP works, while installing Elixir I get this output and error :

  /home/github-action-runner-01/actions-runner/_work/_actions/actions/setup-elixir/v1/src/install-elixir v1.9.4 -otp-22
  Archive:  v1.9.4-otp-22.zip
     creating: .setup-elixir/elixir/bin/
    inflating: .setup-elixir/elixir/bin/elixirc
...
 mix local.rebar --force
/tmp/.setup-elixir/elixir/bin/elixir: 228: exec: erl: not found
##[error]The process 'mix' failed with exit code 127


Looks like the Elixir script doesn't know that the otp is installed in /tmp/.setup-elixir/otp/bin/erl. Is there a env variable that I'm missing to config?

I've been using setup-elixir in my public repos and works perfectly using GitHub's own workers


this is my workflow config for the reference.
name: Test

on: [push]

env:
  CI: true
  MIX_ENV: test

jobs:
  build:
    runs-on: self-hosted
    services:
      db:
        image: postgres:9.6-alpine
        env:
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

    steps:
      - uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.MY_PRIV_REPO_KEY }}
      - uses: actions/checkout@v2
      - name: Setup elixir
        uses: actions/setup-elixir@v1
        with:
          elixir-version: 1.9.4
          otp-version: 22.2
      - name: Install Dependencies
        run: |
          mix deps.get
      - name: Run Tests
        run: |
          mix test

Document which precompiled elixir is used

From the source code, it detects the otp major version from otp-version, and append it to Bob's elixir version (so 1.11.0 would be 1.11.0-otp-23.

I like this default behavior since it uses the specific precompiled elixir matched to the given otp version... but I think 1) where the elixir binary from and 2) which elixir binary will be fetched should be noted in the README for clarity.

(Ideally, I think it would be better to use the elixir-version as-is for Bob's elixir - so I can just pass 1.11.0-otp-22 as elixir-version - and I can test it against OTP 23 for example. Is it possible?)

Erlang/OTP version resolution does not work as expected

Problem

From README:

However, values like 22.x are also accepted, and we attempt to resolve them according to semantic versioning rules.

Erlang/OTP version does not conform to SemVer, into the format outlined in SemVer 2.0 schema (i.e., MAJOR.MINOR.PATCH), so 22.x will not resolve to 22.3.4.11 as expected.

More specifically, actions/setup-elixir v1.4.0 uses semantic version resolution for Erlang/OTP, but Erlang/OTP version scheme does not follow SemVer and "In general, versions can have more than three parts.", so otp: 19.x resolves to 19.3.6, not 19.3.6.13, as expected.

Solution

Build a resolver that works with Erlang - Versions - 5.3 Version Scheme.

The following shell function, which uses asdf-erlang and sed, can be used as reference:

$ resolve_erlang_version () { asdf list-all erlang $(echo $1 | sed s/\.x/./) | tail -1; }
$ resolve_erlang_version 22.x
22.3.4.11
$ resolve_erlang_version 22.2.x
22.2.8
$ resolve_erlang_version 22.1.8.x
22.1.8.1

Use runner temp directory instead of /tmp/.setup-elixir

Currently, this action installs runtimes into /tmp/.setup-elixir. This directory isn't cleaned up after each run on self-hosted runners and we run into issues like this one.

Instead, we should:

  • Default to using the designated runner temp directory that is guaranteed to be empty at the start of each job.
  • Maybe make the installation directory configurable, as well.

add-path command is disabled for setup-elixir/elixir/VERSION

2020-11-18T05:34:50.5003816Z   inflating: .setup-elixir/elixir/README.md  
2020-11-18T05:34:50.5005549Z  extracting: .setup-elixir/elixir/VERSION  
2020-11-18T05:34:50.5042959Z ##[error]Unable to process command '::add-path::/tmp/.setup-elixir/elixir/bin' successfully.
2020-11-18T05:34:50.5050016Z ##[error]The `add-path` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
2020-11-18T05:34:50.5058682Z ##[endgroup]

Running in macOS

Currently, this action only runs on Ubuntu runtimes using precompiled builds from Hex.pm. There's definitely a need to support other runtimes, but we need to use precompiled builds for them. Without precompiled builds, I'm concerned about users inadvertently churning through their Actions usage by building Elixir and OTP from scratch every time they run a workflow.

Related Issues

git executable not found

I get the following error when trying to install mix dependencies via Git. Any idea how to fix?

** (Mix) Error fetching/updating Git repository: the "git" executable is not available in your PATH. Please install Git on this machine or pass --no-deps-check if you want to run a previously built application on a system without Git.

Error when using Elixir 1.11.0-rc.0

When upgrading my build to use Elixir 1.11.0-rc.0, I get the following error message

##[error]Cannot read property 'includes' of undefined

Here are a couple of example build failures:

It appears the problem could be the fact that this is a pre-release version, but I'm having trouble figuring out how to fix it.

Improve name of this action in Elixir CI template

Not sure if you think this belongs as an issue on this repo or not โ€“ I couldn't find another repo for it.

The Elixir CI template I got when setting up a new action uses "Setup elixir" as the name for the step calling this action.

A better name would perhaps be "Set up Elixir" - "Set up" being the verb ("Setup" is the noun) and capitalising Elixir.

Elixir action not running on Ubuntu 20.04

I just tried bumping the ubuntu version on the runner and now when Elixir action runs I get the following error:

/home/runner/work/_temp/.setup-elixir/elixir/bin/mix local.rebar --force

06:27:00.545 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library /home/runner/work/_temp/.setup-elixir/otp/lib/crypto-4.4.2/priv/lib/crypto: 'libcrypto.so.1.0.0: cannot open shared object file: No such file or directory'"
OpenSSL might not be installed on this system.


06:27:00.551 [warn]  The on_load function for module crypto returned:
***:error, ***:load_failed, 'Failed to load NIF library /home/runner/work/_temp/.setup-elixir/otp/lib/crypto-4.4.2/priv/lib/crypto: \'libcrypto.so.1.0.0: cannot open shared object file: No such file or directory\''***

** (Mix) httpc request failed with: ***:failed_connect, [***:to_address, ***'repo.hex.pm', 443***, ***:inet, [:inet], ***:eoptions, ***:undef, [***:crypto, :supports, [], []***, ***:tls_record, :supported_protocol_versions, 1, [file: 'tls_record.erl', line: 633]***, ***:tls_record, :supported_protocol_versions, 0, [file: 'tls_record.erl', line: 327]***, ***:ssl, :handle_options, 3, [file: 'ssl.erl', line: 1356]***, ***:ssl, :connect, 4, [file: 'ssl.erl', line: 446]***, ***:http_transport, :connect, 4, [file: 'http_transport.erl', line: 109]***, ***:httpc_handler, :connect, 4, [file: 'httpc_handler.erl', line: 786]***, ***:httpc_handler, :connect_and_send_first_request, 3, [file: 'httpc_handler.erl', line: 812]***]***]***

Could not install Rebar because Mix could not download metadata at https://repo.hex.pm/installs/rebar-1.x.csv.

##[error]The process '/home/runner/work/_temp/.setup-elixir/elixir/bin/mix' failed with exit code 1

Error: object null is not iterable

We are using setup-elixir for some time already, but recently it started to fail for us during elixir setup process.

Config looks like this:

      - uses: actions/setup-elixir@v1
        with:
          elixir-version: "1.10.4"
          otp-version: "23.0.2"

And the error we get is this:

image

Do you have an idea where should I look at or how can I resolve this issue? Thanks in advance

Not a regular file error with latest version

With the latest version, when running mix dialyzer, I've the following error:

07:54:47.738 [error] Process #PID<0.793.0> raised an exception
** (ErlangError) Erlang error: {:nocatch, {:dialyzer_error, [78, 111, 116, 32, 97, 32, 114, 101, 103, 117, 108, 97, 114, 32, 102, 105, 108, 101, 58, 32, '/tmp/.setup-elixir/otp/lib/hipe-3.19.3/ebin/erl_bif_types.beam', 10]}}
##[error]    dialyzer_plt.erl:543: :dialyzer_plt.compute_md5_from_file/1
##[error]    dialyzer_plt.erl:509: :dialyzer_plt.compute_new_md5_1/3
##[error]    dialyzer_plt.erl:328: :dialyzer_plt.check_version/1
##[error]    dialyzer_plt.erl:267: :dialyzer_plt.from_file1/3
##[error]    dialyzer_plt.erl:603: anonymous fn/1 in :dialyzer_plt.subproc/1
** (CaseClauseError) no case clause matching: {{:nocatch, {:dialyzer_error, [78, 111, 116, 32, 97, 32, 114, 101, 103, 117, 108, 97, 114, 32, 102, 105, 108, 101, 58, 32, '/tmp/.setup-elixir/otp/lib/hipe-3.19.3/ebin/erl_bif_types.beam', 10]}}, [{:dialyzer_plt, :compute_md5_from_file, 1, [file: 'dialyzer_plt.erl', line: 543]}, {:dialyzer_plt, :compute_new_md5_1, 3, [file: 'dialyzer_plt.erl', line: 509]}, {:dialyzer_plt, :check_version, 1, [file: 'dialyzer_plt.erl', line: 328]}, {:dialyzer_plt, :from_file1, 3, [file: 'dialyzer_plt.erl', line: 267]}, {:dialyzer_plt, :"-subproc/1-fun-0-", 1, [file: 'dialyzer_plt.erl', line: 603]}]}
##[error]    dialyzer_plt.erl:256: :dialyzer_plt.from_file/2
##[error]    dialyzer_cl.erl:365: :dialyzer_cl."-do_analysis/1-lc$^0/1-0-"/1
##[error]    dialyzer_cl.erl:365: :dialyzer_cl.do_analysis/1
##[error]    dialyzer.erl:160: :dialyzer.run/1
##[error]    (stdlib 3.12.1) timer.erl:181: :timer.tc/2
##[error]    lib/dialyxir/dialyzer.ex:47: Dialyxir.Dialyzer.Runner.run/2
##[error]    lib/dialyxir/dialyzer.ex:75: Dialyxir.Dialyzer.dialyze/3
##[error]    lib/mix/tasks/dialyzer.ex:267: Mix.Tasks.Dialyzer.run_dialyzer/2
##[error]Process completed with exit code 1.

Making the error more readable:

Not a regular file: /tmp/.setup-elixir/otp/lib/hipe-3.19.3/ebin/erl_bif_types.beam

I suspect it is related to the changes about tmp folder in the latest commit.

v1 tag?

Could we tag a v1? It would be consistent with most of the other actions in this organization, like checkout and other setup-foo workflows.

Needs erlang-dev to compile NIFs in otp-23

When using otp-23 and mix compile compiles libraries that have embedded NIFs, the build fails. The same build works fine on otp-22.3.4.

Example output where it fails (with the crc hex package):

==> crc
 C      checksum_xor.c
 C      crc_8.c
 C      crc_algorithm.c
 C      crc_model.c
 C      crc_nif.c
 C      crc_resource.c
 C      xnif_slice.c
 LD     crc_nif.so
/usr/bin/ld: cannot find -lerl_interface
collect2: error: ld returned 1 exit status
##[error]Makefile:159: recipe for target '/home/runner/work/legolas/legolas/_build/test/lib/crc/priv/crc_nif.so' failed
make: *** [/home/runner/work/legolas/legolas/_build/test/lib/crc/priv/crc_nif.so] Error 1
could not compile dependency :crc, "mix compile" failed. You can recompile this dependency with "mix deps.compile crc", update it with "mix deps.update crc" or clean it with "mix deps.clean crc"
  • This works fine with otp-22.3.4
  • This also works fine if doing a sudo apt-get install --yes erlang-dev before compile on otp-23.0

I had the same problem locally after upgrading to otp-23.0, and the fix with installing erlang-dev also helped there.
Perhaps it should be supported by setup-elixir to install that dependency automatically?

Problem matcher creates bogus annotations for failing tests

When running ExUnit tests with mix test after running this action as a step of an Actions job, the problem matchers defined create bogus annotations due to incorrectly parsed ExUnit results.

Minimal repository for reproduction: https://github.com/jswny/elixir-setup-actions-test.

The problem appears to be that it is picking up on stacktraces printed from failing tests, with each line being a single match from the problem matcher. In addition, it's pointing at the file .github, which isn't right either.

Bogus annotations created on the mix test step:

extract `setup-erlang`

As the subject suggests, extract and provide a separate setup-erlang to be used in separate steps.

Rename default branch

๐Ÿ‘‹ This issue is to track the move over to using main as the default branch for this repo. Weโ€™d love your team's help in completing this transition.

Do not remove your old default branch, customers are going to be using it. We will be sending messages out about these changes, but if you want to message in your repository, that's fine as well.

  • Create a main branch.
  • You might need to rebase any pull requests you want to merge before changing the default branch.
  • Change the default branch in settings to main.
  • Update any documentation in this repo to refer to the new branch name, although using the version tag is still preferred.
  • Check that this Action works correctly for users who have a repository with a custom default branch name.
  • Close this issue and celebrate ๐ŸŽ‰

We are aiming to complete this work by July 17th August 28th.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.