Run tests on github actions #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
schedule: | |
- cron: "0 0 * * 4" # every Thursday | |
concurrency: | |
group: test-${{ github.ref_name }} | |
cancel-in-progress: ${{ github.ref_name != 'main' }} | |
permissions: | |
contents: read | |
jobs: | |
Rspec: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby-version: | |
- "3.1" | |
- "3.2" | |
- "3.3" | |
solidus: | |
- "v4.1" | |
- "v4.2" | |
- "v4.3" | |
- "v4.4" | |
database: | |
- "postgresql" | |
- "mysql" | |
- "sqlite" | |
env: | |
SOLIDUS_BRANCH: ${{ matrix.solidus }} | |
DB: ${{ matrix.database }} | |
RAILS_ENV: test | |
services: | |
postgres: | |
image: postgres:14 | |
env: | |
POSTGRES_USER: dummy | |
POSTGRES_PASSWORD: dummy | |
POSTGRES_DB: dummy_test | |
ports: ["5432:5432"] | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
mysql: | |
image: mysql:5.7 | |
ports: ['3306:3306'] | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_ROOT_HOST: '%' | |
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby-version }} | |
bundler-cache: true | |
- name: Setup mysql database connection | |
run: | | |
mkdir -p /home/runner/apt/cache | |
sudo apt update -qq | |
sudo apt install -qq --fix-missing libmysqlclient-dev -o dir::cache::archives="/home/runner/apt/cache" | |
sudo chown -R runner /home/runner/apt/cache | |
echo "DATABASE_URL=mysql2://[email protected]:3306/dummy_test?pool=5" >> $GITHUB_ENV | |
if: matrix.database == 'mysql' | |
- name: Setup postgresql database connection | |
if: matrix.database == 'postgresql' | |
run: | | |
mkdir -p /home/runner/apt/cache | |
sudo apt update -qq | |
sudo apt install -qq --fix-missing libpq-dev -o dir::cache::archives="/home/runner/apt/cache" | |
sudo chown -R runner /home/runner/apt/cache | |
echo "DATABASE_URL=postgres://dummy:[email protected]:5432/dummy_test?pool=5" >> $GITHUB_ENV | |
- name: Run tests for Solidus ${{ matrix.solidus }} on ${{ matrix.database }} with Ruby ${{ matrix.ruby-version }} | |
run: bundle exec rake | |
- name: Store test results | |
uses: actions/upload-artifact@v4 | |
with: | |
path: test-results |