Skip to content

Commit

Permalink
Add RuboCop and Rspec GH action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aksafan committed Nov 25, 2024
1 parent 43c505c commit 5ae6fda
Show file tree
Hide file tree
Showing 9 changed files with 452 additions and 65 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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
17 changes: 17 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
inherit_from: .rubocop_todo.yml

inherit_mode:
merge:
- Exclude

require:
- rubocop-performance
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
- rubocop-factory_bot

AllCops:
NewCops: enable

RSpec/FilePath:
Enabled: false
Loading

0 comments on commit 5ae6fda

Please sign in to comment.