Refactor GitHub Actions to use Micromamba

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.
This commit is contained in:
Alex38Lyon
2026-08-31 18:23:46 +02:00
committed by GitHub
parent 2aecc76e6c
commit b6376438e7
+116 -58
View File
@@ -6,6 +6,7 @@ on:
paths: paths:
- 'Outputs/SHP/*.shp' - 'Outputs/SHP/*.shp'
# Permet de lancer l'action manuellement
workflow_dispatch: workflow_dispatch:
permissions: permissions:
@@ -24,116 +25,152 @@ jobs:
uses: actions/checkout@v6 uses: actions/checkout@v6
# ------------------------------------------------------------ # ------------------------------------------------------------
# Installation de Python # Installation de Micromamba
# ------------------------------------------------------------ # ------------------------------------------------------------
- name: Setup Python - name: Setup Micromamba
uses: actions/setup-python@v7 uses: mamba-org/setup-micromamba@v2
with: with:
python-version: '3.12' environment-name: pyThtoQgis
create-args: >-
# ------------------------------------------------------------ python=3.12
# Installation de GDAL et SFCGAL gdal
# ------------------------------------------------------------ sfcgal
- name: Install GDAL and SFCGAL numpy
run: | pip
sudo apt-get update init-shell: bash
cache-environment: true
sudo apt-get install -y \ cache-downloads: true
gdal-bin \
libgdal-dev \
libsfcgal-dev
# ------------------------------------------------------------
# Vérification de GDAL
# ------------------------------------------------------------
- name: Check GDAL
run: |
echo "========================================"
echo "GDAL système"
echo "========================================"
gdal-config --version
echo
echo "gdal-config :"
which gdal-config
echo
echo "GDAL --version :"
gdalinfo --version
# ------------------------------------------------------------ # ------------------------------------------------------------
# Installation des bibliothèques Python # Installation des bibliothèques Python
# ------------------------------------------------------------ # ------------------------------------------------------------
- name: Install Python dependencies - name: Install Python dependencies
shell: bash -el {0}
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install alive-progress
pip install numpy
pip install alive-progress
pip install "gdal[numpy]==$(gdal-config --version).*"
# ------------------------------------------------------------ # ------------------------------------------------------------
# Vérification des bibliothèques Python # Vérification de l'environnement
# ------------------------------------------------------------ # ------------------------------------------------------------
- name: Test Python dependencies - name: Check GDAL and SFCGAL
shell: bash -el {0}
run: | run: |
echo "========================================" echo "========================================"
echo "Python" echo "Python"
echo "========================================" echo "========================================"
python --version python --version
which python
echo echo
echo "========================================" echo "========================================"
echo "NumPy" echo "Conda"
echo "========================================" echo "========================================"
python -c "import numpy; print(numpy.__version__)" echo "$CONDA_PREFIX"
conda list | grep -E "gdal|libgdal|sfcgal|geos|numpy"
echo echo
echo "========================================" echo "========================================"
echo "GDAL Python" echo "GDAL"
echo "========================================" echo "========================================"
python -c "from osgeo import gdal; print(gdal.__version__)" gdalinfo --version
echo
echo "GDAL Python :"
python -c "
from osgeo import gdal
print(gdal.__version__)
"
echo echo
echo "========================================" echo "========================================"
echo "OGR" echo "OGR"
echo "========================================" echo "========================================"
python -c "from osgeo import ogr; print('OGR OK')" python -c "
from osgeo import ogr
print('OGR OK')
print('GEOS version:', ogr.GetGEOSVersionMajor(),
ogr.GetGEOSVersionMinor(),
ogr.GetGEOSVersionMicro())
"
echo echo
echo "========================================" echo "========================================"
echo "alive-progress" echo "SFCGAL"
echo "========================================" echo "========================================"
python -c "from alive_progress import alive_bar; print('alive-progress OK')" 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 # Exécution de pyThtoQgis
# ------------------------------------------------------------ # ------------------------------------------------------------
- name: Run pyThtoQgis - name: Run pyThtoQgis
shell: bash -el {0}
working-directory: Scripts/pyThtoQgis working-directory: Scripts/pyThtoQgis
run: | run: |
python pyThtoQgis.py --folder "../../Outputs/SHP/" python pyThtoQgis.py --folder "../../Outputs/SHP/"
# ------------------------------------------------------------ # ------------------------------------------------------------
# Vérification des fichiers générés # Affichage des fichiers générés
# ------------------------------------------------------------ # ------------------------------------------------------------
- name: Check generated files - name: Show generated files
shell: bash -el {0}
run: | run: |
echo "========================================" echo "========================================"
echo "GPKG et logs générés" echo "Fichiers générés"
echo "========================================" echo "========================================"
find Outputs -type f \( \ find Outputs/SHP/QGis_GPKG_Files \
-name "*.gpkg" -o \ -maxdepth 1 \
-name "pyThtoQgis.log" \ -type f \
\) -print -print
echo echo
echo "========================================" echo "========================================"
@@ -142,6 +179,26 @@ jobs:
git status --short 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 # Commit des résultats
# ------------------------------------------------------------ # ------------------------------------------------------------
@@ -149,5 +206,6 @@ jobs:
uses: stefanzweifel/git-auto-commit-action@v7 uses: stefanzweifel/git-auto-commit-action@v7
with: with:
commit_message: "Auto-run pyThtoQgis" commit_message: "Auto-run pyThtoQgis"
file_pattern: 'Outputs/**/*.gpkg Outputs/**/pyThtoQgis.log' file_pattern: >-
Outputs/SHP/QGis_GPKG_Files/*.gpkg
Outputs/SHP/QGis_GPKG_Files/pyThtoQgis.log