rails_mysql CI #23
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: rails_mysql CI | |
on: | |
pull_request: | |
push: | |
branches: [ main ] | |
paths: [ rails_mysql/** ] | |
workflow_dispatch: | |
env: | |
rails_app_root: rails_mysql | |
DB_HOST: mysql | |
jobs: | |
scan_ruby: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
working-directory: ${{ env.rails_app_root }} | |
bundler-cache: true | |
- name: Scan for common Rails security vulnerabilities using static analysis | |
run: ./bin/brakeman --no-pager | |
working-directory: ${{ env.node_app_root }} | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
working-directory: ${{ env.rails_app_root }} | |
bundler-cache: true | |
- name: Lint code for consistent style | |
run: ./bin/rubocop -f github | |
working-directory: ${{ env.node_app_root }} | |
rspec: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
services: | |
mysql: | |
image: mysql:latest | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
ports: | |
- "3306:3306" | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
working-directory: ${{ env.rails_app_root }} | |
bundler-cache: true | |
- name: Create database | |
run: | | |
sleep 3 # Waiting to make sure MySQL is up and running | |
./bin/rails db:reset | |
working-directory: ${{ env.node_app_root }} | |
- name: Run RSpec | |
run: ./bin/rspec --format json --out tmp/rspec_results.json --format progress | |
working-directory: ${{ env.node_app_root }} | |
- name: Generate RSpec report | |
uses: SonicGarden/rspec-report-action@v5 | |
with: | |
json-path: ${{ env.rails_app_root }}/tmp/rspec_results.json | |
if: always() |