From 3774c25d217d1d8ec67ce25fc4472c1aaddfdd43 Mon Sep 17 00:00:00 2001 From: "Vincent Namy (EDU_GE)" <vincent.namy@edu.ge.ch> Date: Thu, 26 Dec 2024 15:36:27 +0100 Subject: [PATCH] =?UTF-8?q?Mettre=20=C3=A0=20jour=20le=20fichier=20.gitlab?= =?UTF-8?q?-ci.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 08b02c8..e69de29 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,50 +0,0 @@ -stages: - - format - -format_files: - stage: format - image: python:3.10 - before_script: - - pip install jq nbformat - script: - # Crée un script Python pour formater les fichiers .ipynb - - | - echo ' - import nbformat - import sys - - def reformat_notebook(file_path): - with open(file_path, "r", encoding="utf-8") as f: - notebook = nbformat.read(f, as_version=4) - - with open(file_path, "w", encoding="utf-8") as f: - nbformat.write(notebook, f) - - if __name__ == "__main__": - for file_path in sys.argv[1:]: - reformat_notebook(file_path) - print(f"Formatted: {file_path}") - ' > reformat_ipynb.py - # Identifier les fichiers modifiés - - MODIFIED_JSON_FILES=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA | grep '\.json$' || true) - - MODIFIED_IPYNB_FILES=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA | grep '\.ipynb$' || true) - - echo "Modified JSON files: $MODIFIED_JSON_FILES" - - echo "Modified IPYNB files: $MODIFIED_IPYNB_FILES" - # 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 reformat_ipynb.py "$file"; - done - # Ajouter et pousser les modifications - - git config --global user.email "ci-bot@example.com" - - git config --global user.name "CI Bot" - - git add $MODIFIED_JSON_FILES $MODIFIED_IPYNB_FILES - - git commit -m "Formatted JSON and IPYNB files" || echo "No changes to commit." - - git push origin $CI_COMMIT_REF_NAME - rules: - - changes: - - "*.json" - - "*.ipynb" -- GitLab