From 8b4ce8a1c2befbc377b4b8114b623fb284a34dd7 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 15:19:06 +0100 Subject: [PATCH 1/5] Use GH actions to run tests We want to migrate away from circle ci --- .circleci/config.yml | 63 ---------------------------------- .github/workflows/lint.yml | 25 ++++++++++++++ .github/workflows/test.yml | 69 ++++++++++++++++++++++++++++++++++++++ Gemfile | 8 ++--- 4 files changed, 98 insertions(+), 67 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 8aba3219..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,63 +0,0 @@ -version: 2.1 - -orbs: - # Always take the latest version of the orb, this allows us to - # run specs against Solidus supported versions only without the need - # to change this configuration every time a Solidus version is released - # or goes EOL. - solidusio_extensions: solidusio/extensions@volatile - -commands: - setup: - steps: - - checkout - - run: - name: "Update bundler" - command: | - sudo gem update --system - gem --version - gem install bundler -v '>=2.3.21' --conservative - bundle --version - -jobs: - solidus-main: - executor: - name: solidusio_extensions/sqlite - ruby_version: '3.2' - steps: ['setup', 'solidusio_extensions/run-tests-solidus-main'] - solidus-current: - executor: - name: solidusio_extensions/sqlite - ruby_version: '3.1' - steps: ['setup', 'solidusio_extensions/run-tests-solidus-current'] - solidus-older: - executor: - name: solidusio_extensions/sqlite - ruby_version: '3.0' - steps: ['setup', 'solidusio_extensions/run-tests-solidus-older'] - lint-code: - executor: - name: solidusio_extensions/sqlite - ruby_version: '3.1' - steps: ['setup', 'solidusio_extensions/lint-code'] - -workflows: - "Run specs on supported Solidus versions": - jobs: - - solidus-main - - solidus-current - - solidus-older - - lint-code - - "Weekly run specs against main": - triggers: - - schedule: - cron: "0 0 * * 4" # every Thursday - filters: - branches: - only: - - main - jobs: - - solidus-main - - solidus-current - - solidus-older diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..dc2a0cfa --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint + +on: [pull_request] + +concurrency: + group: lint-${{ github.ref_name }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +permissions: + contents: read + +jobs: + ruby: + name: Check Ruby + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.2" + bundler-cache: true + - name: Lint Ruby files + run: bundle exec rubocop -ESP diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..82bea242 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,69 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + schedule: + - cron: "0 0 * * 4" # every Thursday + +concurrency: + group: test-${{ github.ref_name }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +permissions: + contents: read + +jobs: + rspec: + name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: true + matrix: + rails-version: + - "7.0" + - "7.1" + - "7.2" + ruby-version: + - "3.1" + - "3.4" + solidus-branch: + - "v4.1" + - "v4.2" + - "v4.3" + - "v4.4" + - "v4.5" + database: + - "postgresql" + - "mysql" + - "sqlite" + exclude: + - rails-version: "7.2" + solidus-branch: "v4.3" + - rails-version: "7.2" + solidus-branch: "v4.2" + - rails-version: "7.2" + solidus-branch: "v4.1" + - rails-version: "7.1" + solidus-branch: "v4.2" + - rails-version: "7.1" + solidus-branch: "v4.1" + - ruby-version: "3.4" + rails-version: "7.0" + steps: + - uses: actions/checkout@v4 + - name: Run extension tests + uses: solidusio/test-solidus-extension@main + with: + database: ${{ matrix.database }} + rails-version: ${{ matrix.rails-version }} + ruby-version: ${{ matrix.ruby-version }} + solidus-branch: ${{ matrix.solidus-branch }} + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + continue-on-error: true + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage/coverage.xml diff --git a/Gemfile b/Gemfile index 41b9bc14..ce5c8603 100644 --- a/Gemfile +++ b/Gemfile @@ -10,8 +10,8 @@ gemspec branch = ENV.fetch('SOLIDUS_BRANCH', 'main') gem 'solidus', github: 'solidusio/solidus', branch: branch -rails_version = ENV.fetch("RAILS_VERSION", "~> 7.0") -gem 'rails', rails_version +rails_version = ENV.fetch("RAILS_VERSION", "7.0") +gem 'rails', "~> #{rails_version}" gem 'bundler' gem 'rake' @@ -21,13 +21,13 @@ group :test do gem 'mysql2' gem 'pg' gem 'solidus_auth_devise' - gem 'sqlite3', rails_version < '~> 7.2' ? '~> 1.4' : '~> 2.0' + gem 'sqlite3', rails_version < '7.2' ? '~> 1.4' : '~> 2.0' end # Use a local Gemfile to include development dependencies that might not be # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`. eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local' -if rails_version == "~> 7.0" +if rails_version == "7.0" gem 'concurrent-ruby', '< 1.3.5' end From 5706e939bcb01c7a3805d737a9a4d5a85e66eafd Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 15:22:59 +0100 Subject: [PATCH 2/5] Generate extensions to run specs on GH actions --- README.md | 11 +-- .../extension/.github/workflows/lint.yml | 25 +++++++ .../extension/.github/workflows/test.yml | 71 +++++++++++++++++++ .../templates/extension/Gemfile.tt | 8 +-- 4 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 lib/solidus_dev_support/templates/extension/.github/workflows/lint.yml create mode 100644 lib/solidus_dev_support/templates/extension/.github/workflows/test.yml diff --git a/README.md b/README.md index 36a82d4d..113eb50d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # solidus_dev_support -[![CircleCI](https://circleci.com/gh/solidusio/solidus_dev_support.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_dev_support) +[![Test](https://github.com/solidusio/solidus_dev_support/actions/workflows/test.yml/badge.svg)](https://github.com/solidusio/solidus_dev_support/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/solidusio/solidus_dev_support/branch/main/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_dev_support) This gem contains common development functionality for Solidus extensions. @@ -138,15 +138,10 @@ require 'solidus_dev_support/rspec/coverage' **Note: Make sure to add this at the VERY TOP of your spec_helper, otherwise you'll get skewed coverage reports!** -If your extension is in a public repo and being tested on Travis or CircleCI, there's nothing else +If your extension is in a public repo and being tested on GitHub actions, there's nothing else you need to do! If your setup is more complex, look at the [SimpleCov](https://github.com/colszowka/simplecov) -and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs. - -> [!WARNING] -> The Codecov ruby uploader is deprecated. -> Please use the Codecov CLI uploader to upload code coverage reports. -> See https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader for more information on upgrading. +and [codecov](https://about.codecov.io/language/ruby/) docs. #### Using GitHub Actions diff --git a/lib/solidus_dev_support/templates/extension/.github/workflows/lint.yml b/lib/solidus_dev_support/templates/extension/.github/workflows/lint.yml new file mode 100644 index 00000000..dc2a0cfa --- /dev/null +++ b/lib/solidus_dev_support/templates/extension/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint + +on: [pull_request] + +concurrency: + group: lint-${{ github.ref_name }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +permissions: + contents: read + +jobs: + ruby: + name: Check Ruby + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.2" + bundler-cache: true + - name: Lint Ruby files + run: bundle exec rubocop -ESP diff --git a/lib/solidus_dev_support/templates/extension/.github/workflows/test.yml b/lib/solidus_dev_support/templates/extension/.github/workflows/test.yml new file mode 100644 index 00000000..4579edbb --- /dev/null +++ b/lib/solidus_dev_support/templates/extension/.github/workflows/test.yml @@ -0,0 +1,71 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + schedule: + - cron: "0 0 * * 4" # every Thursday + +concurrency: + group: test-${{ github.ref_name }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +permissions: + contents: read + +jobs: + rspec: + name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: true + matrix: + rails-version: + - "7.0" + - "7.1" + - "7.2" + ruby-version: + - "3.1" + - "3.4" + solidus-branch: + - "v4.1" + - "v4.2" + - "v4.3" + - "v4.4" + - "v4.5" + database: + - "postgresql" + - "mysql" + - "sqlite" + exclude: + - rails-version: "7.2" + solidus-branch: "v4.3" + - rails-version: "7.2" + solidus-branch: "v4.2" + - rails-version: "7.2" + solidus-branch: "v4.1" + - rails-version: "7.1" + solidus-branch: "v4.2" + - rails-version: "7.1" + solidus-branch: "v4.1" + - ruby-version: "3.4" + rails-version: "7.0" + env: + CODECOV_COVERAGE_PATH: ./coverage/coverage.xml + steps: + - uses: actions/checkout@v4 + - name: Run extension tests + uses: solidusio/test-solidus-extension@main + with: + database: ${{ matrix.database }} + rails-version: ${{ matrix.rails-version }} + ruby-version: ${{ matrix.ruby-version }} + solidus-branch: ${{ matrix.solidus-branch }} + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + continue-on-error: true + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ env.CODECOV_COVERAGE_PATH }} diff --git a/lib/solidus_dev_support/templates/extension/Gemfile.tt b/lib/solidus_dev_support/templates/extension/Gemfile.tt index fc31ca2a..35d0485c 100644 --- a/lib/solidus_dev_support/templates/extension/Gemfile.tt +++ b/lib/solidus_dev_support/templates/extension/Gemfile.tt @@ -15,8 +15,8 @@ else gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch end -rails_version = ENV.fetch('RAILS_VERSION', '~> 7.0') -gem 'rails', rails_version +rails_version = ENV.fetch('RAILS_VERSION', '7.0') +gem 'rails', "~> #{rails_version}" case ENV.fetch('DB', nil) when 'mysql' @@ -24,10 +24,10 @@ when 'mysql' when 'postgresql' gem 'pg' else - gem 'sqlite3', rails_version < '~> 7.2' ? '~> 1.4' : '~> 2.0' + gem 'sqlite3', rails_version < '7.2' ? '~> 1.4' : '~> 2.0' end -if rails_version == '~> 7.0' +if rails_version == '7.0' gem 'concurrent-ruby', '< 1.3.5' end From 4f6958e53e9a9e0524d4f65c91c8e7875d17ca2e Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 17:02:12 +0100 Subject: [PATCH 3/5] CI: Drop Rails 7.0 but add Rails 8.0 builds Rails 7.0 is untestable because the rails _7.0_ new command fails because of a bug that has not been fixed in the published rails gem and wont be ever. Since rails 7.0 will be eol in 6 weeks it does not make sense to waste carbon on it. --- .github/workflows/test.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82bea242..5c281a5d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,18 +23,17 @@ jobs: fail-fast: true matrix: rails-version: - - "7.0" - "7.1" - "7.2" + - "8.0" ruby-version: - "3.1" - "3.4" solidus-branch: - - "v4.1" - - "v4.2" - "v4.3" - "v4.4" - "v4.5" + - "main" database: - "postgresql" - "mysql" @@ -42,16 +41,12 @@ jobs: exclude: - rails-version: "7.2" solidus-branch: "v4.3" - - rails-version: "7.2" - solidus-branch: "v4.2" - - rails-version: "7.2" - solidus-branch: "v4.1" - - rails-version: "7.1" - solidus-branch: "v4.2" - - rails-version: "7.1" - solidus-branch: "v4.1" - - ruby-version: "3.4" - rails-version: "7.0" + - ruby-version: "3.1" + rails-version: "8.0" + - solidus-branch: "v4.3" + rails-version: "8.0" + - solidus-branch: "v4.4" + rails-version: "8.0" steps: - uses: actions/checkout@v4 - name: Run extension tests From f783ea3d1c088110cf00c109c5f782b42609f006 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 13 Feb 2025 17:24:36 +0100 Subject: [PATCH 4/5] Add csv gem for Ruby 3.4 --- lib/solidus_dev_support/templates/extension/Gemfile.tt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/solidus_dev_support/templates/extension/Gemfile.tt b/lib/solidus_dev_support/templates/extension/Gemfile.tt index 35d0485c..c6ece8c9 100644 --- a/lib/solidus_dev_support/templates/extension/Gemfile.tt +++ b/lib/solidus_dev_support/templates/extension/Gemfile.tt @@ -31,6 +31,11 @@ if rails_version == '7.0' gem 'concurrent-ruby', '< 1.3.5' end +if RUBY_VERSION >= '3.4' + # Solidus Promotions uses CSV but does not have it as dependency yet. + gem 'csv' +end + # While we still support Ruby < 3 we need to workaround a limitation in # the 'async' gem that relies on the latest ruby, since RubyGems doesn't # resolve gems based on the required ruby version. From c2b4db4c2d349d16c17fd7ea81ed1da009190d73 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 14 Feb 2025 13:50:50 +0100 Subject: [PATCH 5/5] Generate Manifest file early in sandbox generation The sandbox wants to install Solidus and migrate before running the install generator. That's bad, because migrating requires the app to boot, and booting fails because Sprockets fails with an error if the `manifest.js` file is not present. Since the file is quite simple, we can just pass it into a heredoc. This is needed for Rails 8, where the install generator won't create the file for us. --- .../templates/extension/bin/sandbox.tt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/solidus_dev_support/templates/extension/bin/sandbox.tt b/lib/solidus_dev_support/templates/extension/bin/sandbox.tt index 389af2bb..7aa2f394 100755 --- a/lib/solidus_dev_support/templates/extension/bin/sandbox.tt +++ b/lib/solidus_dev_support/templates/extension/bin/sandbox.tt @@ -61,6 +61,14 @@ group :test, :development do end RUBY +echo "Generating manifest file" +mkdir -p app/assets/config +cat < app/assets/config/manifest.js +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css +MANIFESTJS + unbundled bundle install --gemfile Gemfile unbundled bundle exec rake db:drop db:create