Skip to content

Commit 094bbab

Browse files
authored
Merge pull request #438 from SuperGoodSoft/fix-github-actions
Fix CI
2 parents 4e24858 + 75cd6bc commit 094bbab

14 files changed

Lines changed: 216 additions & 158 deletions

File tree

.github/workflows/test.yml

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,17 @@
11
name: Test
2+
23
on:
34
push:
45
branches:
56
- main
67
pull_request:
78
schedule:
89
- cron: "0 0 * * 4" # every Thursday
9-
concurrency:
10-
group: test-${{ github.ref_name }}
11-
cancel-in-progress: ${{ github.ref_name != 'master' }}
10+
workflow_call:
11+
1212
permissions:
1313
contents: read
14+
1415
jobs:
1516
rspec:
16-
name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }}
17-
runs-on: ubuntu-24.04
18-
strategy:
19-
fail-fast: true
20-
matrix:
21-
rails-version:
22-
- "7.2"
23-
- "8.0"
24-
ruby-version:
25-
- "3.3"
26-
- "3.4"
27-
solidus-branch:
28-
- "v4.4"
29-
- "v4.5"
30-
- "v4.6"
31-
database:
32-
- "postgresql"
33-
- "mysql"
34-
- "sqlite"
35-
steps:
36-
- uses: actions/checkout@v4
37-
- name: Run extension tests
38-
uses: solidusio/test-solidus-extension@main
39-
with:
40-
database: ${{ matrix.database }}
41-
rails-version: ${{ matrix.rails-version }}
42-
ruby-version: ${{ matrix.ruby-version }}
43-
solidus-branch: ${{ matrix.solidus-branch }}
44-
- name: Upload coverage reports to Codecov
45-
uses: codecov/codecov-action@v5
46-
continue-on-error: true
47-
with:
48-
token: ${{ secrets.CODECOV_TOKEN }}
49-
files: ./coverage/coverage.xml
17+
uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
source 'https://rubygems.org'
44

5-
gem 'rails', ENV['RAILS_VERSION'] || '~> 7.2.0'
5+
gem 'rails', ENV['RAILS_VERSION'] || '~> 8.0.0'
6+
7+
gem "state_machines", "<= 0.6"
68

79
group :development do
10+
gem 'benchmark', '~> 0.5', require: false
811
gem 'guard'
912
gem 'guard-shell'
1013

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![Solidus Starter Frontend Rails Storefront](https://github.com/solidusio/solidus_starter_frontend/assets/167946/16c0298a-a2bd-47d9-a2eb-64bcc8d2fa74)
22

33
# Solidus Starter Frontend
4-
[![CircleCI](https://circleci.com/gh/solidusio/solidus_starter_frontend.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_starter_frontend)
4+
[![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>)
55
[![codecov](https://codecov.io/gh/solidusio/solidus_starter_frontend/branch/main/graph/badge.svg?token=54gge25dNh)](https://codecov.io/gh/solidusio/solidus_starter_frontend)
66

77
`solidus_starter_frontend` is a new starter storefront for [Solidus][solidus].

bin/sandbox

Lines changed: 73 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,104 @@
11
#!/usr/bin/env bash
22

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

6-
replace_in_database_yml() {
7-
if [[ "$DB" == "postgresql" ]]; then
8-
sed -i.bck "/^ adapter:/a \ \ $1: $2" config/database.yml
9-
elif [[ "$DB" == "mysql" ]]; then
10-
sed -i.bck "s/^ $1:.*/\ \ $1: $2/" config/database.yml
11-
fi
6+
test "$DB" = "sqlite" && export DB="sqlite3"
127

13-
test -f config/database.yml.bck && rm -f config/database.yml.bck
14-
}
8+
if [ -z "$PAYMENT_METHOD" ]
9+
then
10+
PAYMENT_METHOD="none"
11+
fi
12+
13+
if [ -z "$SOLIDUS_BRANCH" ]
14+
then
15+
echo "~~> Use 'export SOLIDUS_BRANCH=[main|v4.0|...]' to control the Solidus branch"
16+
SOLIDUS_BRANCH="main"
17+
fi
18+
echo "~~> Using branch $SOLIDUS_BRANCH of solidus"
1519

1620
# Stay away from the bundler env of the containing extension.
1721
function unbundled {
18-
set +x
19-
ruby -rbundler -e'Bundler.with_unbundled_env { system *ARGV }' -- "$@"
22+
ruby -rbundler -e'
23+
Bundler.with_unbundled_env {system *ARGV}' -- \
24+
env BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true $@
2025
}
2126

22-
# "sqlite" is set by the ORB extension instead of "sqlite3",
23-
# all other options are already in the format expected by `rails new`.
24-
test "$DB" = "sqlite" && export DB="sqlite3"
25-
26-
# Remove some noise generated by bundler
27-
export BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES=true
28-
27+
echo "~~~> Removing the old sandbox"
2928
rm -rf ./sandbox
29+
30+
echo "~~~> Creating a pristine Rails app"
3031
rails_version=`bundle exec ruby -e'require "rails"; puts Rails.version'`
31-
rails _${rails_version}_ new sandbox \
32+
33+
# --skip-solid was added in Rails 8.0 to skip Solid Cache, Queue, and Cable
34+
# setup which is unnecessary for the sandbox and fails during generation.
35+
rails_major=$(echo "$rails_version" | cut -d. -f1)
36+
skip_solid_flag=""
37+
if [ "$rails_major" -ge 8 ] 2>/dev/null; then
38+
skip_solid_flag="--skip-solid"
39+
fi
40+
41+
bundle exec rails _${rails_version}_ new sandbox \
42+
--database="${DB:-sqlite3}" \
3243
--skip-git \
33-
--database=${DB:-sqlite3} \
34-
--skip-rc
44+
--skip-keeps \
45+
--skip-rc \
46+
--skip-bootsnap \
47+
--skip-test \
48+
$skip_solid_flag
3549

3650
if [ ! -d "sandbox" ]; then
3751
echo 'sandbox rails application failed'
3852
exit 1
3953
fi
4054

55+
echo "~~~> Adding solidus (with i18n) to the Gemfile"
4156
cd ./sandbox
4257

43-
# Coverage
44-
echo "require_relative '../../coverage.rb' if ENV['COVERAGE']" >> config/boot.rb
45-
echo "gem 'rspec_junit_formatter', require: false" >> Gemfile
46-
echo "gem 'simplecov', '~> 0.22', require: false" >> Gemfile
47-
echo "gem 'simplecov-cobertura', require: false" >> Gemfile
48-
unbundled bundle install
58+
if [ -n "$DB_HOST" ]; then
59+
echo "~~~> Configuring database.yml for DB_HOST=$DB_HOST"
60+
ruby -i -pe '
61+
if $_ =~ /^ pool:/
62+
$_ += " host: <%= ENV.fetch(\"DB_HOST\", \"localhost\") %>\n"
63+
$_ += " username: <%= ENV[\"DB_USERNAME\"] %>\n"
64+
end
65+
' config/database.yml
66+
fi
67+
68+
cat <<RUBY >> Gemfile
69+
gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH'
70+
gem 'rails-i18n'
71+
gem 'solidus_i18n'
72+
gem 'solidus_auth_devise', github: "solidusio/solidus_auth_devise"
73+
74+
# Ruby 4.0 removed benchmark from default gems, but ActiveSupport requires it.
75+
gem 'benchmark' if RUBY_VERSION >= '4.0'
76+
77+
group :test, :development do
78+
platforms :mri do
79+
gem 'pry-byebug'
80+
end
81+
end
82+
RUBY
4983

50-
test -n "${host}" && replace_in_database_yml "host" "${host}"
51-
test -n "${username}" && replace_in_database_yml "username" "${username}"
52-
test -n "${password}" && replace_in_database_yml "password" "${password}"
84+
echo "Generating manifest file"
85+
mkdir -p app/assets/config
86+
cat <<MANIFESTJS > app/assets/config/manifest.js
87+
//= link_tree ../images
88+
//= link_directory ../javascripts .js
89+
//= link_directory ../stylesheets .css
90+
MANIFESTJS
5391

54-
unbundled bundle add solidus \
55-
--github "${SOLIDUS_REPO:-solidusio/solidus}" \
56-
--branch "${SOLIDUS_BRANCH:-main}" \
57-
--version '> 0.a'
92+
unbundled bundle install --gemfile Gemfile
5893

5994
unbundled bundle exec rake db:drop db:create
6095

6196
export FRONTEND="$PWD/../template.rb"
62-
unbundled bundle exec rails generate solidus:install --auto-accept "$@"
97+
unbundled bundle exec rails generate solidus:install \
98+
--auto-accept \
99+
$@
63100

64101
echo
65102
echo "🚀 Sandbox app successfully created for the starter frontend!"
66103
echo "🚀 Use 'export DB=[postgres|mysql|sqlite3]' to control the DB adapter"
67-
echo "🚀 This app is intended for test purposes."
104+
echo "🧪 This app is intended for test purposes."

0 commit comments

Comments
 (0)