Skip to content

Commit e87e973

Browse files
committed
CI: Extract solidus installer and dummy app into GH workflow
We want to migrate away from CircleCI and these two workflows can be run in parallel pretty fine. (cherry picked from commit 638d84d)
1 parent 7f7180e commit e87e973

File tree

5 files changed

+169
-122
lines changed

5 files changed

+169
-122
lines changed

.circleci/config.yml

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -141,128 +141,7 @@ commands:
141141
sudo apt-get update
142142
sudo apt-get install -yq libvips-dev
143143
144-
install_solidus:
145-
parameters:
146-
flags:
147-
type: string
148-
default: "# no options"
149-
description: "flags to be passed to `bin/rails g solidus:install"
150-
steps:
151-
- run:
152-
name: "Cleanup & check rails version"
153-
command: |
154-
sudo gem update --system
155-
gem install bundler -v"~> 2.4"
156-
gem environment path
157-
rm -rf /tmp/my_app /tmp/.ruby-versions # cleanup previous runs
158-
rm -rf /tmp/my_app /tmp/.gems-versions # cleanup previous runs
159-
160-
ruby -v >> /tmp/.ruby-versions
161-
gem --version >> /tmp/.gems-versions
162-
bundle --version >> /tmp/.gems-versions
163-
gem search -eq rails -v "~> 7" -v "< 8.0" >> /tmp/.gems-versions # get the latest rails from rubygems
164-
gem search -eq solidus >> /tmp/.gems-versions # get the latest solidus from rubygems
165-
166-
cat /tmp/.ruby-versions
167-
cat /tmp/.gems-versions
168-
- restore_cache:
169-
keys:
170-
- solidus-installer-v11-{{ checksum "/tmp/.ruby-versions" }}-{{ checksum "/tmp/.gems-versions" }}
171-
- solidus-installer-v11-{{ checksum "/tmp/.ruby-versions" }}-
172-
- run:
173-
name: "Prepare the rails application"
174-
command: |
175-
cd /tmp
176-
test -d my_app || (gem install rails -v "< 8.0" && gem install solidus)
177-
test -d my_app || rails new my_app --skip-git
178-
- save_cache:
179-
key: solidus-installer-v11-{{ checksum "/tmp/.ruby-versions" }}-{{ checksum "/tmp/.gems-versions" }}
180-
paths:
181-
- /tmp/my_app
182-
- /home/circleci/.rubygems
183-
- run:
184-
name: "Run `solidus:install` with `<<parameters.flags>>`"
185-
command: |
186-
cd /tmp/my_app
187-
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")"
188-
unset RAILS_ENV # avoid doing everything on the test environment
189-
bin/rails generate solidus:install --auto-accept <<parameters.flags>>
190-
191-
test_page:
192-
parameters:
193-
app_root:
194-
type: string
195-
default: "/tmp/my_app"
196-
path:
197-
type: string
198-
default: "/"
199-
expected_text:
200-
type: string
201-
202-
steps:
203-
- run:
204-
name: "Check the contents of the <<parameters.path>> page"
205-
command: |
206-
cd <<parameters.app_root>>
207-
unset RAILS_ENV # avoid doing everything on the test environment
208-
bin/rails server -p 3000 &
209-
wget --quiet --output-document - --tries=30 --retry-connrefused "http://localhost:3000<<parameters.path>>" | grep "<<parameters.expected_text>>"
210-
echo "Exited with $?"
211-
kill $(cat "tmp/pids/server.pid")
212-
213-
install_dummy_app:
214-
parameters:
215-
extra_gems:
216-
type: string
217-
default: ""
218-
description: "Gems to be added to the extension's Gemfile before running the installer"
219-
steps:
220-
- run:
221-
name: "Test `rake task: extensions:test_app` <<#parameters.extra_gems>>(with <<parameters.extra_gems>>)<</parameters.extra_gems>>"
222-
command: |
223-
rm -rf /tmp/dummy_extension # cleanup previous runs
224-
mkdir -p /tmp/dummy_extension
225-
cd /tmp/dummy_extension
226-
bundle init
227-
bundle add rails -v "< 8.1" --skip-install
228-
bundle add sqlite3 -v "~> 2.0" --skip-install
229-
test -n "<<parameters.extra_gems>>" && bundle add <<parameters.extra_gems>> --skip-install
230-
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")"
231-
export LIB_NAME=set # dummy requireable file
232-
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'
233-
234144
jobs:
235-
solidus_installer:
236-
executor:
237-
name: sqlite
238-
ruby: "3.1"
239-
steps:
240-
- checkout
241-
- run:
242-
name: "Skip for Solidus older than 4.2"
243-
command: |
244-
ruby -I. -rcore/lib/spree/core/version.rb -e "exit Spree.solidus_gem_version >= Gem::Version.new('4.2')" ||
245-
circleci-agent step halt
246-
- libvips
247-
- install_solidus:
248-
flags: "--sample=false --frontend=starter --authentication=devise"
249-
- test_page:
250-
expected_text: "<title>Sample Store</title>"
251-
- run:
252-
name: Ensure the correct PayPal is installed for SSF
253-
command: |
254-
cd /tmp/my_app
255-
bundle list | grep 'solidus_paypal_commerce_platform (1.'
256-
- install_solidus:
257-
flags: "--sample=false --frontend=starter --authentication=devise --payment-method=stripe"
258-
- test_page:
259-
expected_text: "<title>Sample Store</title>"
260-
- install_dummy_app
261-
- run:
262-
name: "Ensure extension test app is created"
263-
command: |
264-
test -d /tmp/dummy_extension/spec/dummy
265-
266145
test_solidus:
267146
parameters:
268147
database:
@@ -341,7 +220,6 @@ jobs:
341220
workflows:
342221
build:
343222
jobs:
344-
- solidus_installer
345223
- test_solidus_with_coverage # Only test with coverage support with the default versions
346224

347225
# Based on supported versions for the current Solidus release and recommended versions from
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Install Solidus"
2+
3+
inputs:
4+
app_root:
5+
type: string
6+
default: "/tmp/my_app"
7+
path:
8+
type: string
9+
default: "/"
10+
expected_text:
11+
type: string
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: "Check the contents of the `${{ inputs.path }}` page"
17+
shell: bash
18+
run: |
19+
cd $RUNNER_TEMP/my_app
20+
unset RAILS_ENV # avoid doing everything on the test environment
21+
bin/rails server -p 3000 &
22+
wget --quiet --output-document - --tries=30 --retry-connrefused "http://localhost:3000/" | grep "<title>Sample Store</title>"
23+
echo "Exited with $?"
24+
kill $(cat "tmp/pids/server.pid")
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "Install Solidus"
2+
3+
inputs:
4+
flags:
5+
type: string
6+
default: "# no options"
7+
description: "flags to be passed to `bin/rails g solidus:install"
8+
rails_version:
9+
type: string
10+
default: "7.2"
11+
ruby_version:
12+
type: string
13+
default: "3.2"
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Set up Ruby
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: ${{ inputs.ruby_version }}
22+
bundler-cache: true
23+
rubygems: "latest"
24+
- name: "Cleanup & check rails version"
25+
shell: bash
26+
run: |
27+
gem environment path
28+
rm -rf $RUNNER_TEMP/my_app $RUNNER_TEMP/.ruby-versions # cleanup previous runs
29+
rm -rf $RUNNER_TEMP/my_app $RUNNER_TEMP/.gems-versions # cleanup previous runs
30+
31+
ruby -v >> $RUNNER_TEMP/.ruby-versions
32+
gem --version >> $RUNNER_TEMP/.gems-versions
33+
bundle --version >> $RUNNER_TEMP/.gems-versions
34+
gem search -eq rails -v "${{ inputs.rails_version }}" >> $RUNNER_TEMP/.gems-versions # get the latest rails from rubygems
35+
gem search -eq solidus >> $RUNNER_TEMP/.gems-versions # get the latest solidus from rubygems
36+
37+
cat $RUNNER_TEMP/.ruby-versions
38+
cat $RUNNER_TEMP/.gems-versions
39+
- uses: actions/cache@v4
40+
with:
41+
path: |
42+
/home/runner/.rubygems
43+
key: |
44+
solidus-installer-v1-${{ hashFiles('${{ runner.temp }}/.ruby-versions') }}-${{ hashFiles('${{ runner.temp }}/.gems-versions') }}
45+
restore-keys: |
46+
solidus-installer-v1-${{ hashFiles('${{ runner.temp }}/.ruby-versions') }}-
47+
- name: "Prepare the rails application"
48+
shell: bash
49+
run: |
50+
cd $RUNNER_TEMP
51+
test -d my_app || (gem install solidus rails:'${{ inputs.rails_version }}' -N)
52+
test -d my_app || rails new my_app --skip-git
53+
- name: "Run `solidus:install` with `${{ inputs.flags }}`"
54+
shell: bash
55+
run: |
56+
cd $RUNNER_TEMP/my_app
57+
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['GITHUB_WORKSPACE']")"
58+
unset RAILS_ENV # avoid doing everything on the test environment
59+
bin/rails generate solidus:install --auto-accept ${{ inputs.flags }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Extension Generator"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
install_dummy_app:
13+
name: Dummy App
14+
runs-on: ubuntu-24.04
15+
env:
16+
RUBY_VERSION: "3.2"
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: ${{ env.RUBY_VERSION }}
23+
bundler-cache: true
24+
rubygems: "latest"
25+
- name: "Test `rake extension:test_app`"
26+
run: |
27+
rm -rf $RUNNER_TEMP/dummy_extension # cleanup previous runs
28+
mkdir -p $RUNNER_TEMP/dummy_extension
29+
cd $RUNNER_TEMP/dummy_extension
30+
bundle init
31+
bundle add rails -v "< 8.1" --skip-install
32+
bundle add sqlite3 -v "~> 2.0" --skip-install
33+
test -n "${{ inputs.extra_gems }}" && bundle add ${{ inputs.extra_gems }} --skip-install
34+
bundle add solidus --path "$(ruby -e"puts File.expand_path ENV['GITHUB_WORKSPACE']")"
35+
export LIB_NAME=set # dummy requireable file
36+
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'
37+
- name: "Ensure extension test app is created"
38+
run: |
39+
test -d ${{ runner.temp }}/dummy_extension/spec/dummy
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Solidus Installer"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: solidus-installer-${{ github.ref_name }}
13+
cancel-in-progress: ${{ github.ref_name != 'main' }}
14+
15+
jobs:
16+
solidus_installer:
17+
name: Test Installer
18+
runs-on: ubuntu-24.04
19+
env:
20+
DB: sqlite
21+
RUBY_VERSION: "3.2"
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Install libvips
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -yq libvips-dev
28+
- name: Install Solidus
29+
uses: ./.github/actions/install_solidus
30+
with:
31+
flags: "--sample=false --frontend=starter --authentication=devise"
32+
- name: "Check homepage"
33+
uses: ./.github/actions/check_page_content
34+
with:
35+
expected_text: "<title>Sample Store</title>"
36+
- name: Ensure the correct PayPal is installed for SSF
37+
run: |
38+
cd $RUNNER_TEMP/my_app
39+
bundle list | grep 'solidus_paypal_commerce_platform (1.'
40+
- name: Install Solidus
41+
uses: ./.github/actions/install_solidus
42+
with:
43+
flags: "--sample=false --frontend=starter --authentication=devise --payment-method=stripe"
44+
- name: "Check homepage"
45+
uses: ./.github/actions/check_page_content
46+
with:
47+
expected_text: "<title>Sample Store</title>"

0 commit comments

Comments
 (0)