Skip to content

CI: Extract solidus installer and dummy app into GH workflow #6217

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
121 changes: 0 additions & 121 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,128 +143,7 @@ commands:
sudo apt-get update
sudo apt-get install -yq libvips-dev

install_solidus:
parameters:
flags:
type: string
default: "# no options"
description: "flags to be passed to `bin/rails g solidus:install"
steps:
- run:
name: "Cleanup & check rails version"
command: |
sudo gem update --system
gem install bundler -v"~> 2.4"
gem environment path
rm -rf /tmp/my_app /tmp/.ruby-versions # cleanup previous runs
rm -rf /tmp/my_app /tmp/.gems-versions # cleanup previous runs

ruby -v >> /tmp/.ruby-versions
gem --version >> /tmp/.gems-versions
bundle --version >> /tmp/.gems-versions
gem search -eq rails -v "~> 7" -v "< 8.0" >> /tmp/.gems-versions # get the latest rails from rubygems
gem search -eq solidus >> /tmp/.gems-versions # get the latest solidus from rubygems

cat /tmp/.ruby-versions
cat /tmp/.gems-versions
- restore_cache:
keys:
- solidus-installer-v11-{{ checksum "/tmp/.ruby-versions" }}-{{ checksum "/tmp/.gems-versions" }}
- solidus-installer-v11-{{ checksum "/tmp/.ruby-versions" }}-
- run:
name: "Prepare the rails application"
command: |
cd /tmp
test -d my_app || (gem install rails -v "< 8.0" && gem install solidus)
test -d my_app || rails new my_app --skip-git
- save_cache:
key: solidus-installer-v11-{{ checksum "/tmp/.ruby-versions" }}-{{ checksum "/tmp/.gems-versions" }}
paths:
- /tmp/my_app
- /home/circleci/.rubygems
- run:
name: "Run `solidus:install` with `<<parameters.flags>>`"
command: |
cd /tmp/my_app
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")"
unset RAILS_ENV # avoid doing everything on the test environment
bin/rails generate solidus:install --auto-accept <<parameters.flags>>

test_page:
parameters:
app_root:
type: string
default: "/tmp/my_app"
path:
type: string
default: "/"
expected_text:
type: string

steps:
- run:
name: "Check the contents of the <<parameters.path>> page"
command: |
cd <<parameters.app_root>>
unset RAILS_ENV # avoid doing everything on the test environment
bin/rails server -p 3000 &
wget --quiet --output-document - --tries=30 --retry-connrefused "http://localhost:3000<<parameters.path>>" | grep "<<parameters.expected_text>>"
echo "Exited with $?"
kill $(cat "tmp/pids/server.pid")

install_dummy_app:
parameters:
extra_gems:
type: string
default: ""
description: "Gems to be added to the extension's Gemfile before running the installer"
steps:
- run:
name: "Test `rake task: extensions:test_app` <<#parameters.extra_gems>>(with <<parameters.extra_gems>>)<</parameters.extra_gems>>"
command: |
rm -rf /tmp/dummy_extension # cleanup previous runs
mkdir -p /tmp/dummy_extension
cd /tmp/dummy_extension
bundle init
bundle add rails -v "< 8.1" --skip-install
bundle add sqlite3 -v "~> 2.0" --skip-install
test -n "<<parameters.extra_gems>>" && bundle add <<parameters.extra_gems>> --skip-install
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")"
export LIB_NAME=set # dummy requireable file
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'

jobs:
solidus_installer:
executor:
name: sqlite
ruby: "3.1"
steps:
- checkout
- run:
name: "Skip for Solidus older than 4.2"
command: |
ruby -I. -rcore/lib/spree/core/version.rb -e "exit Spree.solidus_gem_version >= Gem::Version.new('4.2')" ||
circleci-agent step halt
- libvips
- install_solidus:
flags: "--sample=false --frontend=starter --authentication=devise"
- test_page:
expected_text: "<title>Sample Store</title>"
- run:
name: Ensure the correct PayPal is installed for SSF
command: |
cd /tmp/my_app
bundle list | grep 'solidus_paypal_commerce_platform (1.'
- install_solidus:
flags: "--sample=false --frontend=starter --authentication=devise --payment-method=stripe"
- test_page:
expected_text: "<title>Sample Store</title>"
- install_dummy_app
- run:
name: "Ensure extension test app is created"
command: |
test -d /tmp/dummy_extension/spec/dummy

test_solidus:
parameters:
database:
Expand Down
23 changes: 23 additions & 0 deletions .github/actions/check_page_content/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Install Solidus"

inputs:
app_root:
type: string
default: "/tmp/my_app"
path:
type: string
default: "/"
expected_text:
type: string

runs:
using: "composite"
steps:
- name: "Check the contents of the `${{ inputs.path }}` page"
run: |
cd $RUNNER_TEMP/my_app
unset RAILS_ENV # avoid doing everything on the test environment
bin/rails server -p 3000 &
wget --quiet --output-document - --tries=30 --retry-connrefused "http://localhost:3000/" | grep "<title>Sample Store</title>"
echo "Exited with $?"
kill $(cat "tmp/pids/server.pid")
31 changes: 31 additions & 0 deletions .github/actions/install_dummy_app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Install Dummy App"
inputs:
extra_gems:
type: string
default: ""
description: "Gems to be added to the extension's Gemfile before running the installer"
ruby_version:
type: string
default: "3.2"

runs:
using: "composite"
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.ruby_version }}
bundler-cache: true
rubygems: "latest"
- name: "Test `rake extension:test_app`"
run: |
rm -rf $RUNNER_TEMP/dummy_extension # cleanup previous runs
mkdir -p $RUNNER_TEMP/dummy_extension
cd $RUNNER_TEMP/dummy_extension
bundle init
bundle add rails -v "< 8.1" --skip-install
bundle add sqlite3 -v "~> 2.0" --skip-install
test -n "${{ inputs.extra_gems }}" && bundle add ${{ inputs.extra_gems }} --skip-install
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['GITHUB_WORKSPACE']")"
export LIB_NAME=set # dummy requireable file
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'
54 changes: 54 additions & 0 deletions .github/actions/install_solidus/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Install Solidus"

inputs:
flags:
type: string
default: "# no options"
description: "flags to be passed to `bin/rails g solidus:install"
ruby_version:
type: string
default: "3.2"

runs:
using: "composite"
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.ruby_version }}
bundler-cache: true
rubygems: "latest"
- name: "Cleanup & check rails version"
run: |
gem environment path
rm -rf $RUNNER_TEMP/my_app $RUNNER_TEMP/.ruby-versions # cleanup previous runs
rm -rf $RUNNER_TEMP/my_app $RUNNER_TEMP/.gems-versions # cleanup previous runs

ruby -v >> $RUNNER_TEMP/.ruby-versions
gem --version >> $RUNNER_TEMP/.gems-versions
bundle --version >> $RUNNER_TEMP/.gems-versions
gem search -eq rails -v "~> 7" -v "< 8.0" >> $RUNNER_TEMP/.gems-versions # get the latest rails from rubygems
gem search -eq solidus >> $RUNNER_TEMP/.gems-versions # get the latest solidus from rubygems

cat $RUNNER_TEMP/.ruby-versions
cat $RUNNER_TEMP/.gems-versions
- uses: actions/cache@v4
with:
path: |
$RUNNER_TEMP/my_app
/home/runner/.rubygems
key:
- solidus-installer-v1-${{ hashFiles("$RUNNER_TEMP/.ruby-versions") }}-${{ hashFiles("$RUNNER_TEMP/.gems-versions") }}
restore-keys:
- solidus-installer-v1-${{ hashFiles("$RUNNER_TEMP/.ruby-versions") }}-
- name: "Prepare the rails application"
run: |
cd $RUNNER_TEMP
test -d my_app || (gem install rails -N -v "< 8.0" && gem install solidus -N)
test -d my_app || rails new my_app --skip-git
- name: "Run `solidus:install` with `${{ inputs.flags }}`"
run: |
cd $RUNNER_TEMP/my_app
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['GITHUB_WORKSPACE']")"
unset RAILS_ENV # avoid doing everything on the test environment
bin/rails generate solidus:install --auto-accept ${{ inputs.flags }}
39 changes: 39 additions & 0 deletions .github/workflows/install_dummy_app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Install Dummy App"

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
install_dummy_app:
name: Install Dummy App
runs-on: ubuntu-24.04
env:
RUBY_VERSION: "3.2"
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
rubygems: "latest"
- name: "Test `rake extension:test_app`"
run: |
rm -rf $RUNNER_TEMP/dummy_extension # cleanup previous runs
mkdir -p $RUNNER_TEMP/dummy_extension
cd $RUNNER_TEMP/dummy_extension
bundle init
bundle add rails -v "< 8.1" --skip-install
bundle add sqlite3 -v "~> 2.0" --skip-install
test -n "${{ inputs.extra_gems }}" && bundle add ${{ inputs.extra_gems }} --skip-install
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['GITHUB_WORKSPACE']")"
export LIB_NAME=set # dummy requireable file
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'
- name: "Ensure extension test app is created"
run: |
test -d /tmp/dummy_extension/spec/dummy_app
47 changes: 47 additions & 0 deletions .github/workflows/solidus_installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Test Solidus Installer"

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: solidus-installer-${{ github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'main' }}

jobs:
solidus_installer:
name: Solidus Installer
runs-on: ubuntu-24.04
env:
DB: sqlite
RUBY_VERSION: "3.2"
steps:
- uses: actions/checkout@v4
- name: Install libvips
run: |
sudo apt-get update
sudo apt-get install -yq libvips-dev
- name: Install Solidus
uses: ./.github/actions/install_solidus
with:
flags: "--sample=false --frontend=starter --authentication=devise"
- name: "Check homepage"
uses: ./.github/actions/check_page_content
with:
expected_text: "<title>Sample Store</title>"
- name: Ensure the correct PayPal is installed for SSF
run: |
cd $RUNNER_TEMP/my_app
bundle list | grep 'solidus_paypal_commerce_platform (1.'
- name: Install Solidus
uses: ./.github/actions/install_solidus
with:
flags: "--sample=false --frontend=starter --authentication=devise --payment-method=stripe"
- name: "Check homepage"
uses: ./.github/actions/check_page_content
with:
expected_text: "<title>Sample Store</title>"
Loading