Skip to content

Commit

Permalink
[skip] Added running tests via GHA (1h)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobsy committed Dec 13, 2021
1 parent 671b1e5 commit a0c52dd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests
on: [push]

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["2.6", "2.7", "3.0"]
services:
postgres:
image: postgres:11
ports: ["5432:5432"]
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ${{ matrix.ruby-version }}

- name: Run the tests
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
run: bundle exec rake test

5 changes: 4 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
require "support/models/book"
require "support/models/haystack"

system "psql -c 'create database hayfork_test'"
connection_url = "'postgresql://#{ENV["POSTGRES_USER"]}:#{ENV["POSTGRES_PASSWORD"]}@localhost:5432'" if ENV["POSTGRES_PASSWORD"]
system "psql #{connection_url} -c 'create database hayfork_test'"

ActiveRecord::Base.establish_connection(
adapter: "postgresql",
host: "localhost",
database: "hayfork_test",
username: ENV["POSTGRES_USER"],
password: ENV["POSTGRES_PASSWORD"],
verbosity: "quiet")

load File.join(File.dirname(__FILE__), "support", "db", "schema.rb")
Expand Down

0 comments on commit a0c52dd

Please sign in to comment.