Skip to content

Commit 364116e

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.
1 parent 8ca4115 commit 364116e

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

349227
# 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)