Skip to content
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
pull_request:
push:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
env:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: password
PGDATABASE: scavinator_test

services:
postgres:
image: postgres:18
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: scavinator_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config postgresql-client

- name: Checkout code
uses: actions/checkout@v4

- name: Setup Databases
run: |
bash script/pg_ci_setup.sh
bash script/pg_parallel_test_setup.sh

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true

- name: Configuration
run: |
cp config/database.sample.yml config/database.yml
cp config/storage.sample.yml config/storage.yml

- name: Run tests
env:
RAILS_ENV: test
run: bin/rails test
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ secret_key_base: <automatically generated by rails>
discord_token: "DISCORD_TOKEN"
discord_client_id: "123456789"
discord_client_secret: "DISCORD_SECRET"

1 change: 1 addition & 0 deletions config/credentials/test.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b7f100a8d3f6bf8b2e1068744ce24802
1 change: 1 addition & 0 deletions config/credentials/test.yml.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dw79mBAUDu35Z8TAVCFYt+hL7igbNGW53LukZbYoGshNSDhfvkL6s2Let07UQIo0ZeNM7CQM7vkznwT5yDdid2bwh0Ifsvx2xKIDfEAvkrcrE9TkJHDEAlP5QH0jhOodS5MceFhxsCSZFs+NrJLp35IOfXNrQxENWojnu+2SG/F+O6LMWHT1SLQrlwZdnFpglTlgFIhfZ59IQroH5FaIBQ5EXnN5KLcHv0649O7bbcshRLWEQLAy0zavQEQfqcbIlFQVaJ7mlhlcjIo7O8zA/RNMRV3zVbJJa+uEQWzYR94gMUeuj4kytgj9YlHGmHAMV0KenbSaOVOTnWlihgXSBm93SZYArXzp3i76M3khvyFU6WebqiZetZLfJmvpdSg=--DVFlZgusfW7hWmha--hFuBNq+DTZ34xLTphjYdXw==
5 changes: 3 additions & 2 deletions config/database.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ development:
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: storage/test.sqlite3
adapter: postgresql
database: scavinator_test
password: password


# Store production database in the storage/ directory, which by default
Expand Down
1 change: 1 addition & 0 deletions script/pg_ci_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl https://raw.githubusercontent.com/Scavinator/scavinator-database/refs/heads/main/schema.sql | psql -d scavinator_test
9 changes: 9 additions & 0 deletions script/pg_parallel_test_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -x

FILE=$(mktemp)
for i in {0..32}; do
printf "%s\n" "CREATE DATABASE \"scavinator_test_$i\" WITH TEMPLATE scavinator_test;" >> $FILE
done
psql -f $FILE
Loading