ci: set DATABASE_URL globally for test job

- Move MIX_ENV and DATABASE_URL to job-level env vars
- Removes need to set them on individual steps
- Ensures all database operations use correct hostname (postgres)
- Fixes 'connection refused' errors from hardcoded localhost in test.exs
This commit is contained in:
Graham McIntire 2026-03-05 10:32:03 -06:00
parent e4fda2f89a
commit be72ff9f93
No known key found for this signature in database

View file

@ -16,6 +16,9 @@ concurrency:
jobs:
test:
runs-on: ubuntu-22.04
env:
MIX_ENV: test
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/towerops_test
services:
postgres:
image: timescale/timescaledb:latest-pg17
@ -84,26 +87,18 @@ jobs:
- name: Setup database
run: mix ecto.create
env:
MIX_ENV: test
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/towerops_test
- name: Check code formatting
run: mix format --check-formatted
- name: Compile with warnings as errors
run: mix compile --warnings-as-errors
env:
MIX_ENV: test
- name: Run Credo
run: mix credo --strict
- name: Run tests
run: mix test --warnings-as-errors
env:
MIX_ENV: test
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/towerops_test
build:
runs-on: ubuntu-22.04