Set up GitHub Actions (#72)
* Add GitHub Actions config * Add extra dependencies and use environment variable for DB config Moved the env vars up to outside of the postgres service so this might not work * Pass environment variables for Postgres credentials to Postgres container * Pass service ports to application Have a suspicion that Redis one won't work as justask.yml is probably not using ERB * Add database.yml.postgres with port * Cache gems; pass Redis URL as env var * Add host to DB config * Pass DB credentials for db:setup * Use 127.0.0.1 instead of localhost to force TCP; Use bundler config without instead of --without * I can't read 🗑 * 🤔 * 💻🔨 I have no idea what I'm doing… * Testing env defined outside steps * Move templated vars down * Add build badge
This commit is contained in:
parent
516bc48aa0
commit
c292f51957
|
@ -0,0 +1,69 @@
|
|||
name: Retrospring
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10.12
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: justask_test
|
||||
ports:
|
||||
- 5432/tcp
|
||||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379:6379
|
||||
options: --entrypoint redis-server
|
||||
|
||||
env:
|
||||
RAILS_ENV: test
|
||||
POSTGRES_HOST: localhost
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: justask_test
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: vendor/bundle
|
||||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gems-
|
||||
- name: Set up Ruby 2.7
|
||||
uses: actions/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.7.x
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install -y libpq-dev libxml2-dev libxslt1-dev libmagickwand-dev imagemagick
|
||||
- name: Copy default configuration
|
||||
run: |
|
||||
cp config/database.yml.postgres config/database.yml
|
||||
cp config/justask.yml.example config/justask.yml
|
||||
- name: Install gems
|
||||
run: |
|
||||
gem install bundler
|
||||
bundle config path vendor/bundle
|
||||
bundle config set without 'production'
|
||||
bundle install --jobs 4 --retry 3
|
||||
- name: Set up database
|
||||
run: bundle exec rake db:setup
|
||||
env:
|
||||
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||
- name: Run tests
|
||||
run: bundle exec rake spec
|
||||
env:
|
||||
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||
REDIS_URL: "redis://localhost:${{ job.services.redis.ports[6379] }}"
|
|
@ -1,4 +1,5 @@
|
|||
# Retrospring
|
||||
![Retrospring](https://github.com/Retrospring/retrospring/workflows/Retrospring/badge.svg)
|
||||
|
||||
This is the source code that powers Retrospring. This is a detached fork of
|
||||
[nilsding/justask](https://github.com/nilsding/justask), where we continue
|
||||
|
|
|
@ -28,7 +28,9 @@ development:
|
|||
test: &test
|
||||
adapter: postgresql
|
||||
encoding: unicode
|
||||
database: justask_test
|
||||
database: <%= ENV['POSTGRES_DB'] %>
|
||||
host: <%= ENV.fetch('POSTGRES_HOST', 'localhost') %>
|
||||
pool: 5
|
||||
username: postgres
|
||||
password:
|
||||
username: <%= ENV['POSTGRES_USER'] %>
|
||||
password: <%= ENV['POSTGRES_PASSWORD'] %>
|
||||
port: <%= ENV.fetch('POSTGRES_PORT', 5432) %>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
redis_url = ENV.fetch("REDIS_URL") { APP_CONFIG["redis_url"] }
|
||||
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = { url: APP_CONFIG['redis_url'] }
|
||||
config.redis = { url: redis_url }
|
||||
end
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = { url: APP_CONFIG['redis_url'] }
|
||||
config.redis = { url: redis_url }
|
||||
end
|
Loading…
Reference in New Issue