Skip to content

Instantly share code, notes, and snippets.

@beauraF
Last active April 26, 2022 21:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beauraF/141cd8a0252bc982494f82507de8d8be to your computer and use it in GitHub Desktop.
Save beauraF/141cd8a0252bc982494f82507de8d8be to your computer and use it in GitHub Desktop.
Simple CI workflow for Rails that run minitest and brakeman on Github Actions
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14.1
ports: ["5432:5432"]
env:
POSTGRES_USER: runner
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RAILS_ENV: test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.2
bundler-cache: true
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "lts/*"
cache: "yarn"
- name: Preparing database
run: bin/rails db:prepare
- name: Run tests
run: bin/rails test:all
- name: Run brakeman
run: bundle exec brakeman
@artyrcheek
Copy link

Thankyou!

@altherlex
Copy link

good one. I appreciate that!

I think you can delete "set up gems cache" and use ruby/setup-ruby@v1 instead with bundler-cache: true instead

      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.6.3
          bundler-cache: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment