From 228c8d99b76d46262afee203ac5ef0b753ceb424 Mon Sep 17 00:00:00 2001 From: Connor Sheremeta Date: Mon, 26 Oct 2020 14:06:51 -0600 Subject: [PATCH 1/3] Use github actions --- .github/workflows/push.yml | 63 ++++++++++++++++++++++++++++++++++ .travis.yml | 21 ------------ test/dummy/config/database.yml | 3 ++ 3 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/push.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..caa27db --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,63 @@ +name: CI +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:11 + ports: + - 5432:5432 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + host: localhost + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby 2.6 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6.6 + + - name: Install PostgreSQL client + run: | + sudo apt-get -yqq install libpq-dev + + - name: Cache Ruby gems + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Bundle gems + run: | + gem install bundler + bundle config path vendor/bundle + bundle config set without 'production development' + bundle install --jobs 4 --retry 3 + - name: Lint with RuboCop + run: bundle exec rubocop --parallel + + - name: Get yarn cache + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v1 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Run Tests + env: + RAILS_ENV: test + run: | + bundle exec rails db:create + bundle exec rails test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cbb80d3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: ruby -sudo: required -dist: xenial - -services: - - postgresql - -rvm: - - 2.5 - -cache: bundler -bundler_args: --without development production --jobs=3 --retry=3 -before_install: - - gem install bundler:2.0.2 - -before_script: - - RAILS_ENV=test bundle exec rails db:create - -script: - - bundle exec rails test - - bundle exec rubocop diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index 92d2ce2..9470edf 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -17,6 +17,9 @@ default: &default adapter: postgresql encoding: unicode + username: postgres + password: postgres + host: localhost # For details on connection pooling, see Rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> From 7dd6e0180e322fe935808652f97a860e95577c85 Mon Sep 17 00:00:00 2001 From: ConnorSheremeta Date: Thu, 5 Nov 2020 14:05:43 -0700 Subject: [PATCH 2/3] add build status to read me --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ea9b605..cfc37f6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + +[![Github Build Status](https://github.com/ualbertalib/oaisys/workflows/CI/badge.svg)](https://github.com/ualbertalib/oaisys/actions) + # Oaisys Short description and motivation. From 2064f3d395435e9b7bee32c159942aaf8bd25aba Mon Sep 17 00:00:00 2001 From: ConnorSheremeta Date: Fri, 6 Nov 2020 12:57:46 -0700 Subject: [PATCH 3/3] Address review comments --- .github/workflows/push.yml | 17 +++++------------ test/dummy/config/database.yml | 6 +++--- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index caa27db..ea72ee8 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -7,14 +7,11 @@ jobs: services: postgres: - image: postgres:11 + image: postgres:11-alpine ports: - 5432:5432 env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - host: localhost - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + POSTGRES_PASSWORD: mysecretpassword steps: - uses: actions/checkout@v2 @@ -24,12 +21,8 @@ jobs: with: ruby-version: 2.6.6 - - name: Install PostgreSQL client - run: | - sudo apt-get -yqq install libpq-dev - - name: Cache Ruby gems - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: vendor/bundle key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} @@ -37,7 +30,6 @@ jobs: ${{ runner.os }}-gem- - name: Bundle gems run: | - gem install bundler bundle config path vendor/bundle bundle config set without 'production development' bundle install --jobs 4 --retry 3 @@ -48,7 +40,7 @@ jobs: id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 + - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} @@ -58,6 +50,7 @@ jobs: - name: Run Tests env: RAILS_ENV: test + DB_PASSWORD: mysecretpassword run: | bundle exec rails db:create bundle exec rails test diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index 9470edf..695ab9a 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -17,9 +17,9 @@ default: &default adapter: postgresql encoding: unicode - username: postgres - password: postgres - host: localhost + username: <%= ENV['DB_USER'] || 'postgres' %> + password: <%= ENV['DB_PASSWORD'] || 'mysecretpassword' %> + host: <%= ENV['DB_HOST'] || 'localhost' %> # For details on connection pooling, see Rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>