DEVOPS-1086: Adding logic to run Pylint on all files when env files changes#206
DEVOPS-1086: Adding logic to run Pylint on all files when env files changes#206RomFloreani wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the reusable Python static analysis GitHub Actions workflow to force running Pylint across the full codebase when an environment lock file changes, instead of limiting linting to only modified Python files in pull requests.
Changes:
- Detects lock-file changes based on the selected package manager (pixi/poetry/conda) during PR runs.
- Falls back to linting only modified Python files when no relevant lock file has changed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| changed_files=$(git diff --diff-filter=AM --name-only refs/remotes/origin/${GITHUB_BASE_REF}... --) | ||
| if [ -n "$LOCK_FILE" ] && echo "$changed_files" | grep -qxF "$LOCK_FILE"; then | ||
| echo "Lock file '$LOCK_FILE' changed: forcing Pylint to run on all files" | ||
| else | ||
| { | ||
| echo 'FILES_PARAM<<_EOF_' | ||
| echo "$changed_files" | grep -E "^(${source_dir}|tests)/.*\.py$" || true | ||
| echo '_EOF_' | ||
| } >> $GITHUB_ENV | ||
| fi |
There was a problem hiding this comment.
Added a separate unfiltered changed_files_all diff for the lock-file check so a genuine deletion is caught, while keeping the AM filter for the pylint file list.
sebhmg
left a comment
There was a problem hiding this comment.
see suggestions and questions
There was a problem hiding this comment.
thought: the existing logic is not quite right here
If in a PR and there are not files changes, there is just no need to run pylint
Instead should likely have something like:
- name: Pylint skipped
if: ${{ (github.event_name == 'pull_request') && !env.FILES_PARAM }}
run: echo "::notice::Pylint skipped: no applicable file changes detected."
- name: Run Pylint on modified files
if: ${{ (github.event_name == 'pull_request') && env.FILES_PARAM }}
run: ...
- name: Run Pylint on all files
if: ${{ (github.event_name != 'pull_request') }}
run: ...|
@sebhmg Link to run: |
DEVOPS-1086 - In CI-Tools, force Pylint on all files if environment lock has changed