GitHub Actions: Test Rails with MiniTest and report to Codecov, Second action for code quality checks
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: "Code Quality" | |
on: | |
push: | |
branches: [ "**" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
CodeQuality: | |
runs-on: ubuntu-latest | |
env: | |
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
steps: | |
# Config | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install Ruby and gems | |
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3 | |
with: | |
bundler-cache: true | |
# from https://github.com/tomferreira/action-bundler-audit | |
- name: 📋 Bundler audit - Check for vulnerable gems | |
uses: tomferreira/action-bundler-audit@v1 | |
with: | |
bundler_audit_version: gemfile | |
fail_on_error: true | |
# from https://github.com/reviewdog/action-brakeman | |
- name: 👮 Brakeman - Security audit application code | |
uses: reviewdog/action-brakeman@v2 | |
with: | |
fail_on_error: true | |
# from https://github.com/reviewdog/action-rubocop | |
- name: 🤖 Rubocop 🚨 | |
uses: reviewdog/action-rubocop@v2 | |
with: | |
rubocop_extensions: rubocop-rails rubocop-performance rubocop-minitest | |
reporter: github-pr-review | |
fail_on_error: true | |
- name: 🤖 Rubocop ✅ | |
uses: reviewdog/action-rubocop@v2 | |
with: | |
rubocop_extensions: rubocop-rails rubocop-performance rubocop-minitest | |
reporter: github-check | |
fail_on_error: true | |
# from https://github.com/reviewdog/action-actionlint | |
- name: GitHub Action Lint | |
uses: reviewdog/action-actionlint@v1 |
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: "Minitest" | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2 * * 0' | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:14.5-alpine | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 500ms | |
--health-retries 15 | |
ports: | |
# Maps port 5432 on service container to the host | |
- "5432:5432" | |
env: | |
POSTGRES_DB: rails_test | |
POSTGRES_USER: rails | |
POSTGRES_PASSWORD: password | |
redis: | |
image: redis | |
# Set health checks to wait until redis has started | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 500ms | |
--health-retries 15 | |
--entrypoint redis-server | |
# Maps port 6379 on service container to the host | |
ports: | |
- "6379:6379" | |
env: | |
RAILS_ENV: test | |
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" | |
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
REDIS_HOST: localhost | |
REDIS_PORT: 6379 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Add or replace dependency steps here | |
- name: Install Ruby and gems | |
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3 | |
with: | |
bundler-cache: true | |
# Add or replace database setup steps here | |
- name: Set up database schema | |
run: bin/rails db:schema:load | |
# Add or replace test runners here | |
- name: Run tests | |
run: bin/rails test | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true # optional (default = false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment