diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b36f738c81825f2c43c9fbf2d855403e37cc0a01..acb9527544e57a3dcdb191a2689d1e8739779fd9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,43 +1,21 @@ -.setup_git: &setup_git - - apt-get update - - apt-get install -y git - - git config --global user.email "gitlab@localhost" - - git config --global user.name "GitLab CI" - - git remote rm origin - - git remote add origin https://gitlab-ci-token:${CI_TAG_TOKEN}@${CI_REPOSITORY_URL#*@} - - git fetch --all - - git checkout $CI_COMMIT_REF_NAME - stages: - - generate - check -workflow_template: - stage: generate +json_format_check: + stage: check image: gitlab-registry.esrf.fr/dau/ci/pyci/python_3.11:latest - before_script: - - *setup_git script: - - python template/generateWorflowFromTemplate.py - - if ! git diff --cached --exit-code; then - echo "Differences detected between generated and existing JSON files."; - git diff --cached; - exit 1; - else - echo "No differences found. Workflow generation is consistent."; - fi - - git add workflows/*.json - - if git diff --cached --quiet; then echo "No changes to commit."; else git commit -m "Generated workflow JSON files" && git push origin $CI_COMMIT_REF_NAME; fi - artifacts: - paths: - - workflows/*.json - rules: - - if: "$CI_COMMIT_BRANCH" + - ci/check_json_format.sh -json_format_check: +workflow_template_check: stage: check image: gitlab-registry.esrf.fr/dau/ci/pyci/python_3.11:latest script: - - ci/check_json_format.sh - rules: - - if: "$CI_COMMIT_BRANCH" + - echo "Calculating initial checksums of workflows files..." + - find workflows/ -type f -exec sha1sum {} \; | sort > before_checksums.txt + - echo "Running generateWorflowFromTemplate.py..." + - python template/generateWorflowFromTemplate.py + - echo "Calculating checksums of workflows files after running the script..." + - find workflows/ -type f -exec sha1sum {} \; | sort > after_checksums.txt + - echo "Comparing checksums..." + - diff before_checksums.txt after_checksums.txt