Skip to content

Commit ef85414

Browse files
authored
Merge pull request #219 from SuperGoodSoft/fix-ci
Fix postgres tests (updated commit)
2 parents f752af7 + e237ab1 commit ef85414

3 files changed

Lines changed: 93 additions & 36 deletions

File tree

β€ŽREADME.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Solidus Paypal Commerce Platform
22

3-
[![Workflow Name](https://github.com/solidusio/solidus_starter_frontend/actions/workflows/test.yml/badge.svg)](https://github.com/solidusio/solidus_starter_frontend/actions/workflows/<WORKFLOW_FILE>)
3+
[![Workflow Name](https://github.com/solidusio/solidus_paypal_commerce_platform/actions/workflows/test.yml/badge.svg)](https://github.com/solidusio/solidus_paypal_commerce_platform/actions/workflows/<WORKFLOW_FILE>)
44
[![codecov](https://codecov.io/gh/solidusio-contrib/solidus_paypal_commerce_platform/branch/main/graph/badge.svg?token=J8HCLE0CZW)](https://codecov.io/gh/solidusio-contrib/solidus_paypal_commerce_platform)
55

66
The official PayPal integration of Solidus.

β€Žbin/dummy-appβ€Ž

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test "$DB" = "sqlite" && export DB="sqlite3"
1515

1616
rm -rf ./dummy-app
1717
rails_version=`bundle exec ruby -e'require "rails"; puts Rails.version'`
18-
rails _${rails_version}_ new dummy-app \
18+
bundle exec rails _${rails_version}_ new dummy-app \
1919
--database=${DB:-sqlite3} \
2020
--skip-git \
2121
--skip-keeps \
@@ -29,6 +29,25 @@ if [ ! -d "dummy-app" ]; then
2929
fi
3030

3131
cd ./dummy-app
32+
33+
if [ -n "$DB_HOST" ]; then
34+
echo "~~~> Configuring database.yml for DB_HOST=$DB_HOST"
35+
ruby -i -pe '
36+
if $_ =~ /^ (pool|max_connections):/
37+
$_ += " host: <%= ENV.fetch(\"DB_HOST\", \"localhost\") %>\n"
38+
$_ += " username: <%= ENV[\"DB_USERNAME\"] %>\n"
39+
end
40+
' config/database.yml
41+
fi
42+
43+
echo "Generating manifest file"
44+
mkdir -p app/assets/config
45+
cat <<MANIFESTJS > app/assets/config/manifest.js
46+
//= link_tree ../images
47+
//= link_directory ../javascripts .js
48+
//= link_directory ../stylesheets .css
49+
MANIFESTJS
50+
3251
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-main}" --version '> 0.a'
3352
unbundled bundle exec rake db:drop db:create
3453
unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none --no-seed --no-sample "$@"

β€Žbin/sandboxβ€Ž

Lines changed: 72 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,99 @@
11
#!/usr/bin/env bash
22

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

5-
case "$DB" in
6-
postgres|postgresql)
7-
RAILSDB="postgresql"
8-
;;
9-
mysql)
10-
RAILSDB="mysql"
11-
;;
12-
sqlite|'')
13-
RAILSDB="sqlite3"
14-
;;
15-
*)
16-
echo "Invalid DB specified: $DB"
17-
exit 1
18-
;;
19-
esac
6+
test "$DB" = "sqlite" && export DB="sqlite3"
207

21-
if [ ! -z $SOLIDUS_BRANCH ]
8+
if [ -z "$SOLIDUS_BRANCH" ]
229
then
23-
BRANCH=$SOLIDUS_BRANCH
24-
else
25-
BRANCH="main"
10+
echo "~~> Use 'export SOLIDUS_BRANCH=[main|v4.0|...]' to control the Solidus branch"
11+
SOLIDUS_BRANCH="main"
2612
fi
27-
28-
extension_name="solidus_paypal_commerce_platform"
13+
echo "~~> Using branch $SOLIDUS_BRANCH of solidus"
2914

3015
# Stay away from the bundler env of the containing extension.
3116
function unbundled {
32-
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@"
17+
ruby -rbundler -e'
18+
Bundler.with_unbundled_env {system *ARGV}' -- \
19+
env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true $@
3320
}
3421

22+
echo "~~~> Removing the old sandbox"
3523
rm -rf ./sandbox
36-
rails new sandbox \
37-
--database="$RAILSDB" \
24+
25+
echo "~~~> Creating a pristine Rails app"
26+
rails_version=`bundle exec ruby -e'require "rails"; puts Rails.version'`
27+
28+
# --skip-solid was added in Rails 8.0 to skip Solid Cache, Queue, and Cable
29+
# setup which is unnecessary for the sandbox and fails during generation.
30+
rails_major=$(echo "$rails_version" | cut -d. -f1)
31+
skip_solid_flag=""
32+
if [ "$rails_major" -ge 8 ] 2>/dev/null; then
33+
skip_solid_flag="--skip-solid"
34+
fi
35+
36+
bundle exec rails _${rails_version}_ new sandbox \
37+
--database="${DB:-sqlite3}" \
3838
--skip-git \
3939
--skip-keeps \
4040
--skip-rc \
4141
--skip-bootsnap \
42-
--skip-test
42+
--skip-test \
43+
$skip_solid_flag
4344

4445
if [ ! -d "sandbox" ]; then
4546
echo 'sandbox rails application failed'
4647
exit 1
4748
fi
4849

50+
echo "~~~> Adding solidus (with i18n) to the Gemfile"
4951
cd ./sandbox
50-
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-main}" --version '> 0.a'
52+
53+
if [ -n "$DB_HOST" ]; then
54+
echo "~~~> Configuring database.yml for DB_HOST=$DB_HOST"
55+
ruby -i -pe '
56+
if $_ =~ /^ pool:/
57+
$_ += " host: <%= ENV.fetch(\"DB_HOST\", \"localhost\") %>\n"
58+
$_ += " username: <%= ENV[\"DB_USERNAME\"] %>\n"
59+
end
60+
' config/database.yml
61+
fi
62+
63+
cat <<RUBY >> Gemfile
64+
gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
65+
gem 'rails-i18n'
66+
gem 'solidus_i18n'
67+
gem 'solidus_auth_devise', github: "solidusio/solidus_auth_devise"
68+
69+
# Ruby 4.0 removed benchmark from default gems, but ActiveSupport requires it.
70+
gem 'benchmark' if RUBY_VERSION >= '4.0'
71+
72+
group :test, :development do
73+
platforms :mri do
74+
gem 'pry-byebug'
75+
end
76+
end
77+
RUBY
78+
79+
echo "Generating manifest file"
80+
mkdir -p app/assets/config
81+
cat <<MANIFESTJS > app/assets/config/manifest.js
82+
//= link_tree ../images
83+
//= link_directory ../javascripts .js
84+
//= link_directory ../stylesheets .css
85+
MANIFESTJS
86+
87+
unbundled bundle install --gemfile Gemfile
88+
5189
unbundled bundle exec rake db:drop db:create
52-
unbundled bundle exec rails generate solidus:install --payment-method=none --auto-accept "$@"
53-
unbundled bundle add ${extension_name} --path '../'
54-
unbundled bundle exec rails generate ${extension_name}:install --frontend=starter --migrate=true
90+
91+
export FRONTEND="$PWD/../template.rb"
92+
unbundled bundle exec rails generate solidus:install \
93+
--auto-accept \
94+
$@
5595

5696
echo
57-
echo "πŸš€ Sandbox app successfully created for ${extension_name}!"
58-
echo "πŸš€ Using $RAILSDB and Solidus $BRANCH"
59-
echo "πŸš€ Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
60-
echo "πŸš€ Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
61-
echo "πŸš€ This app is intended for test purposes."
97+
echo "πŸš€ Sandbox app successfully created for the storefront!"
98+
echo "πŸš€ Use 'export DB=[postgres|mysql|sqlite3]' to control the DB adapter"
99+
echo "πŸ§ͺ This app is intended for test purposes."

0 commit comments

Comments
Β (0)