Add RuboCop and Rspec GH action workflow #34
Workflow file for this run
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
env: | |
RUBY_VERSION: 3.2.1 | |
RAILS_ENV: test | |
HEALTHKEEPER_TEST_DATABASE_USERNAME: postgres | |
HEALTHKEEPER_TEST_DATABASE_PASSWORD: postgres | |
HEALTHKEEPER_TEST_DATABASE: healthkeeper_test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: healthkeeper_test | |
POSTGRES_HOST: localhost | |
name: Rails tests | |
on: [pull_request] | |
jobs: | |
rubocop-test: | |
name: Rubocop | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ env.RUBY_VERSION }} | |
bundler-cache: true | |
- name: Install Rubocop | |
run: gem install rubocop | |
- name: Install Rubocop Performance | |
run: gem install rubocop-performance | |
- name: Install Rubocop Rails | |
run: gem install rubocop-rails | |
- name: Install Rubocop Rspec | |
run: gem install rubocop-rspec | |
- name: Install Rubocop Rspec Rails | |
run: gem install rubocop-rspec_rails | |
- name: Install Rubocop Factory Bot | |
run: gem install rubocop-factory_bot | |
- name: Check code | |
run: rubocop | |
rspec-test: | |
name: RSpec | |
needs: rubocop-test | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:17.1-alpine | |
env: | |
POSTGRES_USER: ${{ env.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
POSTGRES_DB: ${{ env.POSTGRES_DB }} | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ env.RUBY_VERSION }} | |
bundler-cache: true | |
- name: Install postgres client | |
run: sudo apt-get install libpq-dev | |
- name: Install dependencies | |
run: | | |
gem install bundler | |
bundler install | |
- name: Create database | |
env: | |
RAILS_ENV: test | |
# DATABASE_URL: postgres://postgres:postgres@localhost:5432/healthkeeper_test | |
run: | | |
bundler exec rails db:create | |
bundler exec rails db:migrate | |
- name: Run tests | |
run: bundler exec rspec |