From 7606b5d3e5ed35fa58c8383ee4b69d21b8b269e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 1 Aug 2026 23:36:04 +0530 Subject: [PATCH 1/3] Add PR review Action: flake8, pylint, bandit via reviewdog Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pr-review.yml | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/pr-review.yml diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml new file mode 100644 index 000000000..86912910a --- /dev/null +++ b/.github/workflows/pr-review.yml @@ -0,0 +1,40 @@ +name: PR Lint Review + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + lint: + runs-on: ubuntu-latest + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install linters + run: | + python -m pip install --upgrade pip + pip install flake8 pylint bandit reviewdog + + - name: Run flake8 and report via reviewdog + run: | + flake8 --format=default . > flake8.out || true + reviewdog -f=flake8 -name="flake8" -reporter=github-pr-review -level=warning < flake8.out + + - name: Run pylint and report via reviewdog + run: | + pylint $(git ls-files "*.py") --output-format=text > pylint.out || true + reviewdog -f=pylint -name="pylint" -reporter=github-pr-review -level=warning < pylint.out + + - name: Run bandit and report via reviewdog + run: | + bandit -r . -f json -o bandit.json || true + reviewdog -f=bandit -name="bandit" -reporter=github-pr-review -level=warning < bandit.json From 3f5cc3f0c3f604c4e481be176d260aaae513367f Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 1 Aug 2026 23:43:56 +0530 Subject: [PATCH 2/3] PR review action: run linters only on changed Python files and skip when none changed\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pr-review.yml | 43 ++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index 86912910a..1c8c96e24 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -13,6 +13,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v4 @@ -24,17 +26,46 @@ jobs: python -m pip install --upgrade pip pip install flake8 pylint bandit reviewdog - - name: Run flake8 and report via reviewdog + - name: Determine changed Python files + id: changes + run: | + echo "PR_BASE=${{ github.event.pull_request.base.sha }}" + # Ensure we have the base ref fetched + git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1 || true + CHANGED_PY_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}...HEAD | grep '\.py$' || true) + echo "changed_files<> $GITHUB_OUTPUT + echo "$CHANGED_PY_FILES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Skip if no Python files changed + if: steps.changes.outputs.changed_files == '' + run: | + echo "No Python files changed in this PR — skipping lint steps." + + - name: Run flake8 on changed files and report via reviewdog + if: steps.changes.outputs.changed_files != '' run: | - flake8 --format=default . > flake8.out || true + set -e + FILES=$(echo "${{ steps.changes.outputs.changed_files }}" | tr '\n' ' ') + echo "Running flake8 on: $FILES" + flake8 --format=default $FILES > flake8.out || true reviewdog -f=flake8 -name="flake8" -reporter=github-pr-review -level=warning < flake8.out - - name: Run pylint and report via reviewdog + - name: Run pylint on changed files and report via reviewdog + if: steps.changes.outputs.changed_files != '' run: | - pylint $(git ls-files "*.py") --output-format=text > pylint.out || true + set -e + FILES=$(echo "${{ steps.changes.outputs.changed_files }}" | tr '\n' ' ') + echo "Running pylint on: $FILES" + pylint $FILES --output-format=text > pylint.out || true reviewdog -f=pylint -name="pylint" -reporter=github-pr-review -level=warning < pylint.out - - name: Run bandit and report via reviewdog + - name: Run bandit on changed files and report via reviewdog + if: steps.changes.outputs.changed_files != '' run: | - bandit -r . -f json -o bandit.json || true + set -e + FILES=$(echo "${{ steps.changes.outputs.changed_files }}" | tr '\n' ' ') + echo "Running bandit on: $FILES" + # bandit accepts files and directories; run against the changed files + bandit -r $FILES -f json -o bandit.json || true reviewdog -f=bandit -name="bandit" -reporter=github-pr-review -level=warning < bandit.json From dc2a6ea5ff85fd3b675a1a4d149730efdfb3d66a Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 1 Aug 2026 23:54:20 +0530 Subject: [PATCH 3/3] Fix: install reviewdog binary via official installer (not pip) --- .github/workflows/pr-review.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml index 1c8c96e24..7beb4df02 100644 --- a/.github/workflows/pr-review.yml +++ b/.github/workflows/pr-review.yml @@ -24,7 +24,12 @@ jobs: - name: Install linters run: | python -m pip install --upgrade pip - pip install flake8 pylint bandit reviewdog + pip install flake8 pylint bandit + + - name: Install reviewdog + run: | + # reviewdog is not a Python package; install the binary using the official installer + curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b /usr/local/bin v0.13.0 - name: Determine changed Python files id: changes