Skip to content

Commit

Permalink
CI with GitHub actions (#719)
Browse files Browse the repository at this point in the history
* Github actions

* Add Postgres service

* Add postgres password

* Remove postgres user

* Add pg password in database.yml

* runner user for Github actions pg

* rails db:setup before tests

* Fix yml?

* Fix

* More test DB connection fixing

* Add redis service for Github Actions

* Map ports for Redis service

* Assets

* Fix

* Fix

* More fixing

* Argos

* Fix yml

* Fix Argos command hopefully

* Remove Heroku CI setup
isc authored Oct 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent c95acd8 commit cd30e56
Showing 5 changed files with 38 additions and 38 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test
on: [push]
jobs:
tests:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:latest
ports:
- 5432:5432
env:
POSTGRES_USER: runner
POSTGRES_PASSWORD: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- run: yarn install
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rails db:setup && bundle exec rake assets:precompile && bundle exec rake
- name: Upload screenshots to argos-ci.com
continue-on-error: true
run: yarn exec argos upload tmp/capybara
17 changes: 0 additions & 17 deletions app.json
Original file line number Diff line number Diff line change
@@ -5,22 +5,5 @@
"stack": "heroku-20",
"scripts": {
"postdeploy": "bundle exec rake db:schema:load"
},
"environments": {
"test": {
"addons": ["heroku-redis:in-dyno", "heroku-postgresql:in-dyno"],
"buildpacks": [
{ "url": "heroku/ruby" },
{ "url": "heroku/nodejs" },
{ "url": "heroku/google-chrome" }
],
"env": {
"DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL": true,
"REMOTE_REPORTER_URL": "http://test-failures.herokuapp.com/867a5de4a32757d08569575eaf78ab"
},
"scripts": {
"test": "./ci.sh"
}
}
}
}
12 changes: 0 additions & 12 deletions ci.sh

This file was deleted.

1 change: 1 addition & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ defaults: &defaults
min_messages: warning
host: localhost
username: <%= ENV['USER'] %>
password: postgres

development:
<<: *defaults
12 changes: 3 additions & 9 deletions test/test_database_schema.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
test_adapter = ENV['adapter'] || ENV['ADAPTER'] || 'postgres'
ActiveRecord::Base.connection.execute 'create database "adminium-fixture"' if ENV['CI']
conn_spec = ActiveRecord::Base.configurations.find_db_config("fixture-#{test_adapter}").configuration_hash
Rails.configuration.test_database_conn_spec =
if ENV['CI']
ActiveRecord::Base.connection.execute 'create database "adminium-fixture"'
conn_spec = ENV['DATABASE_URL'].split('/')
conn_spec[-1] = 'adminium-fixture'
conn_spec.join('/')
else
conn_spec = ActiveRecord::Base.configurations.find_db_config("fixture-#{test_adapter}").configuration_hash
"#{conn_spec[:adapter]}://#{conn_spec[:username]}@#{conn_spec[:host]}/#{conn_spec[:database]}"
end
"#{conn_spec[:adapter]}://#{conn_spec[:username]}:#{conn_spec[:password]}@#{conn_spec[:host]}/#{conn_spec[:database]}"

ActiveRecord::Base.establish_connection Rails.configuration.test_database_conn_spec
ActiveRecord::Schema.verbose = false

0 comments on commit cd30e56

Please sign in to comment.