Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
This patch moves CI checks into GitHub actions and away from CircleCI. Hooray.
  • Loading branch information
hayesgm committed Mar 25, 2024
1 parent ca0ca91 commit c4bd48b
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Elixir CI

on:
push:

# Sets the ENV `MIX_ENV` to `test` for running tests
env:
MIX_ENV: test

permissions:
contents: read

jobs:
lint:
name: "Elixir Lint"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Compile with cache
uses: ./.github/workflows/setup-elixir

# If this complains about redefining modules as a warning,
# there can be a probem with the cached build, so switch to giving
# a cache key modifier input on the setup elixir action (e.g. key <> "lint" )
- name: Compiles without warnings
run: mix compile --warnings-as-errors

- name: Check Formatting
run: mix format --check-formatted

test-and-coverage:
permissions: write-all
name: "Elixir Tests"
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Compile with cache
uses: ./.github/workflows/setup-elixir

- name: Run Elixir Tests
run: mix test --formatter JUnitFormatter --formatter ExUnit.CLIFormatter
57 changes: 57 additions & 0 deletions .github/workflows/setup-elixir/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Set up Elixir with cached build
description: "pulls in the elixir dependencies and builds a cache for the compiled build"
inputs:
mix_env:
description: "MIX_ENV to compile"
required: true
default: "test"

runs:
using: "composite"
steps:
# Step: Setup Elixir + Erlang image as the base.
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: "26.1.2"
elixir-version: "1.15"

# Step: Define how to cache deps. Restores existing cache if present.
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: deps
key: ${{ runner.os }}-mix-${{ inputs.mix_env }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ inputs.mix_env }}-${{ env.cache-name }}-
# Step: Define how to cache the `_build` directory. After the first run,
# this speeds up tests runs a lot. This includes not re-compiling our
# project's downloaded deps every run.
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-mix-${{ inputs.mix_env }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ inputs.mix_env }}-${{ env.cache-name }}-
${{ runner.os }}-mix-${{ inputs.mix_env }}-
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Install dependencies
shell: bash
run: mix deps.get

# Step: Compile the project for test and cache the build
- name: Build for cache
shell: bash
run: mix compile
env:
MIX_ENV: ${{ inputs.mix_env }}
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ defmodule ABI.Mixfile do
{:ex_doc, "~> 0.31.1", only: :dev, runtime: false},
{:jason, "~> 1.4"},
{:ex_sha3, "~> 0.1.4"},
{:junit_formatter, "~> 3.1", only: [:test, :integration]}
]
end
end
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"httpoison": {:hex, :httpoison, "1.4.0", "e0b3c2ad6fa573134e42194d13e925acfa8f89d138bc621ffb7b1989e6d22e73", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"junit_formatter": {:hex, :junit_formatter, "3.3.1", "c729befb848f1b9571f317d2fefa648e9d4869befc4b2980daca7c1edc468e40", [:mix], [], "hexpm", "761fc5be4b4c15d8ba91a6dafde0b2c2ae6db9da7b8832a55b5a1deb524da72b"},
"keccakf1600": {:hex, :keccakf1600_orig, "2.0.0", "0a7217ddb3ee8220d449bbf7575ec39d4e967099f220a91e3dfca4dbaef91963", [:rebar3], [], "hexpm"},
"libsecp256k1": {:hex, :libsecp256k1, "0.1.10", "d27495e2b9851c7765129b76c53b60f5e275bd6ff68292c50536bf6b8d091a4d", [:make, :mix], [{:mix_erlang_tasks, "0.1.0", [hex: :mix_erlang_tasks, repo: "hexpm", optional: false]}], "hexpm"},
"logger_file_backend": {:hex, :logger_file_backend, "0.0.10", "876f9f84ae110781207c54321ffbb62bebe02946fe3c13f0d7c5f5d8ad4fa910", [:mix], [], "hexpm"},
Expand Down

0 comments on commit c4bd48b

Please sign in to comment.