Tests for Mergin DB Sync #134
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests for Mergin DB Sync | |
| on: | |
| push: | |
| paths: | |
| - "test/**" | |
| - "**.py" | |
| - "requirements.txt" | |
| - "requirements-dev.txt" | |
| - "pyproject.toml" | |
| - ".github/workflows/tests_mergin_db_sync.yaml" | |
| workflow_dispatch: | |
| inputs: | |
| geodiff_branch: | |
| description: "Geodiff branch to compile (default: master)" | |
| required: false | |
| default: "master" | |
| mergin_client_branch: | |
| description: "Mergin Python client branch from GitHub (leave empty to install from pip)" | |
| required: false | |
| default: "" | |
| env: | |
| TEST_GEODIFF_EXE: geodiff | |
| TEST_DB_CONNINFO: host=localhost dbname=test_db user=postgres password=postgres port=5432 | |
| TEST_MERGIN_URL: https://app.dev.merginmaps.com/ | |
| TEST_API_USERNAME: test_db_sync | |
| TEST_API_PASSWORD: ${{ secrets.TEST_API_PASSWORD }} | |
| TEST_API_WORKSPACE: test-db-sync | |
| jobs: | |
| Tests-for-Mergin-DB-Sync: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgis/postgis:latest | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: test_db | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - name: Install Geodiff | |
| run: | | |
| sudo apt-get install libsqlite3-dev libpq-dev | |
| git clone --branch ${{ inputs.geodiff_branch || 'master' }} https://github.com/MerginMaps/geodiff.git | |
| cd geodiff | |
| mkdir build && cd build | |
| cmake -DWITH_POSTGRESQL=TRUE ../geodiff | |
| sudo make install | |
| sudo cp geodiff /usr/local/bin | |
| - name: Check Geodiff version | |
| run: geodiff version | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install pygeodiff from source | |
| if: ${{ inputs.mergin_client_branch != '' }} | |
| run: | | |
| python3 -m pip install scikit-build cmake ninja | |
| cd geodiff | |
| python3 -m pip install . | |
| - name: Install Python dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| python3 -m pip install -r requirements.txt | |
| python3 -m pip install -r requirements-dev.txt | |
| - name: Install Mergin client from GitHub | |
| if: ${{ inputs.mergin_client_branch != '' }} | |
| run: | | |
| python3 -m pip install --no-deps git+https://github.com/MerginMaps/python-api-client.git@${{ inputs.mergin_client_branch }} | |
| - name: Run tests | |
| run: | | |
| pytest test --cov=. --cov-report=term-missing:skip-covered -vv | |
| - name: Check files using the black formatter | |
| uses: rickstaa/action-black@v1 | |
| id: action_black | |
| with: | |
| black_args: "." |