Merge pull request #237 from nuest/main #218
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: Django CI Tests | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| permissions: | |
| pull-requests: write # allow posting comments on PRs by actions | |
| jobs: | |
| unittests: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| max-parallel: 4 | |
| matrix: | |
| python-version: [ | |
| 3.11, | |
| #3.13 | |
| ] | |
| services: | |
| db: | |
| image: postgis/postgis:17-3.5 | |
| env: | |
| POSTGRES_USER: optimap | |
| POSTGRES_PASSWORD: optimap | |
| POSTGRES_DB: optimap | |
| ports: | |
| - 5432:5432 | |
| options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install GDAL from UbuntuGIS | |
| run: | | |
| sudo apt-get update | |
| sudo add-apt-repository ppa:ubuntugis/ppa | |
| sudo apt-get install -y -qq gdal-bin libgdal-dev | |
| - name: Install Python Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install gdal=="$(gdal-config --version).*" | |
| python -m pip install -r requirements.txt | |
| python -m pip install -r requirements-dev.txt | |
| - name: Run Django migrations | |
| env: | |
| DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap | |
| run: | | |
| python manage.py migrate | |
| - name: Load all testdata to see if it is up to date with the Django migrations | |
| env: | |
| DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap | |
| run: | | |
| python manage.py loaddata fixtures/test_data_optimap.json | |
| python manage.py loaddata fixtures/test_data_partners.json | |
| - name: Run deploy checks | |
| env: | |
| DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap | |
| run: | | |
| python -Wa manage.py check --deploy | |
| - name: Run Tests | |
| env: | |
| DATABASE_URL: postgis://optimap:optimap@localhost:5432/optimap | |
| run: | | |
| coverage run --source='works' --omit='*/migrations/**' manage.py test tests | |
| - name: Check coverage and save it to files | |
| run: | | |
| coverage html | |
| coverage xml | |
| coverage report --show-missing --fail-under=50 | |
| #- name: Post code coverage | |
| # uses: orgoro/[email protected] | |
| # with: | |
| # coverageFile: coverage.xml | |
| # token: ${{ secrets.GITHUB_TOKEN }} | |
| uitests: | |
| # disable until UI tests are fixed, see https://github.com/GeoinformationSystems/optimap/issues/142 | |
| if: false | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| max-parallel: 4 | |
| matrix: | |
| python-version: [ | |
| 3.11, | |
| #3.13 | |
| ] | |
| services: | |
| db: | |
| image: postgis/postgis:17-3.5 | |
| env: | |
| POSTGRES_USER: optimap | |
| POSTGRES_PASSWORD: optimap | |
| POSTGRES_DB: optimap | |
| ports: | |
| - 5432:5432 | |
| options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # Based on https://github.com/MarketingPipeline/Python-Selenium-Action/blob/main/.github/workflows/Selenium-Action_Template.yaml and put python packages in requirements-dev.txt | |
| - name: Removing previous chrome instances on runner | |
| run: sudo apt purge google-chrome-stable | |
| - name: Install xvfb | |
| run: | | |
| sudo apt install -y xvfb firefox | |
| # See https://github.com/SeleniumHQ/selenium/issues/15327 | |
| - name: Install deps for chrome | |
| run: | | |
| sudo apt install libgtk-3-dev libnotify-dev libnss3 libxss1 libasound2t64 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install GDAL from UbuntuGIS | |
| run: | | |
| sudo apt-get update | |
| sudo add-apt-repository ppa:ubuntugis/ppa | |
| sudo apt-get install -y -qq gdal-bin libgdal-dev | |
| - name: Install Python Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install gdal=="$(gdal-config --version).*" | |
| python -m pip install -r requirements.txt | |
| python -m pip install -r requirements-dev.txt | |
| - name: Run Django migrations | |
| run: | | |
| python manage.py migrate | |
| - name: Run UI Tests | |
| run: | | |
| python -Wa manage.py runserver > server.log 2>&1 & python -Wa manage.py test tests-ui | |
| - name: Print Server Logs | |
| run: | | |
| cat server.log | |
| - name: Upload screenshots | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: screenshots for Python ${{ matrix.python-version }} | |
| path: | | |
| ${{ github.workspace }}/tests-ui/screenshots/ |