Skip to content

Commit

Permalink
Add test action
Browse files Browse the repository at this point in the history
  • Loading branch information
renatolond committed Sep 20, 2024
1 parent 0526ece commit 17ad636
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.github.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PGSQL_USERNAME=postgres
PGSQL_PASSWORD_USERNAME=postgres
PGSQL_PASSWORD=postgres
46 changes: 46 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:

jobs:
test:

runs-on: ubuntu-latest

# Service containers to run with `runner-job`
services:
postgres:
image: postgres:16
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: retromeet_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Copy github env file
run: cp .env.github.test .env.test.local
- name: Create needed extension
run: psql -U postgres -c "CREATE EXTENSION citext" retromeet_test
- name: Setup the database
run: APP_ENV=test bundle exec rake db:setup
- name: Run tests
run: bundle exec rake test

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
.env.*
!.env.development
!.env.test
!.env.github.test
!.env.template

# Ignore Byebug command history file.
.byebug_history
Expand Down

0 comments on commit 17ad636

Please sign in to comment.