From 91e65840c108f4bcb7de449a4d315a27cadb8cd3 Mon Sep 17 00:00:00 2001 From: "Vincent Namy (EDU_GE)" <vincent.namy@edu.ge.ch> Date: Thu, 26 Dec 2024 15:20:17 +0100 Subject: [PATCH] =?UTF-8?q?Mettre=20=C3=A0=20jour=20le=20fichier=20.gitlab?= =?UTF-8?q?-ci.yml=20pour=20formater=20les=20ficher=20json=20et=20ipynb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..4c8eb2a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,28 @@ +stages: + - format + +format_files: + stage: format + image: python:3.10 + before_script: + - pip install jq nbformat + script: + # Récupère les fichiers JSON et IPYNB modifiés dans le commit + - MODIFIED_JSON_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.json$' || true) + - MODIFIED_IPYNB_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.ipynb$' || true) + # Si aucun fichier n'est modifié, terminer le job + - if [ -z "$MODIFIED_JSON_FILES" ] && [ -z "$MODIFIED_IPYNB_FILES" ]; then echo "No files to format."; exit 0; fi + # Formatage des fichiers JSON + - for file in $MODIFIED_JSON_FILES; do + jq . "$file" > "$file.formatted" && mv "$file.formatted" "$file"; + done + # Formatage des fichiers IPYNB + - for file in $MODIFIED_IPYNB_FILES; do + python -m nbformat --to notebook --input "$file" --output "$file.formatted" && mv "$file.formatted" "$file"; + done + # Ajouter les modifications pour le commit (optionnel) + - git add $MODIFIED_JSON_FILES $MODIFIED_IPYNB_FILES + rules: + - changes: + - "*.json" + - "*.ipynb" -- GitLab