Loading .gitlab-ci.yml +40 −78 Original line number Diff line number Diff line # .gitlab-ci.yml image: python:3.12 variables: PROJECT: "noctua" PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" FORMAT_TARGETS: "${PROJECT}" # For sed, autopep8, isort PYLINT_TARGETS: "${PROJECT}" # For pylint FORMAT_TARGETS: "${PROJECT}" PYLINT_TARGETS: "${PROJECT}" GIT_USER_EMAIL: "davide.ricci@inaf.it" GIT_USER_NAME: "Davide GitLab CI" FORMATTED_BRANCH_NAME: "validated" cache: key: "$CI_COMMIT_REF_SLUG" # Cache pip downloads per branch key: "$CI_COMMIT_REF_SLUG" paths: - .cache/pip # - venv/ stages: - deploy_docs - setup_and_format - lint # Does not modify code - lint - auto_commit # Job 1: Install ${PROJECT} and its dependencies # Job 1: We don't actually need to pass artifacts here if we just want to test install install_project: stage: setup_and_format tags: - git-run-ia2 script: - echo "Current directory $(pwd)" - ls -la - echo "Python version $(python -v)" - pip install --upgrade pip - echo "Installing project '${PROJECT}' and its dependencies..." - pip install -e . - echo "${PROJECT} installation complete." artifacts: paths: # Pass the entire workspace. This includes the checked-out code # or if -e . modifies local files (e.g. .egg-info). - . # The current working directory state # No artifacts needed here unless you are generating files needed by others # Job 2: Remove Trailing Whitespaces fix_trailing_whitespaces: stage: setup_and_format tags: - git-run-ia2 needs: - job: install_project artifacts: true script: - echo "Current directory $(pwd)" - ls -la - echo "Removing trailing whitespaces from '${FORMAT_TARGETS}' directory..." - find "${FORMAT_TARGETS}" -type f -name "*.py" -exec sed -i 's/[[:space:]]*$//' {} \; - echo "Trailing whitespaces removed." artifacts: paths: - . # Pass the modified workspace - "${FORMAT_TARGETS}" # ONLY pass the source code folder # Job 3: Apply isort apply_isort: Loading @@ -71,15 +52,10 @@ apply_isort: before_script: - pip install isort script: - echo "Current directory $(pwd)" - ls -la - echo "Applying isort to '${FORMAT_TARGETS}' directory..." # isort will use pyproject.toml for configuration - isort "${FORMAT_TARGETS}" - echo "isort formatting complete." artifacts: paths: - . # Pass the modified workspace - "${FORMAT_TARGETS}" # ONLY pass the source code folder # Job 4: Apply autopep8 apply_autopep8: Loading @@ -92,14 +68,10 @@ apply_autopep8: before_script: - pip install autopep8 script: - echo "Current directory $(pwd)" - ls -la - echo "Applying autopep8 to '${FORMAT_TARGETS}' directory..." - autopep8 --in-place --recursive --aggressive --aggressive "${FORMAT_TARGETS}" - echo "autopep8 formatting complete." artifacts: paths: - . # Pass the modified workspace - "${FORMAT_TARGETS}" # ONLY pass the source code folder # Job 5: Run Pylint run_pylint: Loading @@ -111,48 +83,30 @@ run_pylint: artifacts: true before_script: - pip install pylint # Install dependencies so pylint can resolve imports - pip install -e . script: - echo "Current directory $(pwd)" - echo "Running pylint on '${PYLINT_TARGETS}'..." - pylint --version - pylint --rcfile=.pylintrc --fail-on=E,F ${PYLINT_TARGETS}/sequencer.py || echo "Pylint finished with exit code $(( $? &2)) (non-zero indicates issues)" - echo "Pylint check complete." #rules: # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # - when: manual # allow_failure: true # Allow manual trigger to not fail overall pipeline if desired - pylint --rcfile=.pylintrc --fail-on=E,F ${PYLINT_TARGETS}/sequencer.py || echo "Pylint finished with issues" # Job 6: Create documentation # This defines a job named 'pages'. GitLab recognizes this special name # and knows that its purpose is to deploy a website to GitLab Pages. # Job 6: Pages (Keep as is, but it only runs on default branch) pages: stage: deploy_docs tags: - git-run-ia2 before_script: - apt-get update -y - apt install -y gnuplot - apt-get update -y && apt install -y gnuplot - pip install --upgrade pip - pip install setuptools gnuplotlib pyvantagepro # Install project so Sphinx can import it - pip install setuptools gnuplotlib pyvantagepro sphinx - pip install -e . # Install doc dependencies - pip install -r docs/requirements.txt script: - echo "creating fake node..." - cp noctua/config/nodes.ini.template noctua/config/nodes.ini - echo "Building documentation..." - sphinx-apidoc -o docs/source ${PROJECT} # The final output directory MUST be named 'public' for GitLab Pages - sphinx-build -b html docs/source public artifacts: paths: - public rules: # Only run on the default branch - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Job 7: commit in branch Loading @@ -161,24 +115,32 @@ commit_formatted_code: tags: - git-run-ia2 needs: - job: run_pylint # Must pass pylint - job: apply_autopep8 # Needs the final code state from formatting - job: run_pylint - job: apply_autopep8 artifacts: true before_script: - git config --global user.email "davide.ricci@inaf.it" - git config --global user.name "CI Bot" - git checkout "$CI_COMMIT_SHA" script: - echo "Checking for changes and committing to ${FORMATTED_BRANCH_NAME} branch..." - git add . - echo "Creating/updating branch '${FORMATTED_BRANCH_NAME}' based on commit $CI_COMMIT_SHA..." - git checkout -B "${FORMATTED_BRANCH_NAME}" "$CI_COMMIT_SHA" # 1. Setup Auth - git config --global user.email "${GIT_USER_EMAIL}" - git config --global user.name "${GIT_USER_NAME}" # 2. Re-initialize the repo state # (GitLab checkout already happened, artifacts from apply_autopep8 # have overwritten the local files in ${PROJECT}) - git add "${FORMAT_TARGETS}" # Check if there are actually changes to commit - | if git diff-index --quiet HEAD --; then echo "No changes to commit." exit 0 fi - git checkout -B "${FORMATTED_BRANCH_NAME}" - MAIN_COMMIT_MSG=$(git log -1 --pretty=%B $CI_COMMIT_SHA) - | git commit -m "$MAIN_COMMIT_MSG - Source Commit: $CI_COMMIT_SHA - Date: $(date +"%Y-%m-%d %H:%M:%S") - Job ID: $CI_JOB_ID - Pipeline ID: $CI_PIPELINE_ID - [skip ci]" Source Commit: $CI_COMMIT_SHA [skip ci]" - git push --force https://davide.ricci:$GITLAB_TOKEN@www.ict.inaf.it/gitlab/davide.ricci/software-di-controllo.git ${FORMATTED_BRANCH_NAME} Loading
.gitlab-ci.yml +40 −78 Original line number Diff line number Diff line # .gitlab-ci.yml image: python:3.12 variables: PROJECT: "noctua" PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" FORMAT_TARGETS: "${PROJECT}" # For sed, autopep8, isort PYLINT_TARGETS: "${PROJECT}" # For pylint FORMAT_TARGETS: "${PROJECT}" PYLINT_TARGETS: "${PROJECT}" GIT_USER_EMAIL: "davide.ricci@inaf.it" GIT_USER_NAME: "Davide GitLab CI" FORMATTED_BRANCH_NAME: "validated" cache: key: "$CI_COMMIT_REF_SLUG" # Cache pip downloads per branch key: "$CI_COMMIT_REF_SLUG" paths: - .cache/pip # - venv/ stages: - deploy_docs - setup_and_format - lint # Does not modify code - lint - auto_commit # Job 1: Install ${PROJECT} and its dependencies # Job 1: We don't actually need to pass artifacts here if we just want to test install install_project: stage: setup_and_format tags: - git-run-ia2 script: - echo "Current directory $(pwd)" - ls -la - echo "Python version $(python -v)" - pip install --upgrade pip - echo "Installing project '${PROJECT}' and its dependencies..." - pip install -e . - echo "${PROJECT} installation complete." artifacts: paths: # Pass the entire workspace. This includes the checked-out code # or if -e . modifies local files (e.g. .egg-info). - . # The current working directory state # No artifacts needed here unless you are generating files needed by others # Job 2: Remove Trailing Whitespaces fix_trailing_whitespaces: stage: setup_and_format tags: - git-run-ia2 needs: - job: install_project artifacts: true script: - echo "Current directory $(pwd)" - ls -la - echo "Removing trailing whitespaces from '${FORMAT_TARGETS}' directory..." - find "${FORMAT_TARGETS}" -type f -name "*.py" -exec sed -i 's/[[:space:]]*$//' {} \; - echo "Trailing whitespaces removed." artifacts: paths: - . # Pass the modified workspace - "${FORMAT_TARGETS}" # ONLY pass the source code folder # Job 3: Apply isort apply_isort: Loading @@ -71,15 +52,10 @@ apply_isort: before_script: - pip install isort script: - echo "Current directory $(pwd)" - ls -la - echo "Applying isort to '${FORMAT_TARGETS}' directory..." # isort will use pyproject.toml for configuration - isort "${FORMAT_TARGETS}" - echo "isort formatting complete." artifacts: paths: - . # Pass the modified workspace - "${FORMAT_TARGETS}" # ONLY pass the source code folder # Job 4: Apply autopep8 apply_autopep8: Loading @@ -92,14 +68,10 @@ apply_autopep8: before_script: - pip install autopep8 script: - echo "Current directory $(pwd)" - ls -la - echo "Applying autopep8 to '${FORMAT_TARGETS}' directory..." - autopep8 --in-place --recursive --aggressive --aggressive "${FORMAT_TARGETS}" - echo "autopep8 formatting complete." artifacts: paths: - . # Pass the modified workspace - "${FORMAT_TARGETS}" # ONLY pass the source code folder # Job 5: Run Pylint run_pylint: Loading @@ -111,48 +83,30 @@ run_pylint: artifacts: true before_script: - pip install pylint # Install dependencies so pylint can resolve imports - pip install -e . script: - echo "Current directory $(pwd)" - echo "Running pylint on '${PYLINT_TARGETS}'..." - pylint --version - pylint --rcfile=.pylintrc --fail-on=E,F ${PYLINT_TARGETS}/sequencer.py || echo "Pylint finished with exit code $(( $? &2)) (non-zero indicates issues)" - echo "Pylint check complete." #rules: # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # - when: manual # allow_failure: true # Allow manual trigger to not fail overall pipeline if desired - pylint --rcfile=.pylintrc --fail-on=E,F ${PYLINT_TARGETS}/sequencer.py || echo "Pylint finished with issues" # Job 6: Create documentation # This defines a job named 'pages'. GitLab recognizes this special name # and knows that its purpose is to deploy a website to GitLab Pages. # Job 6: Pages (Keep as is, but it only runs on default branch) pages: stage: deploy_docs tags: - git-run-ia2 before_script: - apt-get update -y - apt install -y gnuplot - apt-get update -y && apt install -y gnuplot - pip install --upgrade pip - pip install setuptools gnuplotlib pyvantagepro # Install project so Sphinx can import it - pip install setuptools gnuplotlib pyvantagepro sphinx - pip install -e . # Install doc dependencies - pip install -r docs/requirements.txt script: - echo "creating fake node..." - cp noctua/config/nodes.ini.template noctua/config/nodes.ini - echo "Building documentation..." - sphinx-apidoc -o docs/source ${PROJECT} # The final output directory MUST be named 'public' for GitLab Pages - sphinx-build -b html docs/source public artifacts: paths: - public rules: # Only run on the default branch - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Job 7: commit in branch Loading @@ -161,24 +115,32 @@ commit_formatted_code: tags: - git-run-ia2 needs: - job: run_pylint # Must pass pylint - job: apply_autopep8 # Needs the final code state from formatting - job: run_pylint - job: apply_autopep8 artifacts: true before_script: - git config --global user.email "davide.ricci@inaf.it" - git config --global user.name "CI Bot" - git checkout "$CI_COMMIT_SHA" script: - echo "Checking for changes and committing to ${FORMATTED_BRANCH_NAME} branch..." - git add . - echo "Creating/updating branch '${FORMATTED_BRANCH_NAME}' based on commit $CI_COMMIT_SHA..." - git checkout -B "${FORMATTED_BRANCH_NAME}" "$CI_COMMIT_SHA" # 1. Setup Auth - git config --global user.email "${GIT_USER_EMAIL}" - git config --global user.name "${GIT_USER_NAME}" # 2. Re-initialize the repo state # (GitLab checkout already happened, artifacts from apply_autopep8 # have overwritten the local files in ${PROJECT}) - git add "${FORMAT_TARGETS}" # Check if there are actually changes to commit - | if git diff-index --quiet HEAD --; then echo "No changes to commit." exit 0 fi - git checkout -B "${FORMATTED_BRANCH_NAME}" - MAIN_COMMIT_MSG=$(git log -1 --pretty=%B $CI_COMMIT_SHA) - | git commit -m "$MAIN_COMMIT_MSG - Source Commit: $CI_COMMIT_SHA - Date: $(date +"%Y-%m-%d %H:%M:%S") - Job ID: $CI_JOB_ID - Pipeline ID: $CI_PIPELINE_ID - [skip ci]" Source Commit: $CI_COMMIT_SHA [skip ci]" - git push --force https://davide.ricci:$GITLAB_TOKEN@www.ict.inaf.it/gitlab/davide.ricci/software-di-controllo.git ${FORMATTED_BRANCH_NAME}