diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index a731fef..39d5ac5 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -1,28 +1,60 @@ name: elixir on: - push: pull_request: + push: + branches: + - main jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 + env: + MIX_ENV: test strategy: + fail-fast: false matrix: - otp: ['24.2', '25.0'] - elixir: ['1.13.x', '1.14.x'] include: - - otp: '25.0' - elixir: '1.14.x' - latest: true + - pair: + elixir: "1.13" + otp: "22" + - pair: + elixir: "1.17" + otp: "27" + lint: lint steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 with: - otp-version: ${{matrix.otp}} - elixir-version: ${{matrix.elixir}} - - run: mix deps.get - - if: ${{ matrix.latest }} - run: mix format --check-formatted --dry-run - - run: mix test + otp-version: ${{matrix.pair.otp}} + elixir-version: ${{matrix.pair.elixir}} + + - uses: actions/cache@v4 + with: + path: | + deps + _build + key: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}- + + - run: mix deps.get --only test + - run: mix format --check-formatted + if: ${{ matrix.lint }} + + - run: mix deps.get && mix deps.unlock --check-unused + if: ${{ matrix.lint }} + + - run: mix deps.compile + + # TODO: disable for now due to upstream error with ExVCR + # warning: redefining module ExVCR.Adapter.Httpc.Converter (current + # version loaded from + # _build/test/lib/exvcr/ebin/Elixir.ExVCR.Adapter.Httpc.Converter.beam) + + # - run: mix compile --warnings-as-errors + # if: ${{ matrix.lint }} + + - run: mix test diff --git a/lib/strategy/gossip.ex b/lib/strategy/gossip.ex index 0834341..ea06e88 100644 --- a/lib/strategy/gossip.ex +++ b/lib/strategy/gossip.ex @@ -130,7 +130,7 @@ defmodule Cluster.Strategy.Gossip do state = %State{state | :meta => {multicast_addr, port, socket, secret}} # TODO: Remove this version check when we deprecate OTP < 21 support - if :erlang.system_info(:otp_release) >= '21' do + if :erlang.system_info(:otp_release) >= ~c"21" do {:ok, state, {:continue, nil}} else {:ok, state, 0} @@ -166,7 +166,7 @@ defmodule Cluster.Strategy.Gossip do # Send stuttered heartbeats # TODO: Remove this version check when we deprecate OTP < 21 support - if :erlang.system_info(:otp_release) >= '21' do + if :erlang.system_info(:otp_release) >= ~c"21" do @impl true def handle_continue(_, state), do: handle_info(:heartbeat, state) else diff --git a/lib/strategy/kubernetes.ex b/lib/strategy/kubernetes.ex index 27c45a5..e365699 100644 --- a/lib/strategy/kubernetes.ex +++ b/lib/strategy/kubernetes.ex @@ -388,10 +388,10 @@ defmodule Cluster.Strategy.Kubernetes do :pods -> "api/v1/namespaces/#{namespace}/pods?labelSelector=#{selector}" end - headers = [{'authorization', 'Bearer #{token}'}] + headers = [{~c"authorization", ~c"Bearer #{token}"}] http_options = [ssl: ssl_opts, timeout: 15000] - case :httpc.request(:get, {'https://#{master}/#{path}', headers}, http_options, []) do + case :httpc.request(:get, {~c"https://#{master}/#{path}", headers}, http_options, []) do {:ok, {{_version, 200, _status}, _headers, body}} -> parse_response(ip_lookup_mode, Jason.decode!(body)) |> Enum.map(fn node_info -> diff --git a/lib/strategy/local_epmd.ex b/lib/strategy/local_epmd.ex index 7c09a8f..09145e2 100644 --- a/lib/strategy/local_epmd.ex +++ b/lib/strategy/local_epmd.ex @@ -37,7 +37,7 @@ defmodule Cluster.Strategy.LocalEpmd do defp get_host_suffix(self) do self = Atom.to_charlist(self) - [_, suffix] = :string.split(self, '@') - '@' ++ suffix + [_, suffix] = :string.split(self, ~c"@") + ~c"@" ++ suffix end end diff --git a/lib/strategy/rancher.ex b/lib/strategy/rancher.ex index 8521ece..a5dbe3e 100644 --- a/lib/strategy/rancher.ex +++ b/lib/strategy/rancher.ex @@ -130,11 +130,11 @@ defmodule Cluster.Strategy.Rancher do case Keyword.fetch!(config, :node_basename) do app_name when is_binary(app_name) and app_name != "" -> endpoints_path = "latest/self/service" - headers = [{'accept', 'application/json'}] + headers = [{~c"accept", ~c"application/json"}] case :httpc.request( :get, - {'#{@rancher_metadata_base_url}/#{endpoints_path}', headers}, + {~c"#{@rancher_metadata_base_url}/#{endpoints_path}", headers}, [], [] ) do diff --git a/mix.exs b/mix.exs index 0d0f759..0be90f8 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,7 @@ defmodule Cluster.Mixfile do [ app: :libcluster, version: @version, - elixir: "~> 1.8", + elixir: "~> 1.13", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, description: """ diff --git a/mix.lock b/mix.lock index 644157d..dcf8e46 100644 --- a/mix.lock +++ b/mix.lock @@ -1,17 +1,16 @@ %{ - "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.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, - "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"}, + "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"}, + "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"}, "exactor": {:hex, :exactor, "2.2.4", "5efb4ddeb2c48d9a1d7c9b465a6fffdd82300eb9618ece5d34c3334d5d7245b1", [:mix], [], "hexpm", "1222419f706e01bfa1095aec9acf6421367dcfab798a6f67c54cf784733cd6b5"}, "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"}, - "exvcr": {:hex, :exvcr, "0.14.1", "d9aacec631ed379e366bce5b3c68f6ec5b92b89142f9379425854e80a28c1107", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:finch, "~> 0.16", [hex: :finch, repo: "hexpm", optional: true]}, {:httpoison, "~> 1.0 or ~> 2.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "5f1e0854fbad0c4bb64ae8cdd289eeace90b8a0a209788c2f840d70f86a2d63c"}, - "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"}, + "exvcr": {:hex, :exvcr, "0.15.1", "772db4d065f5136c6a984c302799a79e4ade3e52701c95425fa2229dd6426886", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 4.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:finch, "~> 0.16", [hex: :finch, repo: "hexpm", optional: true]}, {:httpoison, "~> 1.0 or ~> 2.0", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.1", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "de4fc18b1d672d9b72bc7468735e19779aa50ea963a1f859ef82cd9e294b13e3"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"}, - "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.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"}, + "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [: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", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, "meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, } diff --git a/test/gossip_test.exs b/test/gossip_test.exs index 449cb99..b915b26 100644 --- a/test/gossip_test.exs +++ b/test/gossip_test.exs @@ -19,7 +19,7 @@ defmodule Cluster.Strategy.GossipTest do if_addr: "127.0.0.1", multicast_if: "192.168.1.1", multicast_addr: "233.252.1.32", - secret: "password", + secret: "password" ], connect: {Cluster.Nodes, :connect, [self()]}, list_nodes: {Cluster.Nodes, :list_nodes, [[]]} diff --git a/test/kubernetes_dns_srv_test.exs b/test/kubernetes_dns_srv_test.exs index 27055cb..e50e30f 100644 --- a/test/kubernetes_dns_srv_test.exs +++ b/test/kubernetes_dns_srv_test.exs @@ -23,10 +23,10 @@ defmodule Cluster.Strategy.KubernetesSRVDNSTest do application_name: "node", resolver: fn _query -> {:ok, - {:hostent, 'elixir-plug-poc.default.svc.cluster.local', [], :srv, 2, + {:hostent, ~c"elixir-plug-poc.default.svc.cluster.local", [], :srv, 2, [ - {10, 50, 0, 'elixir-plug-poc-0.elixir-plug-poc.default.svc.cluster.local'}, - {10, 50, 0, 'elixir-plug-poc-1.elixir-plug-poc.default.svc.cluster.local'} + {10, 50, 0, ~c"elixir-plug-poc-0.elixir-plug-poc.default.svc.cluster.local"}, + {10, 50, 0, ~c"elixir-plug-poc-1.elixir-plug-poc.default.svc.cluster.local"} ]}} end ], @@ -59,9 +59,9 @@ defmodule Cluster.Strategy.KubernetesSRVDNSTest do application_name: "node", resolver: fn _query -> {:ok, - {:hostent, 'elixir-plug-poc.default.svc.cluster.local', [], :srv, 1, + {:hostent, ~c"elixir-plug-poc.default.svc.cluster.local", [], :srv, 1, [ - {10, 50, 0, 'elixir-plug-poc-0.elixir-plug-poc.default.svc.cluster.local'} + {10, 50, 0, ~c"elixir-plug-poc-0.elixir-plug-poc.default.svc.cluster.local"} ]}} end ], @@ -102,9 +102,9 @@ defmodule Cluster.Strategy.KubernetesSRVDNSTest do application_name: "node", resolver: fn _query -> {:ok, - {:hostent, 'elixir-plug-poc.default.svc.cluster.local', [], :srv, 2, + {:hostent, ~c"elixir-plug-poc.default.svc.cluster.local", [], :srv, 2, [ - {10, 50, 0, 'elixir-plug-poc-1.elixir-plug-poc.default.svc.cluster.local'} + {10, 50, 0, ~c"elixir-plug-poc-1.elixir-plug-poc.default.svc.cluster.local"} ]}} end ], diff --git a/test/kubernetes_dns_test.exs b/test/kubernetes_dns_test.exs index 5313aa3..d294d08 100644 --- a/test/kubernetes_dns_test.exs +++ b/test/kubernetes_dns_test.exs @@ -21,7 +21,7 @@ defmodule Cluster.Strategy.KubernetesDNSTest do service: "app", application_name: "node", resolver: fn _query -> - {:ok, {:hostent, 'app', [], :inet, 4, [{10, 0, 0, 1}, {10, 0, 0, 2}]}} + {:ok, {:hostent, ~c"app", [], :inet, 4, [{10, 0, 0, 1}, {10, 0, 0, 2}]}} end ], connect: {Nodes, :connect, [self()]}, @@ -45,7 +45,7 @@ defmodule Cluster.Strategy.KubernetesDNSTest do polling_interval: 100, service: "app", application_name: "node", - resolver: fn _query -> {:ok, {:hostent, 'app', [], :inet, 4, [{10, 0, 0, 1}]}} end + resolver: fn _query -> {:ok, {:hostent, ~c"app", [], :inet, 4, [{10, 0, 0, 1}]}} end ], connect: {Nodes, :connect, [self()]}, disconnect: {Nodes, :disconnect, [self()]}, @@ -68,7 +68,7 @@ defmodule Cluster.Strategy.KubernetesDNSTest do polling_interval: 100, service: "app", application_name: "node", - resolver: fn _query -> {:ok, {:hostent, 'app', [], :inet, 4, [{10, 0, 0, 1}]}} end + resolver: fn _query -> {:ok, {:hostent, ~c"app", [], :inet, 4, [{10, 0, 0, 1}]}} end ], connect: {Nodes, :connect, [self()]}, disconnect: {Nodes, :disconnect, [self()]},