Skip to content

Commit

Permalink
Merge pull request #40 from rubyforgood/update-workflow
Browse files Browse the repository at this point in the history
Update workflow
  • Loading branch information
cflipse authored Aug 1, 2023
2 parents 5d6e9e9 + fa9c50d commit 47945af
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#
# This workflow will install a prebuilt Ruby version, install dependencies, and
# run tests and linters.
---
name: "Ruby on Rails CI"

on:
push:
branches: [ 'main' ]
branches: ['main']
pull_request:
types: ['opened', 'reopened', 'synchronize', 'unlocked']

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -22,21 +25,25 @@ jobs:
POSTGRES_DB: sif
POSTGRES_USER: sif
POSTGRES_PASSWORD: password
redis:
image: redis:7.0

env:
RAILS_ENV: test
DATABASE_URL: "postgres://sif:password@localhost:5432/sif"
REDIS_URL: "redis://localhost:6379/1"
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Ruby and gems
uses: ruby/[email protected]
uses: ruby/[email protected]
with:
ruby-version: '3.2.2'
bundler-cache: true
ruby-version: '3.2.2'
bundler-cache: true

- name: Set up database schema
run: bin/rails db:schema:load

- name: Run tests
run: bin/rake
13 changes: 7 additions & 6 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Ensure Docker container for Ruby can build successfully
---
name: Ensure Docker container for Ruby can build successfully

on:
push:
branches: [ 'main' ]
branches: ['main']
pull_request:
types: ['opened', 'reopened', 'synchronize', 'unlocked']

Expand All @@ -18,13 +19,13 @@ jobs:
working-directory: ./
run: |
docker compose build
- name: Run containers
- name: Run containers
working-directory: ./
run: |
docker compose up --wait
- name: Curl web page
- name: Curl web page
working-directory: ./
run: |
curl -X GET http://localhost:3000
8 changes: 5 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
name: "Lint"

on:
push:
branches: [ 'main' ]
branches: ['main']
pull_request:
types: ['opened', 'reopened', 'synchronize', 'unlocked']

Expand All @@ -10,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/[email protected]
- uses: ruby/[email protected]
with:
ruby-version: '3.2.2'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Lint Ruby files
run: bundle exec standardrb
run: bundle exec standardrb
11 changes: 6 additions & 5 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
name: "Security"

on:
push:
branches: [ 'main' ]
branches: ['main']
pull_request:
types: ['opened', 'reopened', 'synchronize', 'unlocked']

Expand All @@ -10,14 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/[email protected]
- uses: ruby/[email protected]
with:
ruby-version: '3.2.2'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Security audit dependencies
run: bundle exec bundler-audit check --update
run: bundle exec bundler-audit check --update

- name: Security audit application code
run: bundle exec brakeman -q -w2

3 changes: 2 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
# config.cache_store = :memory_store
config.cache_store = :redis_cache_store, {URL: ENV.fetch("REDIS_URL", "redis://localhost:6397/1")}
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
Expand Down
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
config.cache_store = :redis_cache_store, {URL: ENV.fetch("REDIS_URL", "redis://localhost:6397/1")}

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
Expand Down

0 comments on commit 47945af

Please sign in to comment.