Skip to content

Commit

Permalink
Add more OTP and Elixir versions to CI (#16)
Browse files Browse the repository at this point in the history
* Update euneus

* Add more OTP and Elixir versions to CI

* Install json_polyfill when needed

* Change CI cache strategy

* Create env var for polyfill

* Act on env vars issue

* Comment the failiing test

* Tweak code

* Temp comment job

* Cache by OTP version

* Try fix record example

* Re-enable artifacts check

* Remove artifacts check
  • Loading branch information
williamthome authored Aug 9, 2024
1 parent 16cdd2b commit 29c3913
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
46 changes: 25 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ name: CI
workflow_dispatch: {}
merge_group:

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

permissions:
contents: read

Expand All @@ -28,13 +24,26 @@ jobs:
ci:
name: CI OTP-${{matrix.otp-version}} / Elixir ${{matrix.elixir-version}}

runs-on: ${{matrix.os}}
runs-on: ubuntu-24.04

strategy:
matrix:
otp-version: [27]
elixir-version: ['1.17.2']
os: [ubuntu-24.04]
include:
- otp-version: "24.3"
elixir-version: "1.12"
- otp-version: "24.3"
elixir-version: "1.13"
- otp-version: "25.3"
elixir-version: "1.14"
- otp-version: "26.2"
elixir-version: "1.15"
- otp-version: "26.2"
elixir-version: "1.16"
- otp-version: "27.0"
elixir-version: "1.17"

env:
MIX_ENV: ${{fromJSON(matrix.otp-version) < 27 && 'polyfill' || 'test'}}

steps:
# Step: Setup Elixir + Erlang image as the base.
Expand All @@ -54,12 +63,13 @@ jobs:
id: cache-deps
uses: actions/cache@v4
env:
cache-name: cache-elixir-deps
CACHE_NAME: cache-elixir-deps
with:
path: deps
key: ${{runner.os}}-mix-${{env.cache-name}}-${{hashFiles('**/mix.lock')}}
key: |
${{runner.os}}-otp-${{matrix.otp-version}}-mix-${{env.CACHE_NAME}}-${{hashFiles('**/mix.lock')}}
restore-keys: |
${{runner.os}}-mix-${{env.cache-name}}-
${{runner.os}}-otp-${{matrix.otp-version}}-mix-${{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
Expand All @@ -68,13 +78,13 @@ jobs:
id: cache-build
uses: actions/cache@v4
env:
cache-name: cache-compiled-build
CACHE_NAME: cache-compiled-build
with:
path: _build
key: ${{runner.os}}-mix-${{env.cache-name}}-${{hashFiles('**/mix.lock')}}
key: |
${{runner.os}}-otp-${{matrix.otp-version}}-mix-${{env.CACHE_NAME}}-${{hashFiles('**/mix.lock')}}
restore-keys: |
${{runner.os}}-mix-${{env.cache-name}}-
${{runner.os}}-mix-
${{runner.os}}-otp-${{matrix.otp-version}}-mix-${{env.CACHE_NAME}}-
# Step: Download project dependencies. If unchanged, uses the cached version.
- name: Install dependencies
Expand All @@ -94,9 +104,3 @@ jobs:
# Step: Execute the tests.
- name: Run tests
run: mix test

- name: Check if build left artifacts
run: |
mix deps.clean --all
mix deps.update --all
git diff --exit-code
6 changes: 5 additions & 1 deletion lib/exneus.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ defmodule Exneus do
...> foo: {[:bar, :baz], 3}
...> }}]}
...> )
"{\"bar\":\"bar\",\"baz\":\"baz\"}"
if String.to_integer(System.otp_release) >= 26 do
"{\"bar\":\"bar\",\"baz\":\"baz\"}"
else
"{\"baz\":\"baz\",\"bar\":\"bar\"}"
end
Custom codec example:
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Exneus.MixProject do
[
app: :exneus,
version: "0.1.0",
elixir: "~> 1.17",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
aliases: aliases(),
preferred_cli_env: [
Expand Down Expand Up @@ -52,6 +52,7 @@ defmodule Exneus.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:json_polyfill, only: :polyfill, runtime: false},
{:euneus, git: "https://github.com/williamthome/euneus", branch: "main"},
# dev
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"},
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
"euneus": {:git, "https://github.com/williamthome/euneus", "0933a9c6ab20f4773a2f794c0f915a659fcb7027", [branch: "main"]},
"euneus": {:git, "https://github.com/williamthome/euneus", "e089bb9e9d64dbab098d64c277b051da17d2b04b", [branch: "main"]},
"ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"jiffy": {:hex, :jiffy, "1.1.2", "a9b6c9a7ec268e7cf493d028f0a4c9144f59ccb878b1afe42841597800840a1b", [:rebar3], [], "hexpm", "bb61bc42a720bbd33cb09a410e48bb79a61012c74cb8b3e75f26d988485cf381"},
Expand Down

0 comments on commit 29c3913

Please sign in to comment.