From b32382620bc67ab0206fca73e66fe1ba7938a5ca Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Thu, 30 Oct 2025 14:56:06 +0800 Subject: [PATCH 1/2] CI housekeeping Changes: - bump actions/checkout - do not run duplicated jobs on push/pull request at the same time - update test to handle ets result between OTP 28/27 and earlier --- .github/workflows/ci.yml | 14 +++++++++----- test/shared/pubsub_test.exs | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9803f250..04f33615 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,8 @@ name: Tests on: - push: pull_request: - branches: - - main + push: env: ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION: node16 @@ -14,13 +12,18 @@ env: jobs: tests: name: Run tests (${{ matrix.image }}) + # Run the job ONLY IF: + # 1. It is a pull_request event OR + # 2. It is a push event AND the repository is not a fork + # The push event for a non-fork PR branch will typically be a duplicate, so we exclude it. + if: github.event_name == 'pull_request' || github.ref != format('refs/heads/{0}', github.event.pull_request.head.ref) strategy: fail-fast: false matrix: include: - image: 1.6.6-erlang-21.3.8.24-debian-buster-20210902-slim - - image: 1.17.2-erlang-27.0.1-debian-bookworm-20240701-slim + - image: 1.19.3-erlang-28.1.1-debian-bullseye-20251103-slim runs-on: ubuntu-latest container: @@ -28,7 +31,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Hex and Rebar setup run: | @@ -44,6 +47,7 @@ jobs: 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 diff --git a/test/shared/pubsub_test.exs b/test/shared/pubsub_test.exs index fe1c0091..7697f9e8 100644 --- a/test/shared/pubsub_test.exs +++ b/test/shared/pubsub_test.exs @@ -181,7 +181,7 @@ defmodule Phoenix.PubSubTest do @tag registry_size: 2 test "PubSub pool size can be configured separately from the Registry partitions", config do - assert {:duplicate, 2, _} = :ets.lookup_element(config.pubsub, -2, 2) + assert_ets_duplicate_count(config.pubsub, 2) assert :persistent_term.get(config.adapter_name) == {config.adapter_name, :"#{config.adapter_name}_2", :"#{config.adapter_name}_3", :"#{config.adapter_name}_4"} @@ -190,9 +190,20 @@ defmodule Phoenix.PubSubTest do @tag pool_size: 3 test "Registry partitions are configured with the same pool size as PubSub if not specified", config do - assert {:duplicate, 3, _} = :ets.lookup_element(config.pubsub, -2, 2) + assert_ets_duplicate_count(config.pubsub, 3) assert :persistent_term.get(config.adapter_name) == {config.adapter_name, :"#{config.adapter_name}_2", :"#{config.adapter_name}_3"} end + + defp assert_ets_duplicate_count(pubsub, count) do + result = :ets.lookup_element(pubsub, -2, 2) + + case System.otp_release() do + otp when otp >= "28" -> + assert {{:duplicate, :pid}, ^count, _} = result + _ -> + assert {:duplicate, ^count, _} = result + end + end end From 5c32781593604a9a7d39d9f96ce58ec1ebf4374f Mon Sep 17 00:00:00 2001 From: Kian-Meng Ang Date: Tue, 25 Nov 2025 23:06:47 +0800 Subject: [PATCH 2/2] Use more understandable rule to prevent duplicated runners --- .github/workflows/ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04f33615..b22e9643 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,10 @@ env: jobs: tests: name: Run tests (${{ matrix.image }}) - # Run the job ONLY IF: - # 1. It is a pull_request event OR - # 2. It is a push event AND the repository is not a fork - # The push event for a non-fork PR branch will typically be a duplicate, so we exclude it. - if: github.event_name == 'pull_request' || github.ref != format('refs/heads/{0}', github.event.pull_request.head.ref) + + # 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 strategy: fail-fast: false