diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1fa26cc6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: Ruby CI + +on: + push: + branches: + - main + paths-ignore: + - 'docs/**' + - '*.md' + - 'bin/*' + pull_request: + branches: + - main + paths-ignore: + - 'docs/**' + - '*.md' + - 'bin/*' + +jobs: + rspec: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v1 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Bundle install + run: | + bundle install --jobs 4 --retry 3 + + - name: Setup CI database.yml + run: cp config/database.github-actions.yml config/database.yml + + - name: Setup DB, Run tests + env: + RAILS_ENV: test + run: | + bundle exec rails db:create db:schema:load + bundle exec rspec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d6eb4bdf..00000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: ruby -cache: bundler -rvm: - - '2.7.1' -services: - - postgresql -script: - - bundle exec standardrb - - RAILS_ENV=test bundle exec rake db:drop - - RAILS_ENV=test bundle exec rake db:create - - RAILS_ENV=test bundle exec rake db:migrate - - bundle exec brakeman -zq --ensure-latest - - bundle exec rake spec -addons: - chrome: stable -before_script: - - cp config/database.travis.yml config/database.yml - - psql -c 'create database doubleunion_test;' -U postgres -env: SECRET_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c56a1da8..596405c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,18 +6,19 @@ Anyone is welcome to make an issue or a pull request. We would *love* for first- Most contributors are DU members who collaborate in an internal Slack channel, but we also welcome non-member contributors! To support that, we have a public mailing list. Feel free to ask any question, including basic git and Ruby questions etc :) https://groups.google.com/a/doubleunion.org/forum/#!forum/public-du-code -- [Development setup](#development-setup) - - [Steps to get set up to develop and run tests](#steps-to-get-set-up-to-develop-and-run-tests) - - [Steps to run arooo server locally](#steps-to-run-arooo-server-locally) - - [Docker setup (optional)](#docker-setup-optional) - - [Set up an application for local OAuth:](#set-up-an-application-for-local-oauth) - - [Common errors and gotchas](#common-errors-and-gotchas) - - [Linting](#linting) -- [Tests](#tests) -- [User states](#user-states) - - [Manually changing a user's state](#manually-changing-a-users-state) -- [Programmatic doorbell](#programmatic-doorbell) - - [Manual doorbell testing](#manual-doorbell-testing) +- [Contributing Guide](#contributing-guide) + - [Development setup](#development-setup) + - [Steps to get set up to develop and run tests](#steps-to-get-set-up-to-develop-and-run-tests) + - [Steps to run arooo server locally](#steps-to-run-arooo-server-locally) + - [Docker setup (optional)](#docker-setup-optional) + - [Set up an application for local OAuth:](#set-up-an-application-for-local-oauth) + - [Common errors and gotchas](#common-errors-and-gotchas) + - [Linting](#linting) + - [Tests](#tests) + - [User states](#user-states) + - [Manually changing a user's state](#manually-changing-a-users-state) + - [Programmatic doorbell](#programmatic-doorbell) + - [Manual doorbell testing](#manual-doorbell-testing) ## Development setup @@ -60,9 +61,9 @@ $ cp config/application.example.yml config/application.yml $ bundle exec rake db:test:prepare ``` -If this step fails on Ubuntu, make sure that your postgres db is up and running -and that you only have one postgres instance up: try `sudo lsof -i:5432`. -You may need to use sudo to set your `/etc/postgresql/11/main/pg_hba.conf` file. +If this step fails on Ubuntu, make sure that your postgres db is up and running +and that you only have one postgres instance up: try `sudo lsof -i:5432`. +You may need to use sudo to set your `/etc/postgresql/11/main/pg_hba.conf` file. IPv4 local connections should say `localhost` under ADDRESS and `trust` under METHOD. 9. Now you should be able to run tests locally, and they should all pass: ``` @@ -132,7 +133,7 @@ Tests, also known as specs, are great! Adding tests is a great pull request all Run `rake db:test:prepare` after you pull or make any changes to the app, so make sure that your test database has the correct database schema -Make sure `bundle exec rake spec` passes before pushing your changes. (Our TravisCI integration will double-check before we merge code, so it's ok if you forget sometimes) :) +Make sure `bundle exec rake spec` passes before pushing your changes. ## User states @@ -187,4 +188,4 @@ For exceptional cases (e.g. package delivery) that don't fit the "one door code You can test the doorbell endpoints directly from a browser or using CURL. You can pass parameters to each endpoint direclty as query params. For example, to manually test the SMS endpoint: ``` http://localhost:3000/doorbell/sms?Body=123456 -``` \ No newline at end of file +``` diff --git a/README.md b/README.md index c7d0d28d..bd62fe37 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # Arooo - A Room Of One's Own -[![Build Status](https://travis-ci.org/doubleunion/arooo.svg)](https://travis-ci.org/doubleunion/arooo) [![Open Source Helpers](https://www.codetriage.com/doubleunion/arooo/badges/users.svg)](https://www.codetriage.com/doubleunion/arooo) - [Welcome :rocket::rocket::rocket:✨✨](#welcome-rocketrocketrocket) @@ -70,7 +69,7 @@ This section only pertains if you have heroku & deployment access. Only maintain If you are a DU member, see https://docs.google.com/document/d/19LbIYB2RDy-17UXuQx6wLgKp2EdLdqj-pg1cm3EpSb8/edit for more information on getting permission. Both `staging` and `production` Heroku environments are connected to this GitHub repo, making it possible to deploy directly through the Heroku UI. To deploy: -* Staging: Merge to `master`, and your code will be automatically deployed to `staging` as soon as Travis CI goes green. +* Staging: Merge to `master`, and your code will be automatically deployed to `staging` as soon as CI goes green. * Production: Log into Heroku, and select the production Aroo app from your dashboard. Click on "Deploy", and scroll to the bottom. There will be a place to select a branch to deploy, and a button that you can click to deploy. Database migrations will run automatically during the release process on Heroku. This is controlled by the `release` directive in our [Procfile](Procfile). @@ -95,7 +94,7 @@ If you prefer to do deploys from the command line, here are the steps: git pull --rebase origin master ``` -1. If Travis CI tests are passing, push to the `staging` environment +1. If CI tests are passing, push to the `staging` environment ``` git checkout master diff --git a/config/database.travis.yml b/config/database.github-actions.yml similarity index 64% rename from config/database.travis.yml rename to config/database.github-actions.yml index b773b61a..c9696d2d 100644 --- a/config/database.travis.yml +++ b/config/database.github-actions.yml @@ -1,4 +1,6 @@ test: adapter: postgresql database: doubleunion_test + host: localhost username: postgres + password: postgres