Enhance pyThtoQgis workflow with SHP checks

Updated the GitHub Actions workflow to include checks for added or modified SHP files, improved comments, and adjusted commit messages for generated outputs.
This commit is contained in:
Alex38Lyon
2026-08-31 21:21:31 +02:00
committed by GitHub
parent 79df9b7b9d
commit 04a9c6ccbc
+166 -49
View File
@@ -2,17 +2,25 @@ name: pyThtoQgis-2
on: on:
push: push:
branches:
- main
paths: paths:
- 'Outputs/SHP/*.shp' - 'Outputs/SHP/*.shp'
# Permet de lancer l'action manuellement
workflow_dispatch: workflow_dispatch:
permissions: permissions:
contents: write contents: write
concurrency:
group: pyThtoQgis
cancel-in-progress: false
jobs: jobs:
build:
pyThtoQgis:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -20,17 +28,72 @@ jobs:
# ============================================================ # ============================================================
# 1. Récupération du dépôt # 1. Récupération du dépôt
# ============================================================ # ============================================================
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
# ============================================================ # ============================================================
# 2. Installation de Micromamba # 2. Vérification du type de modification
#
# Le workflow est déclenché par *.shp mais GitHub déclenche
# également l'action lorsqu'un SHP est supprimé.
#
# On ne continue que si au moins un SHP a été AJOUTÉ ou MODIFIÉ.
# ============================================================ # ============================================================
- name: Check SHP changes
id: changed
shell: bash
run: |
echo "========================================"
echo "Recherche des SHP ajoutés/modifiés"
echo "========================================"
SHP_FILES=$(git diff-tree \
--no-commit-id \
--name-only \
--diff-filter=AM \
-r \
"$GITHUB_SHA" \
-- 'Outputs/SHP/*.shp')
echo "Fichiers SHP ajoutés/modifiés :"
echo "$SHP_FILES"
if [ -n "$SHP_FILES" ]; then
echo "shp=true" >> "$GITHUB_OUTPUT"
else
echo "shp=false" >> "$GITHUB_OUTPUT"
fi
# ============================================================
# 3. Arrêt si aucun SHP ajouté/modifié
# ============================================================
- name: Stop if no SHP added or modified
if: steps.changed.outputs.shp != 'true'
shell: bash
run: |
echo "Aucun fichier SHP ajouté ou modifié."
echo "Le workflow s'arrête."
# ============================================================
# 4. Installation de Micromamba
# ============================================================
- name: Setup Micromamba - name: Setup Micromamba
if: steps.changed.outputs.shp == 'true'
uses: mamba-org/setup-micromamba@v2 uses: mamba-org/setup-micromamba@v2
with: with:
environment-name: pyThtoQgis environment-name: pyThtoQgis
create-args: >- create-args: >-
python=3.12 python=3.12
numpy numpy
@@ -48,15 +111,19 @@ jobs:
cmake cmake
ninja ninja
pkg-config pkg-config
init-shell: bash init-shell: bash
cache-environment: true cache-environment: true
cache-downloads: true cache-downloads: true
# ============================================================ # ============================================================
# 3. Informations environnement # 5. Informations environnement
# ============================================================ # ============================================================
- name: Environment information - name: Environment information
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
@@ -73,14 +140,20 @@ jobs:
echo "CONDA_PREFIX=$CONDA_PREFIX" echo "CONDA_PREFIX=$CONDA_PREFIX"
echo "========================================"
echo "Packages"
echo "========================================"
conda list | grep -E \ conda list | grep -E \
"python|numpy|gdal|geos|sfcgal|proj|sqlite" "python|numpy|gdal|geos|sfcgal|proj|sqlite|cmake"
# ============================================================ # ============================================================
# 4. Vérification SFCGAL # 6. Vérification SFCGAL
# ============================================================ # ============================================================
- name: Check SFCGAL - name: Check SFCGAL
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
@@ -90,6 +163,7 @@ jobs:
sfcgal-config --version || true sfcgal-config --version || true
echo ""
echo "Bibliothèques SFCGAL :" echo "Bibliothèques SFCGAL :"
find "$CONDA_PREFIX" \ find "$CONDA_PREFIX" \
@@ -98,9 +172,11 @@ jobs:
# ============================================================ # ============================================================
# 5. Compilation de GDAL # 7. Compilation de GDAL avec SFCGAL
# ============================================================ # ============================================================
- name: Build GDAL with SFCGAL - name: Build GDAL with SFCGAL
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
@@ -125,9 +201,9 @@ jobs:
cd build cd build
# -------------------------------------------------------- echo "========================================"
# CMake echo "Configuration CMake"
# -------------------------------------------------------- echo "========================================"
cmake .. \ cmake .. \
-GNinja \ -GNinja \
@@ -148,28 +224,25 @@ jobs:
echo "========================================" echo "========================================"
echo "Configuration CMake terminée" echo "Compilation"
echo "========================================" echo "========================================"
# --------------------------------------------------------
# Compilation
# --------------------------------------------------------
ninja -j"$(nproc)" ninja -j"$(nproc)"
# -------------------------------------------------------- echo "========================================"
# Installation dans Conda echo "Installation"
# -------------------------------------------------------- echo "========================================"
ninja install ninja install
# ============================================================ # ============================================================
# 6. Vérification de GDAL installé # 8. Vérification GDAL
# ============================================================ # ============================================================
- name: Check GDAL - name: Check GDAL
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
@@ -178,24 +251,30 @@ jobs:
echo "========================================" echo "========================================"
which gdalinfo which gdalinfo
gdalinfo --version gdalinfo --version
echo "" echo ""
echo "GDAL Python :" echo "GDAL Python :"
python - <<'PY' python - <<'PY'
from osgeo import gdal from osgeo import gdal
print(gdal.VersionInfo("--version")) print(gdal.VersionInfo("--version"))
print() print()
print(gdal.VersionInfo("--build-info")) print(gdal.VersionInfo("--build-info"))
PY PY
# ============================================================ # ============================================================
# 7. Vérification liaison SFCGAL # 9. Vérification liaison GDAL / SFCGAL / GEOS
# ============================================================ # ============================================================
- name: Check GDAL SFCGAL linkage - name: Check GDAL SFCGAL linkage
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
@@ -203,6 +282,7 @@ jobs:
echo "GDAL / SFCGAL linkage" echo "GDAL / SFCGAL linkage"
echo "========================================" echo "========================================"
echo ""
echo "libgdal :" echo "libgdal :"
find "$CONDA_PREFIX/lib" \ find "$CONDA_PREFIX/lib" \
@@ -211,16 +291,18 @@ jobs:
-print -print
echo "" echo ""
echo "Dépendances :" echo "Dépendances libgdal :"
ldd "$CONDA_PREFIX/lib/libgdal.so" \ ldd "$CONDA_PREFIX/lib/libgdal.so" \
| grep -Ei "sfcgal|geos" || true | grep -Ei "sfcgal|geos" || true
# ============================================================ # ============================================================
# 8. Test OGR / SFCGAL # 10. Test SFCGAL via OGR
# ============================================================ # ============================================================
- name: Test SFCGAL via OGR - name: Test SFCGAL via OGR
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
@@ -236,7 +318,7 @@ jobs:
print("GDAL :", gdal.VersionInfo("--version")) print("GDAL :", gdal.VersionInfo("--version"))
# -------------------------------------------------------- # --------------------------------------------------------
# Géométrie PolyhedralSurface Z # Création d'une géométrie 3D
# -------------------------------------------------------- # --------------------------------------------------------
wkt = """ wkt = """
@@ -259,6 +341,7 @@ jobs:
) )
print("Type :", geom.GetGeometryName()) print("Type :", geom.GetGeometryName())
print( print(
"Geometry type :", "Geometry type :",
geom.GetGeometryType() geom.GetGeometryType()
@@ -266,7 +349,9 @@ jobs:
print( print(
"Has Z :", "Has Z :",
ogr.GT_HasZ(geom.GetGeometryType()) ogr.GT_HasZ(
geom.GetGeometryType()
)
) )
try: try:
@@ -288,13 +373,15 @@ jobs:
raise raise
print() print()
print("Test terminé.") print("Test SFCGAL terminé avec succès.")
# ============================================================ # ============================================================
# 9. Installation des dépendances Python # 11. Installation des dépendances Python du projet
# ============================================================ # ============================================================
- name: Install Python dependencies - name: Install Python dependencies
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
@@ -305,46 +392,76 @@ jobs:
# ============================================================ # ============================================================
# 10. Test pyThtoQgis # 12. Affichage des SHP à traiter
# ============================================================ # ============================================================
- name: Test pyThtoQgis
- name: List SHP input files
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0} shell: bash -el {0}
run: | run: |
echo "========================================" echo "========================================"
echo "pyThtoQgis" echo "Fichiers SHP"
echo "========================================" echo "========================================"
python pyThtoQgis.py --folder "../../Outputs/SHP/" find Outputs/SHP \
-maxdepth 1 \
-type f \
-name "*.shp" \
-print
# ------------------------------------------------------------ # ============================================================
# Vérification des fichiers générés # 13. Exécution de pyThtoQgis
# ------------------------------------------------------------ # ============================================================
- name: Check generated files
- name: Run pyThtoQgis
if: steps.changed.outputs.shp == 'true'
shell: bash -el {0}
run: | run: |
echo "========================================" echo "========================================"
echo "GPKG et logs générés" echo "Exécution pyThtoQgis"
echo "========================================" echo "========================================"
find Outputs -type f \( \ cd Scripts/pyThtoQgis
-name "*.gpkg" -o \
-name "pyThtoQgis.log" \ python pyThtoQgis.py \
\) -print --folder "../../Outputs/SHP/"
# ============================================================
# 14. Affichage des fichiers produits
# ============================================================
- name: Show generated files
if: steps.changed.outputs.shp == 'true'
shell: bash
run: |
echo
echo "========================================" echo "========================================"
echo "Statut Git" echo "Fichiers générés / modifiés"
echo "========================================" echo "========================================"
git status --short git status --short
# ------------------------------------------------------------ echo ""
# Commit des résultats echo "========================================"
# ------------------------------------------------------------ echo "Différence Git"
echo "========================================"
git diff --stat
# ============================================================
# 15. Commit des fichiers produits
# ============================================================
- name: Commit generated files - name: Commit generated files
if: steps.changed.outputs.shp == 'true'
uses: stefanzweifel/git-auto-commit-action@v7 uses: stefanzweifel/git-auto-commit-action@v7
with: with:
commit_message: "Auto-run pyThtoQgis" commit_message: "Auto-generate outputs from SHP"
file_pattern: 'Outputs/**/*.gpkg Outputs/**/pyThtoQgis.log' commit_user_name: "github-actions[bot]"
commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"