From fdb26a325208e79a9d82bf5519d975d701e9b65e Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:12:23 -0500 Subject: [PATCH 01/15] Run CI on GHA --- .github/workflows/ci.yml | 39 ++++++++++++++++++++++++++++++++ script/pg_ci_setup.sh | 1 + script/pg_parallel_test_setup.sh | 10 ++++++++ 3 files changed, 50 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 script/pg_ci_setup.sh create mode 100644 script/pg_parallel_test_setup.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5315388 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + pull_request: + push: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:18 + env: + POSTGRES_PASSWORD: password + POSTGRES_DB: scavinator_test + volumes: + - ./script/pg_ci_setup.sh:/docker-entrypoint-initdb.d/01_schema.sh:ro + - ./script/pg_test_setup.sh:/docker-entrypoint-initdb.d/02_test_setup.sh:ro + ports: + - 5433: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 + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: .ruby-version + bundler-cache: true + + - name: Run tests + env: + RAILS_ENV: test + run: bin/rails test diff --git a/script/pg_ci_setup.sh b/script/pg_ci_setup.sh new file mode 100644 index 0000000..14d7da2 --- /dev/null +++ b/script/pg_ci_setup.sh @@ -0,0 +1 @@ +curl https://raw.githubusercontent.com/Scavinator/scavinator-database/refs/heads/main/schema.sql | psql -d scavinator_test diff --git a/script/pg_parallel_test_setup.sh b/script/pg_parallel_test_setup.sh new file mode 100644 index 0000000..2d8401e --- /dev/null +++ b/script/pg_parallel_test_setup.sh @@ -0,0 +1,10 @@ +#!/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 +cat $FILE +PGPASSWORD=password psql -f $FILE From b9ae368992bce33b75a7ea200e08202e3a5ed915 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:27:55 -0500 Subject: [PATCH 02/15] Run DB initialization as a part of the CI run --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5315388..591b533 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,18 +15,20 @@ jobs: env: POSTGRES_PASSWORD: password POSTGRES_DB: scavinator_test - volumes: - - ./script/pg_ci_setup.sh:/docker-entrypoint-initdb.d/01_schema.sh:ro - - ./script/pg_test_setup.sh:/docker-entrypoint-initdb.d/02_test_setup.sh:ro ports: - 5433: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 + 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_test_setup.sh + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From 094fc13a708f9ec2bbb7c4955546be94c7d37b83 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:29:49 -0500 Subject: [PATCH 03/15] Set PGHOST --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 591b533..d7f795e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,8 @@ on: jobs: test: runs-on: ubuntu-latest + env: + PGHOST: '127.0.0.1' services: postgres: From 4dacb6ea59134d09f89c5c171e8517c296b8b1aa Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:31:19 -0500 Subject: [PATCH 04/15] Try referring to db by hostname --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7f795e..d570254 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: test: runs-on: ubuntu-latest env: - PGHOST: '127.0.0.1' + PGHOST: postgres services: postgres: From f3ec2ef8b03aa91d1996d103ea17b2eb3a4a7527 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:35:56 -0500 Subject: [PATCH 05/15] Add healthcheck --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d570254..9eaa10f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,9 @@ jobs: runs-on: ubuntu-latest env: PGHOST: postgres + PGPORT: 5432 + PGUSER: postgres + PGDATABASE: scavinator_test services: postgres: @@ -17,8 +20,11 @@ jobs: env: POSTGRES_PASSWORD: password POSTGRES_DB: scavinator_test - ports: - - 5433:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 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 From ff14e59ee65fe483204c8537dd49fc604df82568 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:37:55 -0500 Subject: [PATCH 06/15] The host should be localhost --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eaa10f..b070597 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: test: runs-on: ubuntu-latest env: - PGHOST: postgres + PGHOST: localhost PGPORT: 5432 PGUSER: postgres PGDATABASE: scavinator_test From f61ebc968497d88a14d780f929cbc9be22ebbae6 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:42:23 -0500 Subject: [PATCH 07/15] Map port --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b070597..232354c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,21 +10,20 @@ jobs: runs-on: ubuntu-latest env: PGHOST: localhost - PGPORT: 5432 - PGUSER: postgres 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 From 34a9e481de3de280e22ab4441e28fa915f9d9adf Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:43:46 -0500 Subject: [PATCH 08/15] Add password back --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 232354c..47083d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,12 +10,14 @@ jobs: runs-on: ubuntu-latest env: PGHOST: localhost + PGUSER: postgres PGDATABASE: scavinator_test services: postgres: image: postgres:18 env: + POSTGRES_PASSWORD: password POSTGRES_DB: scavinator_test options: >- --health-cmd pg_isready From e1efbb7536e4b73901de2c342c9edb9036396d98 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:45:20 -0500 Subject: [PATCH 09/15] Add password --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47083d7..ee3703d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: env: PGHOST: localhost PGUSER: postgres + PGPASSWORD: password PGDATABASE: scavinator_test services: From 0cf57c3daf3403062df84d3fb6c1a16e03ab38ea Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:46:58 -0500 Subject: [PATCH 10/15] Fix script name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee3703d..8fa8d97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: - name: Setup Databases run: | bash script/pg_ci_setup.sh - bash script/pg_test_setup.sh + bash script/pg_parallel_test_setup.sh - name: Set up Ruby uses: ruby/setup-ruby@v1 From 853a5968ed9de03c345958097c33ec2e765c5569 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:50:09 -0500 Subject: [PATCH 11/15] Add sample configs --- .github/workflows/ci.yml | 5 +++++ config/database.sample.yml | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fa8d97..6d6bb84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,11 @@ jobs: 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 diff --git a/config/database.sample.yml b/config/database.sample.yml index 69b7811..665a723 100644 --- a/config/database.sample.yml +++ b/config/database.sample.yml @@ -20,7 +20,8 @@ development: # Do not set this db to the same as development or production. test: <<: *default - database: storage/test.sqlite3 + database: scavinator_test + password: password # Store production database in the storage/ directory, which by default From b0cd5b40db90d9fb890dc3520104fdfa1b58e54f Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 19:56:12 -0500 Subject: [PATCH 12/15] Try and use unencrypted credentials --- .github/workflows/ci.yml | 1 + config/{credentials.sample.yaml => credentials.sample.yml} | 0 2 files changed, 1 insertion(+) rename config/{credentials.sample.yaml => credentials.sample.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d6bb84..53bfab4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,7 @@ jobs: run: | cp config/database.sample.yml config/database.yml cp config/storage.sample.yml config/storage.yml + cp config/credentials.sample.yml config/credentials.yml - name: Run tests env: diff --git a/config/credentials.sample.yaml b/config/credentials.sample.yml similarity index 100% rename from config/credentials.sample.yaml rename to config/credentials.sample.yml From ab3484a524f5704f0e7679cb51c0eb6e0e6a8142 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 20:01:14 -0500 Subject: [PATCH 13/15] Add test credentials --- .github/workflows/ci.yml | 1 - config/credentials.sample.yml | 1 - config/credentials/test.key | 1 + config/credentials/test.yml.enc | 1 + 4 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 config/credentials/test.key create mode 100644 config/credentials/test.yml.enc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53bfab4..6d6bb84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,6 @@ jobs: run: | cp config/database.sample.yml config/database.yml cp config/storage.sample.yml config/storage.yml - cp config/credentials.sample.yml config/credentials.yml - name: Run tests env: diff --git a/config/credentials.sample.yml b/config/credentials.sample.yml index 58dcec0..73db627 100644 --- a/config/credentials.sample.yml +++ b/config/credentials.sample.yml @@ -4,4 +4,3 @@ secret_key_base: discord_token: "DISCORD_TOKEN" discord_client_id: "123456789" discord_client_secret: "DISCORD_SECRET" - diff --git a/config/credentials/test.key b/config/credentials/test.key new file mode 100644 index 0000000..5110281 --- /dev/null +++ b/config/credentials/test.key @@ -0,0 +1 @@ +b7f100a8d3f6bf8b2e1068744ce24802 \ No newline at end of file diff --git a/config/credentials/test.yml.enc b/config/credentials/test.yml.enc new file mode 100644 index 0000000..770f759 --- /dev/null +++ b/config/credentials/test.yml.enc @@ -0,0 +1 @@ +Dw79mBAUDu35Z8TAVCFYt+hL7igbNGW53LukZbYoGshNSDhfvkL6s2Let07UQIo0ZeNM7CQM7vkznwT5yDdid2bwh0Ifsvx2xKIDfEAvkrcrE9TkJHDEAlP5QH0jhOodS5MceFhxsCSZFs+NrJLp35IOfXNrQxENWojnu+2SG/F+O6LMWHT1SLQrlwZdnFpglTlgFIhfZ59IQroH5FaIBQ5EXnN5KLcHv0649O7bbcshRLWEQLAy0zavQEQfqcbIlFQVaJ7mlhlcjIo7O8zA/RNMRV3zVbJJa+uEQWzYR94gMUeuj4kytgj9YlHGmHAMV0KenbSaOVOTnWlihgXSBm93SZYArXzp3i76M3khvyFU6WebqiZetZLfJmvpdSg=--DVFlZgusfW7hWmha--hFuBNq+DTZ34xLTphjYdXw== \ No newline at end of file From 49fa839272f755f211e64f4aea8de28d0a0eb5c5 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 20:03:09 -0500 Subject: [PATCH 14/15] Don't use sqlite --- config/database.sample.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database.sample.yml b/config/database.sample.yml index 665a723..69a3a3e 100644 --- a/config/database.sample.yml +++ b/config/database.sample.yml @@ -19,7 +19,7 @@ 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 + adapter: postgresql database: scavinator_test password: password From b5f7ee8de9706849e0d3bc41de128b2b98b3f095 Mon Sep 17 00:00:00 2001 From: isaiahzs Date: Sat, 16 May 2026 20:07:50 -0500 Subject: [PATCH 15/15] Clean up test setup script --- script/pg_parallel_test_setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script/pg_parallel_test_setup.sh b/script/pg_parallel_test_setup.sh index 2d8401e..fb217d3 100644 --- a/script/pg_parallel_test_setup.sh +++ b/script/pg_parallel_test_setup.sh @@ -6,5 +6,4 @@ FILE=$(mktemp) for i in {0..32}; do printf "%s\n" "CREATE DATABASE \"scavinator_test_$i\" WITH TEMPLATE scavinator_test;" >> $FILE done -cat $FILE -PGPASSWORD=password psql -f $FILE +psql -f $FILE