Skip to content

Commit

Permalink
Improve postgres makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Jul 24, 2024
1 parent 86813bc commit 1bca936
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ on:
branches: [ "master" ]
paths:
- '**.sql'
- 'Makefile'
pull_request:
branches: [ "master" ]
paths:
- '**.sql'
- 'Makefile'
workflow_dispatch:
jobs:
sql:
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ lint:
@go generate ./... && git status --porcelain=v2 | { ! { grep _gen.go > /dev/null && echo "Generated files were not up to date."; } } && echo "Generated files are up to date"

test-postgres:
@docker run --name test-nextmn-srv6 -e POSTGRES_PASSWORD=postgres -v ./internal/database/database.sql:/docker-entrypoint-initdb.d/database.sql:ro postgres 2>/dev/stdout| grep -m 1 'PostgreSQL init process complete' || { echo "Could not initialize postgres" ; $(MAKE) stop-postgres ; exit 1 ; } && $(MAKE) stop-postgres
@docker pull postgres # avoid doing this under timeout
@chmod o+r ./internal/database/database.sql # mandatory to allow postgres’s docker container to process the file
@timeout 15 docker run --name test-nextmn-srv6 -e POSTGRES_PASSWORD=postgres -v ./internal/database/database.sql:/docker-entrypoint-initdb.d/database.sql:ro postgres 2>/dev/stdout| grep -m 1 'PostgreSQL init process complete' || { echo "Could not initialize postgres" ; $(MAKE) stop-postgres ; exit 1 ; } && $(MAKE) stop-postgres
stop-postgres:
@echo "Shutting down postgres"
@docker stop test-nextmn-srv6 >/dev/null
@docker rm test-nextmn-srv6 >/dev/null
@docker rm --force=true --volumes=true test-nextmn-srv6 >/dev/null

0 comments on commit 1bca936

Please sign in to comment.