Skip to content

Commit 35b09be

Browse files
committed
wip: run tests on github actions
1 parent 7f2d80a commit 35b09be

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: "Test Solidus"
2+
3+
inputs:
4+
lib_name:
5+
description: "The name of the Solidus library to test (e.g., core, backend, frontend)"
6+
type: string
7+
required: true
8+
rails_version:
9+
type: string
10+
description: "The version of Rails to use for testing"
11+
default: "7.2"
12+
ruby_version:
13+
type: string
14+
description: "The version of Ruby to use for testing"
15+
default: "3.2"
16+
database:
17+
type: string
18+
description: "The database to use for testing"
19+
default: sqlite
20+
options:
21+
- sqlite
22+
- mysql
23+
- postgres
24+
paperclip:
25+
type: boolean
26+
description: "Use Paperclip for file attachments instead of ActiveStorage"
27+
default: false
28+
coverage:
29+
description: "Enable code coverage reporting"
30+
type: boolean
31+
default: false
32+
33+
runs:
34+
using: "composite"
35+
steps:
36+
- name: Set up Ruby
37+
uses: ruby/setup-ruby@v1
38+
env:
39+
BUNDLE_WITHOUT: "lint release"
40+
DB: ${{ inputs.database }}
41+
RAILS_VERSION: ${{ inputs.rails_version }}
42+
with:
43+
ruby-version: ${{ inputs.ruby_version }}
44+
bundler-cache: true
45+
- name: Install libvips
46+
if: ${{ inputs.paperclip == false }}
47+
shell: bash
48+
run: |
49+
sudo apt-get update -yq
50+
sudo apt-get autoremove -yq
51+
sudo apt-get install -yq libvips-dev --fix-missing
52+
- name: Run tests
53+
env:
54+
LIB_NAME: ${{ inputs.lib_name }}
55+
RAILS_VERSION: ${{ inputs.rails_version }}
56+
DISABLE_ACTIVE_STORAGE: ${{ inputs.paperclip }}
57+
COVERAGE: ${{ inputs.coverage }}
58+
COVERAGE_DIR: tmp/coverage
59+
DB: ${{ inputs.database }}
60+
DB_HOST: ${{ inputs.database == 'mysql' && '127.0.0.1' || 'localhost' }}
61+
RAILS_ENV: test
62+
shell: bash
63+
run: |
64+
cd ${{ inputs.lib_name }}
65+
bundle exec rake test_app
66+
bundle exec rspec --profile 10 --format progress
67+
- name: Report Coverage
68+
if: ${{ inputs.coverage == true }}
69+
env:
70+
COVERAGE_DIR: tmp/coverage
71+
shell: bash
72+
run: |
73+
bundle exec rake solidus:coverage[cobertura]
74+
- name: Upload Coverage Report
75+
if: ${{ inputs.coverage == true }}
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: coverage-report
79+
path: tmp/coverage/coverage.xml

.github/workflows/test.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
concurrency:
9+
group: test-${{ github.ref_name }}
10+
cancel-in-progress: ${{ github.ref_name != 'main' }}
11+
12+
jobs:
13+
test-core:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# Rails 7.0, 7.1, 7.2, 8.0 + Ruby 3.1 + MySQL + Paperclip
20+
# - rails: "7.0"
21+
# ruby: "3.1"
22+
# database: mysql
23+
# paperclip: true
24+
# - rails: "7.1"
25+
# ruby: "3.1"
26+
# database: mysql
27+
# paperclip: true
28+
# - rails: "7.2"
29+
# ruby: "3.1"
30+
# database: mysql
31+
# paperclip: true
32+
# - rails: "8.0"
33+
# ruby: "3.1"
34+
# database: mysql
35+
# paperclip: true
36+
# Rails 7.0, 7.1, 7.2, 8.0 + Ruby 3.1 + Postgres + ActiveStorage
37+
# - rails: "7.0"
38+
# ruby: "3.1"
39+
# database: postgres
40+
# paperclip: false
41+
# - rails: "7.1"
42+
# ruby: "3.1"
43+
# database: postgres
44+
# paperclip: false
45+
# - rails: "7.2"
46+
# ruby: "3.1"
47+
# database: postgres
48+
# paperclip: false
49+
# - rails: "8.0"
50+
# ruby: "3.1"
51+
# database: postgres
52+
# paperclip: false
53+
# Rails 7.1 + Ruby 3.2 + SQLite + ActiveStorage
54+
# - rails: "7.1"
55+
# ruby: "3.2"
56+
# database: sqlite
57+
# paperclip: false
58+
# Rails 7.2, 8.0, main + Ruby 3.3.5 + SQLite + ActiveStorage
59+
# - rails: "7.2"
60+
# ruby: "3.3"
61+
# database: sqlite
62+
# paperclip: false
63+
# - rails: "8.0"
64+
# ruby: "3.3"
65+
# database: sqlite
66+
# paperclip: false
67+
# - rails: "main"
68+
# ruby: "3.3"
69+
# database: sqlite
70+
# paperclip: false
71+
# Rails 7.2, 8.0 + Ruby 3.4.1 + Postgres + ActiveStorage
72+
- rails: "7.2"
73+
ruby: "3.4"
74+
database: postgres
75+
paperclip: false
76+
# - rails: "8.0"
77+
# ruby: "3.4"
78+
# database: postgres
79+
# paperclip: false
80+
env:
81+
DB_USERNAME: solidus
82+
DB_PASSWORD: password
83+
services:
84+
postgres:
85+
image: postgres:13
86+
env:
87+
POSTGRES_USER: ${{env.DB_USERNAME}}
88+
POSTGRES_PASSWORD: ${{env.DB_PASSWORD}}
89+
POSTGRES_DB: solidus_test
90+
ports: [5432:5432]
91+
options: >-
92+
--health-cmd pg_isready
93+
--health-interval 10s
94+
--health-timeout 5s
95+
--health-retries 5
96+
mysql:
97+
image: mysql:5.7
98+
env:
99+
MYSQL_ROOT_PASSWORD: ${{env.DB_PASSWORD}}
100+
MYSQL_DATABASE: solidus_test
101+
ports: [3306:3306]
102+
options: >-
103+
--health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -proot"
104+
--health-interval 10s
105+
--health-timeout 5s
106+
--health-retries 5
107+
steps:
108+
- uses: actions/checkout@v4
109+
- name: Test Solidus
110+
uses: ./.github/actions/test_solidus
111+
env:
112+
DEFAULT_MAX_WAIT_TIME: 10
113+
SOLIDUS_RAISE_DEPRECATIONS: true
114+
with:
115+
lib_name: core
116+
rails_version: ${{ matrix.rails }}
117+
ruby_version: ${{ matrix.ruby }}
118+
database: ${{ matrix.database }}
119+
paperclip: ${{ matrix.paperclip }}
120+
coverage: ${{ matrix.ruby == '3.4' && matrix.rails == '8.0' && matrix.database == 'postgres' && matrix.paperclip == false }}

0 commit comments

Comments
 (0)