Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
ci: add docker compose testing with db, plus ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Mar 26, 2024
1 parent 9b6de78 commit f2a7225
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: 🧪 PyTest

on:
# Run tests on all pushed branches
push:
branches: [main]
# Run tests on PR, prior to merge to main & development
Expand All @@ -12,7 +11,11 @@ on:

jobs:
pytest:
uses: hotosm/gh-workflows/.github/workflows/test_pytest[email protected].0
uses: hotosm/gh-workflows/.github/workflows/test_compose[email protected].5
with:
image_name: ghcr.io/${{ github.repository }}
tag_override: ${{ github.event_name == 'push' && 'ci' || '' }}
tag_override: ci
compose_service: tm-admin
compose_command: pytest
cache_extra_imgs: |
"docker.io/postgis/postgis:14-3.4-alpine"
60 changes: 60 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) 2022, 2023 Humanitarian OpenStreetMap Team
# This file is part of tm-admin.
#
# tm-admin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# tm-admin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with tm-admin. If not, see <https:#www.gnu.org/licenses/>.
#

version: "3"

networks:
net:
name: tm-admin

services:
tm-admin:
image: "ghcr.io/hotosm/tm-admin:${TAG_OVERRIDE:-ci}"
build:
target: ci
container_name: tm-admin
volumes:
# Mount local package
- ./tm_admin:/usr/local/lib/python3.10/site-packages/tm_admin
# Mount local tests
- ./tests:/data/tests
depends_on:
db:
condition: service_healthy
networks:
- net
restart: "unless-stopped"
command: "pytest"

db:
image: "postgis/postgis:14-3.4-alpine"
container_name: tm-admin-db
environment:
- POSTGRES_USER=tm
- POSTGRES_PASSWORD=dummycipassword
- POSTGRES_DB=tmadmin
ports:
- "5439:5432"
networks:
- net
restart: "unless-stopped"
healthcheck:
test: pg_isready -U ${TM_DB_USER:-tm} -d ${TM_DB_NAME:-tmadmin}
start_period: 5s
interval: 10s
timeout: 5s
retries: 3

0 comments on commit f2a7225

Please sign in to comment.