pr-build #89
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: pr-build | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
push: | |
branches: [main, develop] | |
schedule: | |
- cron: '0 0 * * 0' | |
jobs: | |
pr-build: | |
runs-on: ${{ matrix.os }} | |
env: | |
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/Gemfile.rails-${{ matrix.rails }} | |
RAILS_ENV: test | |
CC_TEST_REPORTER_ID: 7a37992f3e7ec03ea12b707bc46196f12a8814e51a5b64d7763738d9844b9f0d | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: password | |
MYSQL_ROOT_PASSWORD: password | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: wallaby_active_record_dummy_test | |
POSTGRES_USER: ${{ env.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
mysql: | |
image: mysql:latest | |
env: | |
MYSQL_DATABASE: wallaby_active_record_dummy_test | |
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd "mysqladmin ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
# NOTE: check the versions that Ruby supports at https://www.ruby-lang.org/en/downloads/branches/ | |
ruby: ['3.2', '3.1', '3.0', '2.7'] | |
# NOTE: check the versions that Rails supports at https://guides.rubyonrails.org/maintenance_policy.html | |
rails: ['7.0', '6.1', '6.0'] | |
# NOTE: .keep | |
exclude: [] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
bundler-cache: true | |
- name: Rubocop Check | |
if: ${{ github.event_name == 'pull_request' }} | |
run: git diff --name-only ${{ github.event.pull_request.base.sha }} --diff-filter AMT | xargs bundle exec rubocop --force-exclusion | |
- name: Rspec | |
run: | | |
if [[ "$GITHUB_BASE_REF" != @(main|develop) ]]; then curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter; fi | |
if [[ "$GITHUB_BASE_REF" != @(main|develop) ]]; then chmod +x ./cc-test-reporter; fi | |
if [[ "$GITHUB_BASE_REF" != @(main|develop) ]]; then ./cc-test-reporter before-build; fi | |
bundle exec rake --trace db:test:prepare spec | |
if [[ "$GITHUB_BASE_REF" != @(main|develop) ]]; then ./cc-test-reporter after-build -r ${{ env.CC_TEST_REPORTER_ID }}; fi |