From b1735d511d53ebbf5c41d01b201f2988db9e53ec Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Mon, 30 Sep 2024 13:06:44 -0700 Subject: [PATCH] * use actioncable-next --- .github/workflows/ci.yml | 62 +++++++++++++++++++++++----------------- .rails-revision | 1 - Gemfile | 25 +++++++++------- bento | 4 ++- 4 files changed, 52 insertions(+), 40 deletions(-) delete mode 100644 .rails-revision diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef27b68..0247eb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - master + - master pull_request: workflow_dispatch: @@ -16,6 +16,7 @@ jobs: BUNDLE_RETRY: 3 CI: true RAILS_VERSION: ${{ matrix.rails_version }} + NEXT_ACTION_CABLE: ${{ matrix.next }} services: redis: image: redis:7.0-alpine @@ -26,27 +27,30 @@ jobs: matrix: server: ["puma", "anycable"] scenario: ["echo", "broadcast"] - rails_version: ["dev", "7"] + rails_version: ["~> 7.0.0", "~> 7.0", "~> 8.0.0.beta1"] + next: ["0", "1"] include: - server: "iodine" - rails_version: "dev" + rails_version: "~> 8.0.0.beta1" scenario: "broadcast" + next: "1" - server: "falcon" - rails_version: "dev" + rails_version: "~> 8.0.0.beta1" scenario: "broadcast" + next: "1" steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.3 - bundler-cache: true - - name: Run server - run: | - bundle exec bento --${{ matrix.server }} & - bin/wait_tcp 8080 - - name: Run WS director scenario - run: | - SCENARIO=${{ matrix.scenario }} make wsdirector + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + - name: Run server + run: | + bundle exec bento --${{ matrix.server }} & + bin/wait_tcp 8080 + - name: Run WS director scenario + run: | + SCENARIO=${{ matrix.scenario }} make wsdirector conformance: if: ${{ !contains(github.event.head_commit.message, '[ci skip]') }} @@ -56,6 +60,7 @@ jobs: BUNDLE_RETRY: 3 CI: true RAILS_VERSION: ${{ matrix.rails_version }} + NEXT_ACTION_CABLE: ${{ matrix.next }} services: redis: image: redis:7.0-alpine @@ -65,18 +70,21 @@ jobs: fail-fast: false matrix: server: ["puma", "anycable"] - rails_version: ["dev", "7"] + rails_version: ["~> 7.0", "~> 8.0.0.beta1"] + next: ["0", "1"] include: - server: "iodine" - rails_version: "dev" + rails_version: "~> 8.0.0.beta1" + next: "1" - server: "falcon" - rails_version: "dev" + rails_version: "~> 8.0.0.beta1" + next: "1" steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.3 - bundler-cache: true - - name: Run conformance tests via AnyT - run: | - make anyt-${{ matrix.server }} + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.3 + bundler-cache: true + - name: Run conformance tests via AnyT + run: | + make anyt-${{ matrix.server }} diff --git a/.rails-revision b/.rails-revision deleted file mode 100644 index 7dff62f..0000000 --- a/.rails-revision +++ /dev/null @@ -1 +0,0 @@ -https://github.com/palkan/rails.git#refactor/action-cable-server-adapterization diff --git a/Gemfile b/Gemfile index dfc4c3a..865413c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,18 +1,25 @@ source "https://rubygems.org" rails_path = File.file?(File.join(__dir__, ".rails-path")) ? File.read(File.join(__dir__, ".rails-path")).strip : File.join(__dir__, "../rails") +no_local = ENV["LOCAL_GEMS"] == "0" -# Use local Rails copy if available -if ENV["RAILS_VERSION"] == "7" - gem "rails", "~> 7.0" -elsif File.directory?(rails_path) +# Do not load to the load path if disabled +unless ENV["NEXT_ACTION_CABLE"] == "0" + if !no_local && File.directory?(File.join(__dir__, "..", "actioncable-next")) + gem "actioncable-next", path: "../actioncable-next", require: false + else + gem "actioncable-next", require: false + end +end + +if !no_local && File.directory?(rails_path) gem "rails", path: rails_path # Use Rails from a git repo elsif File.file?(File.join(__dir__, ".rails-revision")) git, branch = *File.read(File.join(__dir__, ".rails-revision")).strip.split("#", 2) gem "rails", git:, branch: else - gem "rails", "~> 8.0" + gem "rails", ENV.fetch("RAILS_VERSION", "~> 7.0") end # Baseline setup: Puma + Redis pub/sub @@ -33,9 +40,7 @@ gem "grpc" unless ENV["ANYCABLE_GRPC_IMPL"] == "grpc_kit" anycable_dir_path = File.file?(File.join(__dir__, ".anycable-path")) ? File.read(File.join(__dir__, ".anycable-path")).strip : File.join(__dir__, "..") -if ENV["RAILS_VERSION"] == "7" - gem "anycable-core", require: false -elsif File.file?(File.join(anycable_dir_path, "anycable/anycable-core.gemspec")) +if !no_local && File.file?(File.join(anycable_dir_path, "anycable/anycable-core.gemspec")) gem "anycable-core",require: false, path: File.join(anycable_dir_path, "anycable") elsif File.file?(File.join(__dir__, ".anycable-revision")) git, branch = *File.read(File.join(__dir__, ".anycable-revision")).strip.split("#", 2) @@ -44,9 +49,7 @@ else gem "anycable-core", require: false end -if ENV["RAILS_VERSION"] == "7" - gem "anycable-rails", require: false -elsif File.file?(File.join(anycable_dir_path, "anycable-rails/anycable-rails.gemspec")) +if !no_local && File.file?(File.join(anycable_dir_path, "anycable-rails/anycable-rails.gemspec")) gem "anycable-rails", require: false, path: File.join(anycable_dir_path, "anycable-rails") elsif File.file?(File.join(__dir__, ".anycable-rails-revision")) git, branch = *File.read(File.join(__dir__, ".anycable-rails-revision")).strip.split("#", 2) diff --git a/bento b/bento index a06067d..f0d4868 100755 --- a/bento +++ b/bento @@ -30,6 +30,8 @@ end.parse! require_relative "lib/application" -$stdout.puts "⚡️ Running Action Cable #{Rails::VERSION::STRING} via #{$benchmark_server}" +desc = defined?(ActionCableNext) ? "Action Cable Next #{ActionCableNext::VERSION} on Rails #{Rails::VERSION::STRING}" : "Action Cable #{Rails::VERSION::STRING}" + +$stdout.puts "⚡️ Running #{desc} via #{$benchmark_server}" BenchmarkServer.run!