Merge remote-tracking branch 'upstream/aaron/stats-api' into deployme… #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake | |
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby | |
name: Ruby | |
on: | |
push: | |
branches: [ deployment-portage ] | |
pull_request: | |
branches: [ deployment-portage ] | |
jobs: | |
test: | |
runs-on: ubuntu-20.04 | |
services: | |
# Postgres installation | |
db: | |
image: postgres | |
env: | |
# Latest version of Postgres has increased security. We can use the default | |
# user/password in this testing scenario though so use the following env | |
# variable to bypass this changes: | |
# https://github.com/docker-library/postgres/issues/681 | |
POSTGRES_HOST_AUTH_METHOD: trust | |
ports: ['5432:5432'] | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
RAILS_ENV: test | |
DATABASE_URL: postgres://postgres:@localhost:5432/roadmap_test | |
steps: | |
# Checkout the repo | |
- uses: actions/checkout@v3 | |
# Install Ruby and run bundler | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.1.4' | |
bundler-cache: true | |
# Install Node | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.6.0' | |
cache: 'yarn' | |
# Install the Postgres developer packages | |
- name: 'Install Postgresql Packages' | |
run: | | |
sudo apt-get update | |
sudo apt-get install libpq-dev | |
# Copy all of the example configs over | |
- name: 'Setup Default Configuration' | |
run: | | |
# Make copies of all the example config files | |
cp config/database.yml.sample config/database.yml | |
cp config/initializers/contact_us.rb.example config/initializers/contact_us.rb | |
cp config/initializers/wicked_pdf.rb.example config/initializers/wicked_pdf.rb | |
- name: 'Setup Credentials' | |
run: | | |
# generate a default credential file and key | |
EDITOR='echo "$(cat config/credentials.yml.mysql2)" >' bundle exec rails credentials:edit | |
- name: 'Determine wkhtmltopdf location' | |
run: echo "WICKED_PDF_PATH=`bundle exec which wkhtmltopdf`" >> $GITHUB_ENV | |
- name: 'Yarn Install' | |
run: | | |
yarn install | |
- name: 'Setup Test DB' | |
run: bin/rails db:setup RAILS_ENV=test | |
- name: 'Migrate DB' | |
run: bin/rails db:migrate RAILS_ENV=test | |
- name: 'Compile Assets' | |
run: | | |
bin/rails assets:precompile | |
- name: Run tests | |
run: bundle exec rake spec |