mirror of
https://github.com/Alex38Lyon/Synthese-PSM_LARRA.git
synced 2026-09-30 07:21:55 +00:00
Updated GitHub Actions workflow to use Micromamba for Python environment setup instead of traditional Python installation. Added explicit steps for checking GDAL and SFCGAL versions, and modified file handling for generated outputs.
212 lines
6.2 KiB
YAML
212 lines
6.2 KiB
YAML
|
|
name: pyThtoQgis
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'Outputs/SHP/*.shp'
|
|
|
|
# Permet de lancer l'action manuellement
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
convert:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
# ------------------------------------------------------------
|
|
# Récupération du dépôt
|
|
# ------------------------------------------------------------
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
# ------------------------------------------------------------
|
|
# Installation de Micromamba
|
|
# ------------------------------------------------------------
|
|
- name: Setup Micromamba
|
|
uses: mamba-org/setup-micromamba@v2
|
|
with:
|
|
environment-name: pyThtoQgis
|
|
create-args: >-
|
|
python=3.12
|
|
gdal
|
|
sfcgal
|
|
numpy
|
|
pip
|
|
init-shell: bash
|
|
cache-environment: true
|
|
cache-downloads: true
|
|
|
|
# ------------------------------------------------------------
|
|
# Installation des bibliothèques Python
|
|
# ------------------------------------------------------------
|
|
- name: Install Python dependencies
|
|
shell: bash -el {0}
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install alive-progress
|
|
|
|
# ------------------------------------------------------------
|
|
# Vérification de l'environnement
|
|
# ------------------------------------------------------------
|
|
- name: Check GDAL and SFCGAL
|
|
shell: bash -el {0}
|
|
run: |
|
|
|
|
echo "========================================"
|
|
echo "Python"
|
|
echo "========================================"
|
|
|
|
python --version
|
|
which python
|
|
|
|
echo
|
|
echo "========================================"
|
|
echo "Conda"
|
|
echo "========================================"
|
|
|
|
echo "$CONDA_PREFIX"
|
|
|
|
conda list | grep -E "gdal|libgdal|sfcgal|geos|numpy"
|
|
|
|
echo
|
|
echo "========================================"
|
|
echo "GDAL"
|
|
echo "========================================"
|
|
|
|
gdalinfo --version
|
|
|
|
echo
|
|
echo "GDAL Python :"
|
|
|
|
python -c "
|
|
from osgeo import gdal
|
|
print(gdal.__version__)
|
|
"
|
|
|
|
echo
|
|
echo "========================================"
|
|
echo "OGR"
|
|
echo "========================================"
|
|
|
|
python -c "
|
|
from osgeo import ogr
|
|
print('OGR OK')
|
|
print('GEOS version:', ogr.GetGEOSVersionMajor(),
|
|
ogr.GetGEOSVersionMinor(),
|
|
ogr.GetGEOSVersionMicro())
|
|
"
|
|
|
|
echo
|
|
echo "========================================"
|
|
echo "SFCGAL"
|
|
echo "========================================"
|
|
|
|
sfcgal-config --version || true
|
|
|
|
echo
|
|
echo "========================================"
|
|
echo "Test SFCGAL via OGR"
|
|
echo "========================================"
|
|
|
|
python - <<'PY'
|
|
from osgeo import ogr
|
|
|
|
print("Création d'une géométrie 3D...")
|
|
|
|
# PolyhedralSurface simple :
|
|
# une pyramide composée de triangles
|
|
wkt = """
|
|
POLYHEDRALSURFACE Z (
|
|
((0 0 0, 10 0 0, 0 10 0, 0 0 0)),
|
|
((0 0 0, 10 0 0, 0 0 10, 0 0 0)),
|
|
((10 0 0, 0 10 0, 0 0 10, 10 0 0)),
|
|
((0 10 0, 0 0 0, 0 0 10, 0 10 0)),
|
|
((0 0 10, 10 0 0, 0 0 0, 0 0 10))
|
|
)
|
|
"""
|
|
|
|
geom = ogr.CreateGeometryFromWkt(wkt)
|
|
|
|
if geom is None:
|
|
raise RuntimeError("Impossible de créer la géométrie de test")
|
|
|
|
print("Type :", geom.GetGeometryName())
|
|
|
|
try:
|
|
valid = geom.IsValid()
|
|
print("IsValid() :", valid)
|
|
print("SFCGAL accessible par OGR : OK")
|
|
|
|
except RuntimeError as e:
|
|
print("ERREUR IsValid() :", e)
|
|
raise
|
|
PY
|
|
|
|
# ------------------------------------------------------------
|
|
# Exécution de pyThtoQgis
|
|
# ------------------------------------------------------------
|
|
- name: Run pyThtoQgis
|
|
shell: bash -el {0}
|
|
working-directory: Scripts/pyThtoQgis
|
|
run: |
|
|
python pyThtoQgis.py --folder "../../Outputs/SHP/"
|
|
|
|
# ------------------------------------------------------------
|
|
# Affichage des fichiers générés
|
|
# ------------------------------------------------------------
|
|
- name: Show generated files
|
|
shell: bash -el {0}
|
|
run: |
|
|
|
|
echo "========================================"
|
|
echo "Fichiers générés"
|
|
echo "========================================"
|
|
|
|
find Outputs/SHP/QGis_GPKG_Files \
|
|
-maxdepth 1 \
|
|
-type f \
|
|
-print
|
|
|
|
echo
|
|
echo "========================================"
|
|
echo "Statut Git"
|
|
echo "========================================"
|
|
|
|
git status --short
|
|
|
|
# ------------------------------------------------------------
|
|
# Ajout explicite des résultats
|
|
# ------------------------------------------------------------
|
|
- name: Add generated files
|
|
shell: bash -el {0}
|
|
run: |
|
|
|
|
git add Outputs/SHP/QGis_GPKG_Files/*.gpkg
|
|
|
|
# Le log peut être ignoré par .gitignore.
|
|
# -f force son ajout.
|
|
git add -f Outputs/SHP/QGis_GPKG_Files/pyThtoQgis.log
|
|
|
|
echo
|
|
echo "========================================"
|
|
echo "Fichiers prêts pour le commit"
|
|
echo "========================================"
|
|
|
|
git status --short
|
|
|
|
# ------------------------------------------------------------
|
|
# Commit des résultats
|
|
# ------------------------------------------------------------
|
|
- name: Commit generated files
|
|
uses: stefanzweifel/git-auto-commit-action@v7
|
|
with:
|
|
commit_message: "Auto-run pyThtoQgis"
|
|
file_pattern: >-
|
|
Outputs/SHP/QGis_GPKG_Files/*.gpkg
|
|
Outputs/SHP/QGis_GPKG_Files/pyThtoQgis.log
|