Loading .gitlab-ci.yml +52 −60 Original line number Diff line number Diff line Loading @@ -126,23 +126,23 @@ apply_autopep8: - . # Pass the modified workspace (this is the fully formatted code) expire_in: 1 hour # Job 5: Run Pylint run_pylint: stage: lint tags: - git-run-ia2 needs: - job: apply_autopep8 artifacts: true before_script: - pip install pylint script: - echo "Current directory $(pwd)" - ls -la - echo "Running pylint on '${PYLINT_TARGETS}'..." # .pylintrc should be at the project root, available from the artifact - pylint --rcfile=.pylintrc "${PYLINT_TARGETS}" - echo "Pylint check complete." ## Job 5: Run Pylint #run_pylint: # stage: lint # tags: # - git-run-ia2 # needs: # - job: apply_autopep8 # artifacts: true # before_script: # - pip install pylint # script: # - echo "Current directory $(pwd)" # - ls -la # - echo "Running pylint on '${PYLINT_TARGETS}'..." # # .pylintrc should be at the project root, available from the artifact # - pylint --rcfile=.pylintrc "${PYLINT_TARGETS}" # - echo "Pylint check complete." #rules: # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH Loading @@ -150,50 +150,42 @@ run_pylint: # allow_failure: true # Allow manual trigger to not fail overall pipeline if desired # --- Optional: Auto Commit Job (Add if you want CI to commit changes) --- # commit_formatted_code: # stage: auto_commit # tags: # - git-run-ia2 # needs: commit_formatted_code: stage: auto_commit tags: - git-run-ia2 needs: # - job: run_pylint # Must pass pylint # - job: apply_autopep8 # Needs the final code state from formatting # artifacts: true # before_script: # # Git and SSH setup (ensure SSH_DEPLOY_KEY CI/CD variable is set as File type) # - apt-get update -y && apt-get install -y openssh-client git # - eval $(ssh-agent -s) # - mkdir -p ~/.ssh && chmod 700 ~/.ssh # - echo "$SSH_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_ci_deploy && chmod 600 ~/.ssh/id_ci_deploy # - ssh-add ~/.ssh/id_ci_deploy # - ssh-keyscan -p ${CI_SERVER_PORT:-22} $CI_SERVER_HOST >> ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts # - git config --global user.email "${GIT_USER_EMAIL}" # - git config --global user.name "${GIT_USER_NAME}" # # Ensure we are on the correct branch and have the latest files from artifacts # - git checkout "$CI_COMMIT_BRANCH" # script: # - echo "Checking for formatting changes to commit..." # - | # # Add only the formatted targets to avoid committing other unintended changes # git add "${FORMAT_TARGETS}" # # if ! git diff --cached --quiet HEAD; then # Check staged changes against HEAD # echo "Code formatting changes applied. Committing to branch '${CI_COMMIT_BRANCH}'." # # Option 1: Commit to a NEW branch (Safer) # # git checkout -B "${FORMATTED_BRANCH_NAME}" # # git commit -m "ci: Apply automated code formatting [skip ci]" # # git push -u origin "${FORMATTED_BRANCH_NAME}" -o ci.skip # # echo "Changes pushed to new branch '${FORMATTED_BRANCH_NAME}'. Please review and merge." # # # Option 2: Commit directly to the CURRENT branch (Use with extreme caution!) # # This is generally NOT recommended for branches that developers also work on directly. # # Only suitable if this CI job is the SOLE writer to this branch for formatting. # git commit -m "ci: Apply automated code formatting [skip ci]" # echo "Pushing formatting changes to '${CI_COMMIT_BRANCH}'..." # git push origin HEAD:"${CI_COMMIT_BRANCH}" -o ci.skip # Push current HEAD to remote branch # echo "Formatting changes pushed to '${CI_COMMIT_BRANCH}'." # else # echo "No formatting changes to commit." # fi - job: apply_autopep8 # Needs the final code state from formatting artifacts: true before_script: # Git and SSH setup (ensure SSH_DEPLOY_KEY CI/CD variable is set as File type) - apt-get update -y && apt-get install -y openssh-client git - eval $(ssh-agent -s) - mkdir -p ~/.ssh && chmod 700 ~/.ssh - echo "$SSH_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_ci_deploy && chmod 600 ~/.ssh/id_ci_deploy - ssh-add ~/.ssh/id_ci_deploy - ssh-keyscan -p ${CI_SERVER_PORT:-22} $CI_SERVER_HOST >> ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts - git config --global user.email "${GIT_USER_EMAIL}" - git config --global user.name "${GIT_USER_NAME}" # Ensure we are on the correct branch and have the latest files from artifacts - git checkout "$CI_COMMIT_BRANCH" script: - echo "Checking for formatting changes to commit..." - | # Add only the formatted targets to avoid committing other unintended changes git add "${FORMAT_TARGETS}" if ! git diff --cached --quiet HEAD; then # Check staged changes against HEAD echo "Code formatting changes applied. Committing to branch '${CI_COMMIT_BRANCH}'." # Option 1: Commit to a NEW branch (Safer) git checkout -B "${FORMATTED_BRANCH_NAME}" git commit -m "ci: Apply automated code formatting [skip ci]" git push -u origin "${FORMATTED_BRANCH_NAME}" -o ci.skip echo "Changes pushed to new branch '${FORMATTED_BRANCH_NAME}'. Please review and merge." else echo "No formatting changes to commit." fi # rules: # # Example: Only run manually on the default branch after all checks pass # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE != "schedule" # Avoid on schedules Loading Loading
.gitlab-ci.yml +52 −60 Original line number Diff line number Diff line Loading @@ -126,23 +126,23 @@ apply_autopep8: - . # Pass the modified workspace (this is the fully formatted code) expire_in: 1 hour # Job 5: Run Pylint run_pylint: stage: lint tags: - git-run-ia2 needs: - job: apply_autopep8 artifacts: true before_script: - pip install pylint script: - echo "Current directory $(pwd)" - ls -la - echo "Running pylint on '${PYLINT_TARGETS}'..." # .pylintrc should be at the project root, available from the artifact - pylint --rcfile=.pylintrc "${PYLINT_TARGETS}" - echo "Pylint check complete." ## Job 5: Run Pylint #run_pylint: # stage: lint # tags: # - git-run-ia2 # needs: # - job: apply_autopep8 # artifacts: true # before_script: # - pip install pylint # script: # - echo "Current directory $(pwd)" # - ls -la # - echo "Running pylint on '${PYLINT_TARGETS}'..." # # .pylintrc should be at the project root, available from the artifact # - pylint --rcfile=.pylintrc "${PYLINT_TARGETS}" # - echo "Pylint check complete." #rules: # - if: $CI_PIPELINE_SOURCE == "merge_request_event" # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH Loading @@ -150,50 +150,42 @@ run_pylint: # allow_failure: true # Allow manual trigger to not fail overall pipeline if desired # --- Optional: Auto Commit Job (Add if you want CI to commit changes) --- # commit_formatted_code: # stage: auto_commit # tags: # - git-run-ia2 # needs: commit_formatted_code: stage: auto_commit tags: - git-run-ia2 needs: # - job: run_pylint # Must pass pylint # - job: apply_autopep8 # Needs the final code state from formatting # artifacts: true # before_script: # # Git and SSH setup (ensure SSH_DEPLOY_KEY CI/CD variable is set as File type) # - apt-get update -y && apt-get install -y openssh-client git # - eval $(ssh-agent -s) # - mkdir -p ~/.ssh && chmod 700 ~/.ssh # - echo "$SSH_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_ci_deploy && chmod 600 ~/.ssh/id_ci_deploy # - ssh-add ~/.ssh/id_ci_deploy # - ssh-keyscan -p ${CI_SERVER_PORT:-22} $CI_SERVER_HOST >> ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts # - git config --global user.email "${GIT_USER_EMAIL}" # - git config --global user.name "${GIT_USER_NAME}" # # Ensure we are on the correct branch and have the latest files from artifacts # - git checkout "$CI_COMMIT_BRANCH" # script: # - echo "Checking for formatting changes to commit..." # - | # # Add only the formatted targets to avoid committing other unintended changes # git add "${FORMAT_TARGETS}" # # if ! git diff --cached --quiet HEAD; then # Check staged changes against HEAD # echo "Code formatting changes applied. Committing to branch '${CI_COMMIT_BRANCH}'." # # Option 1: Commit to a NEW branch (Safer) # # git checkout -B "${FORMATTED_BRANCH_NAME}" # # git commit -m "ci: Apply automated code formatting [skip ci]" # # git push -u origin "${FORMATTED_BRANCH_NAME}" -o ci.skip # # echo "Changes pushed to new branch '${FORMATTED_BRANCH_NAME}'. Please review and merge." # # # Option 2: Commit directly to the CURRENT branch (Use with extreme caution!) # # This is generally NOT recommended for branches that developers also work on directly. # # Only suitable if this CI job is the SOLE writer to this branch for formatting. # git commit -m "ci: Apply automated code formatting [skip ci]" # echo "Pushing formatting changes to '${CI_COMMIT_BRANCH}'..." # git push origin HEAD:"${CI_COMMIT_BRANCH}" -o ci.skip # Push current HEAD to remote branch # echo "Formatting changes pushed to '${CI_COMMIT_BRANCH}'." # else # echo "No formatting changes to commit." # fi - job: apply_autopep8 # Needs the final code state from formatting artifacts: true before_script: # Git and SSH setup (ensure SSH_DEPLOY_KEY CI/CD variable is set as File type) - apt-get update -y && apt-get install -y openssh-client git - eval $(ssh-agent -s) - mkdir -p ~/.ssh && chmod 700 ~/.ssh - echo "$SSH_DEPLOY_KEY" | tr -d '\r' > ~/.ssh/id_ci_deploy && chmod 600 ~/.ssh/id_ci_deploy - ssh-add ~/.ssh/id_ci_deploy - ssh-keyscan -p ${CI_SERVER_PORT:-22} $CI_SERVER_HOST >> ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts - git config --global user.email "${GIT_USER_EMAIL}" - git config --global user.name "${GIT_USER_NAME}" # Ensure we are on the correct branch and have the latest files from artifacts - git checkout "$CI_COMMIT_BRANCH" script: - echo "Checking for formatting changes to commit..." - | # Add only the formatted targets to avoid committing other unintended changes git add "${FORMAT_TARGETS}" if ! git diff --cached --quiet HEAD; then # Check staged changes against HEAD echo "Code formatting changes applied. Committing to branch '${CI_COMMIT_BRANCH}'." # Option 1: Commit to a NEW branch (Safer) git checkout -B "${FORMATTED_BRANCH_NAME}" git commit -m "ci: Apply automated code formatting [skip ci]" git push -u origin "${FORMATTED_BRANCH_NAME}" -o ci.skip echo "Changes pushed to new branch '${FORMATTED_BRANCH_NAME}'. Please review and merge." else echo "No formatting changes to commit." fi # rules: # # Example: Only run manually on the default branch after all checks pass # - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE != "schedule" # Avoid on schedules Loading