diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 56126d1f..3f8755f2 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -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 @@ -12,7 +11,11 @@ on: jobs: pytest: - uses: hotosm/gh-workflows/.github/workflows/test_pytest.yml@1.4.0 + uses: hotosm/gh-workflows/.github/workflows/test_compose.yml@1.4.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" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f6e3e82c --- /dev/null +++ b/docker-compose.yml @@ -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 . +# + +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