Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for v4 #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,40 @@ orbs:
solidusio_extensions: solidusio/extensions@volatile

jobs:
run-specs-with-sqlite:
executor:
name: solidusio_extensions/sqlite
ruby_version: "3.0"
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
run-specs-with-postgres:
executor:
name: solidusio_extensions/postgres
ruby_version: "3.2"
ruby_version: "3.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you changed the tested ruby version?

steps:
- checkout
- browser-tools/install-chrome
- solidusio_extensions/run-tests-solidus-master
- solidusio_extensions/store-test-results

- solidusio_extensions/run-tests
run-specs-with-mysql:
executor:
name: solidusio_extensions/mysql
ruby_version: "3.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Please do not change test config

steps:
- checkout
- browser-tools/install-chrome
- solidusio_extensions/run-tests-solidus-current
- solidusio_extensions/store-test-results

run-specs-with-sqlite:
executor:
name: solidusio_extensions/sqlite
ruby_version: "3.0"
steps:
- checkout
- browser-tools/install-chrome
- solidusio_extensions/run-tests-solidus-older
- solidusio_extensions/store-test-results

- solidusio_extensions/run-tests
lint-code:
executor: solidusio_extensions/sqlite
executor:
name: solidusio_extensions/sqlite-memory
ruby_version: "3.0"
steps:
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-sqlite
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs-with-sqlite
- lint-code

"Weekly run specs against master":
Expand All @@ -63,6 +56,6 @@ workflows:
only:
- master
jobs:
- run-specs-with-sqlite
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs-with-sqlite
18 changes: 1 addition & 17 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to the Solidus 4.0 upgrade? If yes, can you explain why?

_extends: .github
2 changes: 2 additions & 0 deletions .github_changelog_generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
issues=false
exclude-labels=infrastructure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this change came from? Can you make this a separate commit.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ pkg
spec/dummy
spec/examples.txt
.ruby-version
Gemfile-local
/sandbox
.rvmrc
.ruby-gemset
11 changes: 1 addition & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,5 @@ inherit_from: .rubocop_todo.yml
require:
- solidus_dev_support/rubocop

inherit_gem:
solidus_dev_support: .rubocop.yml

AllCops:
Exclude:
- spec/dummy/**/*
- vendor/**/*

Rails/SkipsModelValidations:
Exclude:
- db/migrate/**/*
NewCops: disable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change also qualifies a separate commit

39 changes: 29 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
%w[solidusio/solidus solidusio/solidus_frontend]
else
%w[solidusio/solidus] * 2
end
gem 'solidus', github: solidus_git, branch: branch
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: 'solidusio/solidus', branch: branch

# The solidus_frontend gem has been pulled out since v3.2
if branch >= 'v3.2'
gem 'solidus_frontend'
elsif branch == 'main'
gem 'solidus_frontend', github: 'solidusio/solidus_frontend', branch: branch
else
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
end

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
Expand All @@ -19,9 +22,8 @@ gem 'rails', '>0.a'

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'
gem 'solidus_dev_support'

case ENV['DB']
case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
Expand All @@ -30,9 +32,26 @@ else
gem 'sqlite3'
end

group :development, :test do
gem 'factory_bot', '> 4.10.0'
gem 'pry-rails'
end

group :test do
gem 'rails-controller-testing'
gem 'rspec-activemodel-mocks'
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.
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')

gemspec

# Use a local Gemfile to include development dependencies that might not be
# relevant for the project or for other contributors, e.g. pry-byebug.
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/spree/backend/solidus_reports.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Placeholder manifest file.
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
2 changes: 1 addition & 1 deletion app/assets/javascripts/spree/frontend/solidus_reports.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Placeholder manifest file.
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
16 changes: 5 additions & 11 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#!/usr/bin/env ruby

# frozen_string_literal: true

app_root = 'spec/dummy'
#!/usr/bin/env ruby

unless File.exist? "#{app_root}/bin/rails"
system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
warn "Automatic creation of the dummy app failed"
exit 1
end
if %w[g generate].include? ARGV.first
exec "#{__dir__}/rails-engine", *ARGV
else
exec "#{__dir__}/rails-sandbox", *ARGV
end

Dir.chdir app_root
exec 'bin/rails', *ARGV
15 changes: 15 additions & 0 deletions bin/rails-engine
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/solidus_reports/engine', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

require 'rails/all'
require 'rails/engine/commands'
18 changes: 18 additions & 0 deletions bin/rails-sandbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

#!/usr/bin/env ruby

app_root = 'sandbox'

unless File.exist? '#{app_root}/bin/rails'
warn 'Creating the sandbox app...'
Dir.chdir '#{__dir__}/..' do
system '#{__dir__}/sandbox' or begin
warn 'Automatic creation of the sandbox app failed'
exit 1
end
end
end

Dir.chdir app_root
exec 'bin/rails', *ARGV
7 changes: 7 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('rake', 'rake')
78 changes: 78 additions & 0 deletions bin/sandbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# frozen_string_literal: true

#!/usr/bin/env bash

set -e
test -z "${DEBUG+empty_string}" || set -x

test "$DB" = "sqlite" && export DB="sqlite3"

if [ -z "$SOLIDUS_BRANCH" ]
then
echo "~~> Use 'export SOLIDUS_BRANCH=[main|v3.2|...]' to control the Solidus branch"
SOLIDUS_BRANCH="main"
fi
echo "~~> Using branch $SOLIDUS_BRANCH of solidus"

if [ -z "$SOLIDUS_FRONTEND" ]
then
echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
SOLIDUS_FRONTEND="solidus_frontend"
fi
echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"

extension_name="solidus_reports"

# Stay away from the bundler env of the containing extension.
function unbundled {
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
}

rm -rf ./sandbox
unbundled bundle exec rails new sandbox \
--database="${DB:-sqlite3}" \
--skip-bundle \
--skip-git \
--skip-keeps \
--skip-rc \
--skip-spring \
--skip-test \
--skip-javascript

if [ ! -d "sandbox" ]; then
echo 'sandbox rails application failed'
exit 1
fi

cd ./sandbox
cat <<RUBY >> Gemfile
gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
gem 'rails-i18n'
gem 'solidus_i18n'
gem '$extension_name', path: '..'
group :test, :development do
platforms :mri do
gem 'pry-byebug'
end
end
RUBY

unbundled bundle install --gemfile Gemfile

unbundled bundle exec rake db:drop db:create

unbundled bundle exec rails generate solidus:install \
--auto-accept \
--user_class=Spree::User \
--enforce_available_locales=true \
--with-authentication=true \
--payment-method=none \
--frontend=${SOLIDUS_FRONTEND} \
$@

unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations

echo
echo "🚀 Sandbox app successfully created for $extension_name!"
echo "🧪 This app is intended for test purposes."
7 changes: 1 addition & 6 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

gem install bundler --conservative
bundle update
bundle exec rake extension:test_app
bin/rake clobber
12 changes: 6 additions & 6 deletions lib/generators/solidus_reports/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ def add_javascripts
end

def add_stylesheets
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_reports\n", before: %r{\*/}, verbose: true
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_reports\n", before: %r{\*/}, verbose: true
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_reports\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_reports\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
end

def add_migrations
run 'bundle exec rake railties:install:migrations FROM=solidus_reports'
run 'bin/rails railties:install:migrations FROM=solidus_reports'
end

def run_migrations
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
if run_migrations
run 'bundle exec rake db:migrate'
run 'bin/rails db:migrate'
else
puts 'Skipping rake db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
end
end
end
Expand Down
3 changes: 0 additions & 3 deletions lib/solidus_reports.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# frozen_string_literal: true

require 'solidus_core'
require 'solidus_support'

require 'solidus_reports/engine'
Loading