Skip to content

Commit 2a53486

Browse files
committed
wip: run tests on github actions
1 parent 125d862 commit 2a53486

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed
File renamed without changes.

.github/workflows/test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
solidus_admin:
14+
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
15+
with:
16+
lib_name: admin
17+
coverage: false
18+
19+
solidus_api:
20+
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
21+
with:
22+
lib_name: api
23+
coverage: false
24+
25+
solidus_backend:
26+
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
27+
with:
28+
lib_name: backend
29+
coverage: false
30+
31+
solidus_core:
32+
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
33+
with:
34+
lib_name: core
35+
coverage: false
36+
37+
solidus_promotions:
38+
uses: solidusio/solidus/.github/workflows/test_solidus.yml@run-tests-on-github-actions
39+
with:
40+
lib_name: promotions
41+
coverage: false

.github/workflows/test_solidus.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: "Test Solidus"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
lib_name:
7+
description: "The name of the Solidus library to test (e.g., core, backend, frontend)"
8+
type: string
9+
required: true
10+
coverage:
11+
description: "Enable code coverage reporting"
12+
type: boolean
13+
default: false
14+
15+
jobs:
16+
run_tests:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: true
20+
matrix:
21+
include:
22+
- rails: "7.2"
23+
ruby: "3.4"
24+
database: postgres
25+
storage: paperclip
26+
env:
27+
BUNDLE_WITHOUT: "lint release"
28+
COVERAGE: ${{ inputs.coverage }}
29+
COVERAGE_DIR: tmp/coverage
30+
DB: ${{ matrix.database }}
31+
DB_HOST: ${{ matrix.database == 'mysql' && '127.0.0.1' || 'localhost' }}
32+
DB_USERNAME: solidus
33+
DB_PASSWORD: password
34+
DEFAULT_MAX_WAIT_TIME: 10
35+
DISABLE_ACTIVE_STORAGE: ${{ matrix.storage == 'paperclip' }}
36+
LIB_NAME: ${{ inputs.lib_name }}
37+
RAILS_ENV: test
38+
RAILS_VERSION: ${{ matrix.rails }}
39+
SOLIDUS_RAISE_DEPRECATIONS: true
40+
services:
41+
postgres:
42+
image: postgres:13
43+
env:
44+
POSTGRES_USER: ${{ env.DB_USERNAME }}
45+
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
46+
POSTGRES_DB: solidus_test
47+
ports: [5432:5432]
48+
options: >-
49+
--health-cmd pg_isready
50+
--health-interval 10s
51+
--health-timeout 5s
52+
--health-retries 5
53+
mysql:
54+
image: mysql:5.7
55+
env:
56+
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
57+
MYSQL_DATABASE: solidus_test
58+
ports: [3306:3306]
59+
options: >-
60+
--health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -proot"
61+
--health-interval 10s
62+
--health-timeout 5s
63+
--health-retries 5
64+
steps:
65+
- name: Set up Ruby
66+
uses: ruby/setup-ruby@v1
67+
with:
68+
ruby-version: ${{ matrix.ruby }}
69+
bundler-cache: true
70+
- name: Install libvips
71+
if: ${{ matrix.storage == 'activestorage' }}
72+
run: |
73+
sudo apt-get update -yq
74+
sudo apt-get autoremove -yq
75+
sudo apt-get install -yq libvips-dev --fix-missing
76+
- name: Run tests
77+
run: |
78+
cd ${{ inputs.lib_name }}
79+
bundle exec rake test_app
80+
bundle exec rspec --profile 10 --format progress
81+
- name: Report Coverage
82+
if: ${{ inputs.coverage == 'true' }}
83+
run: |
84+
bundle exec rake solidus:coverage[cobertura]
85+
- name: Upload Coverage Report
86+
if: ${{ inputs.coverage == 'true' }}
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: coverage-report
90+
path: tmp/coverage/coverage.xml

0 commit comments

Comments
 (0)