|
| 1 | +# This workflow uses actions that are not certified by GitHub. They are |
| 2 | +# provided by a third-party and are governed by separate terms of service, |
| 3 | +# privacy policy, and support documentation. |
| 4 | +# |
| 5 | +# This workflow will install a prebuilt Ruby version, install dependencies, and |
| 6 | +# run tests and linters. |
| 7 | +name: "Ruby on Rails CI" |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [ "master" ] |
| 11 | + pull_request: |
| 12 | + branches: [ "master" ] |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + services: |
| 17 | + postgres: |
| 18 | + image: postgres:11-alpine |
| 19 | + ports: |
| 20 | + - "5432:5432" |
| 21 | + env: |
| 22 | + POSTGRES_DB: rails_test |
| 23 | + POSTGRES_USER: rails |
| 24 | + POSTGRES_PASSWORD: password |
| 25 | + env: |
| 26 | + RAILS_ENV: test |
| 27 | + DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v3 |
| 31 | + # Add or replace dependency steps here |
| 32 | + - name: Install Ruby and gems |
| 33 | + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 |
| 34 | + with: |
| 35 | + bundler-cache: true |
| 36 | + # Add or replace database setup steps here |
| 37 | + - name: Set up database schema |
| 38 | + run: bin/rails db:schema:load |
| 39 | + # Add or replace test runners here |
| 40 | + - name: Run tests |
| 41 | + run: bin/rake |
| 42 | + |
| 43 | + lint: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v3 |
| 48 | + - name: Install Ruby and gems |
| 49 | + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 |
| 50 | + with: |
| 51 | + bundler-cache: true |
| 52 | + # Add or replace any other lints here |
| 53 | + - name: Security audit dependencies |
| 54 | + run: bin/bundler-audit --update |
| 55 | + - name: Security audit application code |
| 56 | + run: bin/brakeman -q -w2 |
| 57 | + - name: Lint Ruby files |
| 58 | + run: bin/rubocop --parallel |
0 commit comments