Skip to content

Commit

Permalink
Merge pull request #55 from UrbanOS-Public/elixir-version-upgrades
Browse files Browse the repository at this point in the history
Elixir version upgrades
  • Loading branch information
nicholas-goodwin authored May 16, 2023
2 parents 9fccc40 + 69ff172 commit 038eacd
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 88 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/divo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-elixir@v1.5.0
- uses: erlef/setup-beam@v1
with:
otp-version: 21.3
elixir-version: 1.10.4
experimental-otp: true
otp-version: 25.3.2
version-type: strict
elixir-version: 1.14.4
- name: Get dependencies
run: |
bash scripts/gh-action-get-deps.sh
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-elixir@v1.5.0
- uses: erlef/setup-beam@v1
with:
otp-version: 21.3
elixir-version: 1.10.4
experimental-otp: true
otp-version: 25.3.2
version-type: strict
elixir-version: 1.14.4
- name: Get dependencies
run: |
bash scripts/gh-action-get-deps.sh
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM bitwalker/alpine-elixir:1.8.1
FROM hexpm/elixir:1.14.4-erlang-25.3.2
COPY . /app
WORKDIR /app
RUN mix local.hex --force \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The package can be installed by adding `divo` to your list of dependencies in `m
```elixir
def deps() do
[
{:divo, "~> 1.3.1", only: [:dev, :integration]}
{:divo, "~> 2.0.0", only: [:dev, :integration]}
]
end
```
Expand Down Expand Up @@ -56,8 +56,8 @@ In your mix file, include the additional dependency
#mix.exs
def deps() do
[
{:divo, "~> 1.3.1", only: [:dev, :integration]},
{:divo_redis, "~> 0.1.0", only: [:dev, :integration]}
{:divo, "~> 2.0.0", only: [:dev, :integration]},
{:divo_redis, "~> 1.0.0", only: [:dev, :integration]}
]
```
And in your config, include the imported dependency module(s) as a list of tuples along with any environment variables the stack takes as a keyword list
Expand Down
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
use Mix.Config
import Config

import_config "#{Mix.env()}.exs"
5 changes: 1 addition & 4 deletions config/dev.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Mix.Config
import Config

config :divo,
divo: %{
Expand All @@ -21,6 +21,3 @@ config :divo,
}
}
}

config :husky,
pre_commit: "./scripts/git_pre_commit_hook.sh"
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Mix.Config
import Config

config :divo,
divo: %{
Expand Down
15 changes: 7 additions & 8 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Divo.MixProject do
def project do
[
app: :divo,
version: "1.3.2",
elixir: "~> 1.8",
version: "2.0.0",
elixir: "~> 1.14.4",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package(),
Expand All @@ -26,14 +26,13 @@ defmodule Divo.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:jason, "~> 1.1"},
{:jason, "~> 1.4"},
{:patiently, "~> 0.2"},
{:placebo, "~> 1.2", only: :test},
{:mock, "~> 0.3", only: :test},
{:temporary_env, "~> 2.0", only: :test},
{:credo, "~> 1.1", only: :dev, runtime: false},
{:dialyxir, "~> 1.0.0-rc.6", only: :dev, runtime: false},
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:husky, "~> 1.0", only: :dev, runtime: false}
{:credo, "~> 1.7", only: :dev, runtime: false},
{:dialyxir, "~> 1.3", only: :dev, runtime: false},
{:ex_doc, "~> 0.29", only: :dev, runtime: false}
]
end

Expand Down
34 changes: 19 additions & 15 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"},
"earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.22.1", "9bb6d51508778193a4ea90fa16eac47f8b67934f33f8271d5e1edec2dc0eee4c", [:mix], [{:earmark, "~> 1.4.0", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"husky": {:hex, :husky, "1.0.3", "960fd2c74214ba3640693ff89fff39abf0a271c4ff42659e6eb8ffbc26f33927", [:mix], [{:poison, ">= 1.2.1", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"jason": {:hex, :jason, "1.2.1", "12b22825e22f468c02eb3e4b9985f3d0cb8dc40b9bd704730efa11abd2708c44", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"makeup": {:hex, :makeup, "1.0.1", "82f332e461dc6c79dbd82fbe2a9c10d48ed07146f0a478286e590c83c52010b5", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm"},
"patiently": {:hex, :patiently, "0.2.0", "67eb139591e10c4b363ae0198e832552f191c58894731efd3bf124ec4722267a", [:mix], [], "hexpm"},
"placebo": {:hex, :placebo, "1.2.2", "a3d47906b01844bfd04ab0351a605620619fdb8f011225e406696f96a88ff380", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"temporary_env": {:hex, :temporary_env, "2.0.1", "d4b5e031837e5619485e1f23af7cba7e897b8fd546eaaa8b10c812d642ec4546", [:mix], [], "hexpm"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
"dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"},
"earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"},
"earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"husky": {:hex, :husky, "1.0.3", "960fd2c74214ba3640693ff89fff39abf0a271c4ff42659e6eb8ffbc26f33927", [:mix], [{:poison, ">= 1.2.1", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm", "17a8b051d7eb2d8fba80de49b2da73be243532a9af5db2c943a8faf1b65fb86b"},
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"},
"mock": {:hex, :mock, "0.3.7", "75b3bbf1466d7e486ea2052a73c6e062c6256fb429d6797999ab02fa32f29e03", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "4da49a4609e41fd99b7836945c26f373623ea968cfb6282742bcb94440cf7e5c"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"patiently": {:hex, :patiently, "0.2.0", "67eb139591e10c4b363ae0198e832552f191c58894731efd3bf124ec4722267a", [:mix], [], "hexpm", "c08cc5edc27def565647a9b55a0bea8025a5f81a4472e57692f28f2292c44c94"},
"placebo": {:hex, :placebo, "2.0.0", "c0e773dec77e941bcbcc14d10b759f2d66775aff9b75051f3e41939b64300e81", [:mix], [{:meck, "~> 0.9", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "e0872cec8848d7e59ba96396f45ee1ad34662c689c86ba6190694d38b4289844"},
"temporary_env": {:hex, :temporary_env, "2.0.1", "d4b5e031837e5619485e1f23af7cba7e897b8fd546eaaa8b10c812d642ec4546", [:mix], [], "hexpm", "f9420044742b5f0479a7f8243e86b048b6a2d4878bce026a3615065b11199c27"},
}
45 changes: 23 additions & 22 deletions test/compose_test.exs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
defmodule Divo.ComposeTest do
use ExUnit.Case
use Placebo

setup do
allow(System.cmd(any(), any()), meck_options: [:passthrough])
allow(System.get_env(any()), return: "/tmp")
allow(System.cmd(any(), any(), any()), return: {"", 0})
:ok
use ExUnit.Case, async: false

import Mock

setup_with_mocks([
{System, [:passthrough], [cmd: fn(_, _) -> {"", 0} end]},
{System, [], [cmd: fn(_, _, _) -> {"", 0} end]},
{System, [], [get_env: fn(_) -> "/tmp" end]}
]) do
{:ok, foo: "bar"}
end

test "docker run command called with expected arguments" do
Divo.Compose.run()

assert_called(
System.cmd("docker-compose", ["--file", "/tmp/divo.compose", "up", "--detach"], stderr_to_stdout: true),
once()
System.cmd("docker-compose", ["--file", "/tmp/divo.compose", "up", "--detach"], stderr_to_stdout: true)
)
end

Expand All @@ -23,32 +24,32 @@ defmodule Divo.ComposeTest do

error_message = "Failed to get authorization token: NoCredentialProviders: no valid providers in chain. Deprecated."

allow(Divo.Validate.validate(any()), return: :ok)

allow(System.cmd(any(), any(), any()),
return: {error_message, 1}
)

assert_raise RuntimeError, "Docker Compose exited with code: 1. " <> error_message, fn ->
Divo.Compose.run()
with_mocks(
[
{Divo.Validate, [], [validate: fn(_) -> :ok end]},
{System, [], [cmd: fn(_, _, _) -> {error_message, 1} end]},
{System, [], [get_env: fn(_) -> "/tmp" end]}
]
) do
assert_raise RuntimeError, "Docker Compose exited with code: 1. " <> error_message, fn ->
Divo.Compose.run()
end
end
end

test "docker stop command called with expected arguments" do
:ok = Divo.Compose.stop()

assert_called(
System.cmd("docker-compose", ["--file", "/tmp/divo.compose", "stop"], stderr_to_stdout: true),
once()
System.cmd("docker-compose", ["--file", "/tmp/divo.compose", "stop"], stderr_to_stdout: true)
)
end

test "docker stop and rm commands called with expected arguments on kill" do
:ok = Divo.Compose.kill()

assert_called(
System.cmd("docker-compose", ["--file", "/tmp/divo.compose", "down"], stderr_to_stdout: true),
once()
System.cmd("docker-compose", ["--file", "/tmp/divo.compose", "down"], stderr_to_stdout: true)
)
end
end
55 changes: 30 additions & 25 deletions test/file_test.exs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
defmodule Divo.FileTest do
use ExUnit.Case
use Placebo

import Mock

require TemporaryEnv

test "correctly determines the filename" do
allow(System.get_env("TMPDIR"), return: "/var/tmp/foo")

assert Divo.File.file_name() == "/var/tmp/foo/divo.compose"
with_mock(System, [], [get_env: fn ("TMPDIR") -> "/var/tmp/foo" end]) do
assert Divo.File.file_name() == "/var/tmp/foo/divo.compose"
end
end

test "correctly defaults the filename" do
allow(System.get_env("TMPDIR"), return: nil)

assert Divo.File.file_name() == "/tmp/divo.compose"
with_mock(System, [], [get_env: fn ("TMPDIR") -> nil end]) do
assert Divo.File.file_name() == "/tmp/divo.compose"
end
end

test "uses existing compose file" do
Expand All @@ -23,31 +25,33 @@ defmodule Divo.FileTest do
end
end

test "generates compose file from app config" do
allow(File.write!(any(), any()), return: :ok)
allow(System.get_env("TMPDIR"), return: "/var/tmp/foo")
config = Divo.Helper.fetch_config()
describe "generate" do
setup_with_mocks([
{System, [], [get_env: fn ("TMPDIR") -> "/var/tmp/foo" end]},
{File, [], [write!: fn (_, _) -> :ok end]},
{DivoFoobar, [:non_strict], [gen_stack: fn(_) -> %{} end]},
{DivoBarbaz, [:non_strict], [gen_stack: fn(_) -> %{} end]}
]) do
{:ok, foo: "bar"}
end

assert Divo.File.ensure_file(config) == "/var/tmp/foo/divo.compose"
end
test "generates compose file from app config" do
config = Divo.Helper.fetch_config()

test "generates compose file from a behaviour implementation of a single service" do
allow(File.write!(any(), any()), return: :ok)
allow(System.get_env("TMPDIR"), return: "/var/tmp/bar")
assert Divo.File.ensure_file(config) == "/var/tmp/foo/divo.compose"
end

services = [{DivoFoobar, [db_password: "we-are-divo", db_name: "foobar-db", something: "else"]}]
test "generates compose file from a behaviour implementation of a single service" do
services = [{DivoFoobar, [db_password: "we-are-divo", db_name: "foobar-db", something: "else"]}]

TemporaryEnv.put :divo, :divo, services do
config = Divo.Helper.fetch_config()
TemporaryEnv.put :divo, :divo, services do
config = Divo.Helper.fetch_config()

assert Divo.File.ensure_file(config) == "/var/tmp/bar/divo.compose"
assert Divo.File.ensure_file(config) == "/var/tmp/foo/divo.compose"
end
end
end

test "concatenates compose file from multiple implementations of the behaviour" do
allow(File.write!(any(), any()), return: :ok)
allow(System.get_env("TMPDIR"), return: "/var/tmp/bar")

services = [
{DivoFoobar, [db_password: "we-are-divo", db_name: "foobar-db", something: "else"]},
DivoBarbaz
Expand All @@ -56,7 +60,8 @@ defmodule Divo.FileTest do
TemporaryEnv.put :divo, :divo, services do
config = Divo.Helper.fetch_config()

assert Divo.File.ensure_file(config) == "/var/tmp/bar/divo.compose"
assert Divo.File.ensure_file(config) == "/var/tmp/foo/divo.compose"
end
end
end
end

0 comments on commit 038eacd

Please sign in to comment.