diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b22e9643..b44b9576 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,56 +1,77 @@ -name: Tests +name: CI on: - pull_request: push: - -env: - ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION: node16 - ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16 - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + pull_request: + branches: + - main jobs: - tests: - name: Run tests (${{ matrix.image }}) - - # prevent workflow jobs run twice on push and pull_request event - # see https://github.com/orgs/community/discussions/57827 - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + mix_test: + name: mix test (OTP ${{matrix.otp}} | Elixir ${{matrix.elixir}}) strategy: fail-fast: false matrix: include: - - image: 1.6.6-erlang-21.3.8.24-debian-buster-20210902-slim - - image: 1.19.3-erlang-28.1.1-debian-bullseye-20251103-slim + - elixir: 1.13.4 + otp: 25.3 + + - elixir: 1.16.3 + otp: 26.2 + + - elixir: 1.18.4 + otp: 27.3 + + - elixir: 1.19.4 + otp: 28.1 + lint: lint + + # run against latest Elixir to catch warnings early + - elixir: main-otp-28 + otp: maint-28 runs-on: ubuntu-latest - container: - image: hexpm/elixir:${{ matrix.image }} steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Hex and Rebar setup - run: | - mix local.hex --force - mix local.rebar --force - - - name: Restore deps and _build cache - uses: actions/cache@v4 - with: - path: | - deps - _build - key: deps-${{ runner.os }}-${{ matrix.image }}-${{ hashFiles('**/mix.lock') }} - restore-keys: | - deps-${{ runner.os }}-${{ matrix.image }} - - - name: Install dependencies - run: mix deps.get --only test - - - name: Run tests - run: | - epmd -daemon - mix test + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.elixir }} + otp-version: ${{ matrix.otp }} + + - name: Restore deps and _build cache + uses: actions/cache@v4 + with: + path: | + deps + _build + key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }} + + - name: Install dependencies + run: mix deps.get + + - name: Remove compiled application files + run: mix clean + + - name: Compile dependencies + run: mix compile + if: ${{ !matrix.lint }} + env: + MIX_ENV: test + + - name: Compile & lint dependencies + run: mix compile --warnings-as-errors + if: ${{ matrix.lint }} + env: + MIX_ENV: test + + - name: Run tests + run: | + epmd -daemon + mix test diff --git a/mix.exs b/mix.exs index ab932c8d..bf6cf3df 100644 --- a/mix.exs +++ b/mix.exs @@ -7,7 +7,7 @@ defmodule Phoenix.PubSub.Mixfile do [ app: :phoenix_pubsub, version: @version, - elixir: "~> 1.6", + elixir: "~> 1.13", name: "Phoenix.PubSub", description: "Distributed PubSub and Presence platform", homepage_url: "http://www.phoenixframework.org", diff --git a/test/support/cluster.ex b/test/support/cluster.ex index 85892854..67741e44 100644 --- a/test/support/cluster.ex +++ b/test/support/cluster.ex @@ -9,17 +9,22 @@ defmodule Phoenix.PubSub.Cluster do # Turn node into a distributed node with the given long name :net_kernel.start([:"primary@127.0.0.1"]) - # Allow spawned nodes to fetch all code from this node - :erl_boot_server.start([]) - allow_boot to_charlist("127.0.0.1") - nodes |> Enum.map(&Task.async(fn -> spawn_node(&1) end)) |> Enum.map(&Task.await(&1, 30_000)) end defp spawn_node({node_host, opts}) do - {:ok, node} = :slave.start(to_charlist("127.0.0.1"), node_name(node_host), inet_loader_args()) + cookie = :erlang.get_cookie() + + {:ok, _peer, node} = + :peer.start(%{ + name: node_name(node_host), + host: ~c"127.0.0.1", + env: [{~c"ERL_AFLAGS", ~c"-setcookie #{cookie}"}] + }) + + true = Node.connect(node) add_code_paths(node) transfer_configuration(node) ensure_applications_started(node) @@ -34,15 +39,6 @@ defmodule Phoenix.PubSub.Cluster do :rpc.block_call(node, module, function, args) end - defp inet_loader_args do - to_charlist("-loader inet -hosts 127.0.0.1 -setcookie #{:erlang.get_cookie()}") - end - - defp allow_boot(host) do - {:ok, ipv4} = :inet.parse_ipv4_address(host) - :erl_boot_server.add_slave(ipv4) - end - defp add_code_paths(node) do rpc(node, :code, :add_paths, [:code.get_path()]) end