-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (69 loc) · 2.11 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: test
# Controls when the workflow will run:
on:
# Triggers the workflow on push to master branch, or on pull request
# to any branch:
push:
branches:
- master
pull_request:
jobs:
# label of the job:
tests:
name: Tests
# containers must run in Linux based operating systems:
runs-on: ubuntu-latest
# Do not ignore bash profile files. From:
# https://github.com/marketplace/actions/setup-miniconda
# This is needed to run conda. It prevents the error:
# CommandNotFoundError: Your shell has not been properly configured
# to use 'conda activate'.
defaults:
run:
shell: bash -l {0}
services:
# label used to access the service container:
postgres:
# Docker Hub image
image: postgres:14.7
# service environment variables:
# `POSTGRES_HOST` is localhost
env:
# required
POSTGRES_PASSWORD: postgres_password
# optional (defaults to `postgres`):
POSTGRES_USER: test_user
ports:
# maps tcp port 5432 on service container to the host:
- 5432:5432
volumes:
- /var/run/postgresql:/var/run/postgresql
# set health checks to wait until postgres has started:
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --yes freetds-dev
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Set up test database
env:
PGPASSWORD: postgres_password
run: |
echo "createdb -h localhost -p 5432 -U test_user polbase_test" | tee base
- name: Run tests
env:
RAILS_ENV: test
run: |
cp .env.example .env
cp config/database.yml.example config/database.yml
RAILS_ENV=test bin/rails db:reset && bin/rails test