diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..1125407 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,113 @@ +name: test_install_modules + +on: + push: + branches: + - main + - develop + - test/ci + pull_request: + branches: + - main + - test/ci + - develop + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: "Debian 11" + python-version: "3.9" + postgres-version: 13 + postgis-version: 3.2 + + name: ${{ matrix.name }} + + 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 + redis: + image: redis + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Add postgis_raster database extension + if: ${{ matrix.postgis-version >= 3 }} + run: | + psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "postgis_raster";' + env: + PGPASSWORD: geonatpasswd + - name: Add database extensions + run: | + psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "hstore";' + psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "uuid-ossp";' + psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "pg_trgm";' + psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "unaccent";' + psql -h localhost -U geonatadmin -d geonature2db -tc 'CREATE EXTENSION "ltree";' + env: + PGPASSWORD: geonatpasswd + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install GDAL + run: | + sudo apt update + sudo apt install -y libgdal-dev + - name: Install geonature + run: | + python -m pip install --upgrade pip + python -m pip install https://github.com/PnX-SI/GeoNature/archive/master.zip + working-directory: . + - name: Install monitoring module + run: | + python -m pip install https://github.com/PnX-SI/gn_module_monitoring/archive/main.zip + working-directory: . + - name: Install geonature database + run: | + curl -fsSL https://raw.githubusercontent.com/PnX-SI/GeoNature/refs/heads/master/config/test_config.toml -o output.txt + export GEONATURE_CONFIG_FILE=output.txt + geonature db upgrade geonature@head -x local-srid=2154 + geonature db autoupgrade -x local-srid=2154 + - name: Install monitoring module database + run: | + + curl -fsSL https://raw.githubusercontent.com/PnX-SI/GeoNature/refs/heads/master/config/test_config.toml -o output.txt + export GEONATURE_CONFIG_FILE=output.txt + geonature upgrade-modules-db MONITORINGS + - name: Test install monitoring + run: | + curl -fsSL https://raw.githubusercontent.com/PnX-SI/GeoNature/refs/heads/master/config/test_config.toml -o output.txt + export GEONATURE_CONFIG_FILE=output.txt + mkdir -p /opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/media/monitorings/ + cp -r * /opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/media/monitorings/ + # Test install module + for protocole in ./*/; do geonature monitorings install $protocole; done + # Test sql + for protocole in ./*/; do geonature monitorings process_sql $protocole|grep -i error|exit 1; done + + +