Terralego/django-geostore

View on GitHub
.github/workflows/python-package.yml

Summary

Maintainability
Test Coverage
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  lint:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.8']

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        python -m pip install flake8

    - name: Lint with flake8
      run: |
        flake8 geostore test_geostore

  build:
    runs-on: ubuntu-20.04
    #TODO: Fix when github action do not show failed for the workflow with continue-on-error
    # continue-on-error: true
    needs: [lint]
    strategy:
      matrix:
        python-version: ['3.8', '3.10', '3.12']
        django-version: ['3.2.*', '4.2.*', '5.0.*']
        postgis-image: ['postgis/postgis:12-2.5']
        exclude:
          - python-version: '3.8'
            django-version: '5.0.*'

    services:
      postgres:
        image: ${{ matrix.postgis-image }}
        env:
          POSTGRES_PASSWORD: travis_ci_test
          POSTGRES_USER: travis_ci_test
          POSTGRES_DB: travis_ci_test
        ports:
          - 5432:5432
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        sudo apt-get -q update && sudo apt-get -yqq install libproj-dev binutils gdal-bin libgdal-dev
        python -m pip install --upgrade pip setuptools wheel
        pip install .[dev] -U
        if [[ ${{ matrix.django-version }} == dev ]]; then
          pip install -e git+https://github.com/django/django@main#egg=django;
        else
          pip install Django==${{ matrix.django-version }} -U;
        fi

    - name: Check missing migrations
      run: |
       ./manage.py makemigrations --check

    - name: Test with coverage
      run: |
        coverage run ./manage.py test
        coverage run -a ./manage.py test --settings=test_geostore.settings_with_customs geostore.tests.test_views.test_vector_tiles.VectorTilesTestCase.test_layer_tilejson_with_custom_hostnames
        coverage run -a ./manage.py test --settings=test_geostore.settings_with_customs geostore.tests.test_custom_classes
        coverage run -a ./manage.py test --settings=test_geostore.settings_with_customs geostore.tests.test_views.test_async_exports
        coverage xml -o coverage.xml

    - uses: codecov/codecov-action@v3
      with:
        files: ./coverage.xml
        fail_ci_if_error: true