Skip to content

Commit

Permalink
Cache Bundler for rubocop and rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpasquini committed May 8, 2024
1 parent e281e32 commit c86b2d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
43 changes: 9 additions & 34 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,18 @@ jobs:
rubocop:
name: runner / rubocop
runs-on: ubuntu-latest
strategy:
matrix:
rails_version:
# - 6_1
- 7_0
# - 7_1
# - master
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_7_0.gemfile
steps:
- uses: actions/checkout@v4
- name: Read .ruby-version file
id: getrubyversion
run: echo "RUBY_VERSION=$(cat .ruby-version)" >> $GITHUB_OUTPUT
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ steps.getrubyversion.outputs.RUBY_VERSION }}
- run: ls -la
- name: Set up Rails ${{ matrix.rails_version }}
run: |
bundle config set --local gemfile "gemfiles/rails_${{ matrix.rails_version }}.gemfile"
bundle config set --local path 'vendor/bundle'
bundle install
bundler-cache: true
- name: Rubocop
run: "bundle exec rubocop"

test:
name: rails / rspec
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -47,29 +34,24 @@ jobs:
- 6_1
- 7_0
- 7_1
# - master
# Service containers to run with `container-job`
#- master
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails_version }}.gemfile
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:14
# Provide the password for postgres
image: postgres:14 # pg_dump tests currently depend on this version
env:
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: apartment_postgresql_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
mysql:
# Docker Hub image
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
Expand All @@ -80,24 +62,17 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 3306 on service container to the host
- 3306:3306
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
- name: Set up Rails ${{ matrix.rails_version }}
run: |
bundle config set --local gemfile "gemfiles/rails_${{ matrix.rails_version }}.gemfile"
bundle config set --local path 'vendor/bundle'
bundle install
bundler-cache: true
- name: Configure config database.yml
run: bundle exec rake db:copy_credentials
- name: Database Setup
run: bundle exec rake db:test:prepare
- name: Run tests
run: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/test-results/rspec/rspec.xml
# - store_test_results:
# path: ~/test-results/rspec/
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require:

AllCops:
Exclude:
- vendor/bundle/**/*
- gemfiles/**/*.gemfile
- gemfiles/vendor/**/*
- spec/dummy_engine/dummy_engine.gemspec
Expand Down

0 comments on commit c86b2d3

Please sign in to comment.