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:
parent
e4fda2f89a
commit
be72ff9f93
1 changed files with 3 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue