Skip to content

Commit

Permalink
Merge pull request #298 from openstax/dotenv
Browse files Browse the repository at this point in the history
New backend deployment
  • Loading branch information
nathanstitt authored Jan 21, 2021
2 parents c701a8a + e1504a5 commit d1fe1c6
Show file tree
Hide file tree
Showing 45 changed files with 701 additions and 740 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Migrations

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

jobs:
migrations:
timeout-minutes: 30
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:11
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
redis:
image: redis
ports:
- 6379:6379
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
# Clone repo and checkout merge commit parent (PR target commit)
- uses: actions/checkout@v2
with:
fetch-depth: 2

- run: git checkout HEAD^

# Install ruby
- uses: actions/setup-ruby@v1
with:
ruby-version: 2.6

# Retrieve gem cache for merge commit parent
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-parent-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-parent-
# Install gems, create data to be migrated and revert to PR merge commit
- name: Create data to be migrated
env:
OXE_DB_USER: postgres
OXE_DB_PASS: postgres
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bundle exec rake db:create db:schema:load db:seed --trace
bundle exec rails runner '10.times { FactoryBot.create :exercise }'
git checkout -
# Retrieve gem cache for PR merge commit
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-pr-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-pr-
# Migrate the data
- name: Migrate
env:
OXE_DB_USER: postgres
OXE_DB_PASS: postgres
run: |
bundle install --jobs 4 --retry 3
bundle exec rake db:migrate
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests

on:
pull_request:
push:
branches:
- main
schedule:
- cron: '0 0 * * 0' # weekly

jobs:
tests:
timeout-minutes: 30
runs-on: ubuntu-18.04
services:
postgres:
image: postgres:11
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_DB: ci_test
POSTGRES_PASSWORD: postgres
strategy:
matrix:
tests:
- name: 'assets'
args: 'ASSETS=true'
- name: 'tests'
args: 'ASSETS=false'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: 2.6
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-pr-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-pr-
- name: Test
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
OXT_DB_USER: postgres
OXT_TEST_DB: ci_test
OXT_DB_PASS: postgres
RAILS_ENV: test
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
${{ matrix.tests.args }} ./bin/ci
105 changes: 71 additions & 34 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,57 +1,94 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
*.rbc
capybara-*.html
.rspec
/db/*.sqlite3
/db/*.sqlite3-journal
/db/*.sqlite3-[0-9]*
/public/system
/coverage/
/spec/tmp
*.orig
rerun.txt
pickle-email-*.html

# Ignore bundler config
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
config/initializers/secret_token.rb
config/master.key

# Only include if you have production secrets in this file, which is no longer a Rails default
# config/secrets.yml

# dotenv, dotenv-rails
# TODO Comment out these rules if environment variables can be committed
.env
.env.*

## Environment normalization:
/.bundle
/vendor/bundle

# Ignore installed gems
vendor
# these should all be checked in to normalize the environment:
# Gemfile.lock, .ruby-version, .ruby-gemset

# Ignore the default SQLite database and yaml_db database files
/db/*.sqlite3*
/db/data.yml*
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp/**/*
# if using bower-rails ignore default bower_components path bower.json files
/vendor/assets/bower_components
*.bowerrc
bower.json

# Ignore pow environment settings
.powenv

# Ignore Byebug command history file.
.byebug_history

# Ignore node_modules
node_modules/

# Ignore files containing keys and passwords
config/*settings.yml
# Ignore precompiled javascript packs
/public/packs
/public/packs-test
/public/assets

# Ignore compiled assets and uploaded files
public/assets/**/*
public/attachments/**/*
# Ignore yarn files
/yarn-error.log
yarn-debug.log*
.yarn-integrity

# Ignore vagrant and berkshelf files
.vagrant*
.vagrant_setup.json
Berksfile.lock
# Ignore uploaded files in development
/storage/*
!/storage/.keep
/public/uploads

# Ignore attached files in development
/public/attachments

# Ignore Cucumber and RSpec failure information
cucumber_rerun.txt
rspec.failures

# Ignore brakeman reports
brakeman.html
# Ignore webdrivers lock file
.webdrivers_update

# Ignore coverage reports
coverage/*

# Ignore ERD diagrams
erd*.pdf

# Ignore misc files
notes
# Ignore brakeman reports
brakeman.html

# Ignore gedit and OSX temp files
# Ignore editor temp files
*~
*.DS_Store

# Ignore dotenv env variable definitions
.env

# Ignore byebug history
.byebug_history
# Ignore OS X's Desktop Service Store files
*.DS_Store
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

31 changes: 15 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ gem 'sanitize'
# Utilities for OpenStax websites
gem 'openstax_utilities'

# Cron job scheduling
gem 'whenever'

# Talks to Accounts (latest version is broken)
gem 'omniauth-oauth2'

Expand Down Expand Up @@ -114,14 +111,18 @@ gem 'scout_apm', '~> 3.0.pre28'
# PostgreSQL database
gem 'pg'

# Support systemd Type=notify services for puma
gem 'sd_notify', require: false

# Use the puma webserver
gem 'puma'

# Prevent server memory from growing until OOM
gem 'puma_worker_killer'

# HTTP requests
gem 'httparty'

gem 'a15k_client',
git: 'https://github.com/a15k/mothership.git',
glob: 'clients/1.0.0/ruby/*gemspec',
branch: 'master'

# Notify developers of Exceptions in production
gem 'openstax_rescue_from'

Expand Down Expand Up @@ -151,10 +152,10 @@ gem 'bootsnap', '~> 1.4.0', require: false
# Bulk inserts and upserts
gem 'activerecord-import'

group :development, :test do
# Get env variables from .env file
gem 'dotenv-rails'
# Get env variables from .env file
gem 'dotenv-rails'

group :development, :test do
# Run specs in parallel
gem 'parallel_tests'

Expand Down Expand Up @@ -221,11 +222,9 @@ group :test do
end

group :production do
# Unicorn production server
gem 'unicorn'

# Unicorn worker killer
gem 'unicorn-worker-killer'
# Used to fetch secrets from the AWS parameter store and secrets manager
gem 'aws-sdk-ssm', require: false
gem 'aws-sdk-secretsmanager', require: false

# AWS SES
gem 'aws-ses', '~> 0.6.0', require: 'aws/ses'
Expand Down
Loading

0 comments on commit d1fe1c6

Please sign in to comment.