From d8cba2e3e23387d3c5ff6eb89c06a315a21093ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Wed, 16 Oct 2024 19:07:27 +0200 Subject: [PATCH] feat(workflows): add reusable pytest actions --- .github/workflows/gn-module-pytest.yml | 126 +++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 .github/workflows/gn-module-pytest.yml diff --git a/.github/workflows/gn-module-pytest.yml b/.github/workflows/gn-module-pytest.yml new file mode 100644 index 0000000000..bc07d57e36 --- /dev/null +++ b/.github/workflows/gn-module-pytest.yml @@ -0,0 +1,126 @@ +name: Run pytest against GeoNature module + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + debian-version: ['11', '12'] + include: + - debian-version: '11' + python-version: '3.9' + postgres-version: '13' + postgis-version: '3.2' + - debian-version: '12' + python-version: '3.11' + postgres-version: '15' + postgis-version: '3.3' + + name: Debian ${{ matrix.debian-version }} + + services: + postgres: + image: postgis/postgis:${{ matrix.postgres-version }}-${{ matrix.postgis-version }} + env: + POSTGRES_DB: geonature2db + POSTGRES_PASSWORD: geonatpasswd + POSTGRES_USER: geonatadmin + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Clone GeoNature + uses: actions/checkout@v4 + with: + repository: ${{ github.action_repository }} + ref: ${{ github.action_ref }} + submodules: true + - uses: actions/checkout@v4 + with: + path: extra + - name: Add database extensions + run: | + psql -h localhost -U geonatadmin -d geonature2db -f install/assets/db/add_pg_extensions.sql + env: + PGPASSWORD: geonatpasswd + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Install GDAL + run: | + sudo apt update + sudo apt install -y libgdal-dev + - name: Install dependencies + if: github.action_ref == 'master' + run: | + echo 'Installation des requirements de prod' + python -m pip install --upgrade pip + python -m pip install \ + -e ..[tests] \ + -r requirements.txt + working-directory: ./backend + - name: Install dependencies + if: github.action_ref != 'master' + run: | + echo 'Installation des requirements de dev' + python -m pip install --upgrade pip + python -m pip install \ + -e ..[tests] \ + -r requirements-dev.txt + working-directory: ./backend + - name: Show database branches and dependencies + run: | + geonature db status --dependencies + env: + GEONATURE_CONFIG_FILE: config/test_config.toml + - name: Install database + run: | + install/03b_populate_db.sh + env: + GEONATURE_CONFIG_FILE: config/test_config.toml + srid_local: 2154 + install_bdc_statuts: true + taxref_region: fr + add_sample_data: true + install_sig_layers: true + install_grid_layer_5: true + install_grid_layer_10: true + install_ref_sensitivity: true + - name: Show database status + run: | + geonature db status + env: + GEONATURE_CONFIG_FILE: config/test_config.toml + - name: Install core modules backend + run: | + pip install -e contrib/occtax + pip install -e contrib/gn_module_occhab + pip install -e contrib/gn_module_validation + - name: Install module backend + run: | + pip install -e extra + - name: Install modules database + run: | + geonature upgrade-modules-db + env: + GEONATURE_CONFIG_FILE: config/test_config.toml + - name: Show database status + run: | + geonature db status --dependencies + env: + GEONATURE_CONFIG_FILE: config/test_config.toml + - name: Test with pytest + run: | + pytest -v --cov --cov-report xml + working-directory: ./extra + env: + GEONATURE_CONFIG_FILE: config/test_config.toml