From 2d5f8088fb4dbfa86318a37c01071e0488b41ee3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 18:57:25 +0000 Subject: [PATCH 1/2] Initial plan From 784a13b72ea0d46609c474c8ccee2e3edfa3698c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 19:00:15 +0000 Subject: [PATCH 2/2] Add conditional Python analysis to CodeQL workflow - Add 'detect' job to check for Python file changes - Modify 'analyze' job to skip Python when no .py files changed - Handle pull_request and push events appropriately - Use $GITHUB_OUTPUT for setting job outputs - Preserve all other CodeQL configurations Co-authored-by: MightyPrytanis <219587333+MightyPrytanis@users.noreply.github.com> --- .github/workflows/codeql.yml | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3f08955b..2f972e17 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -36,8 +36,63 @@ on: - cron: '25 14 * * 4' jobs: + detect: + name: Detect Changed Files + runs-on: ubuntu-latest + outputs: + python_changed: ${{ steps.detect_python.outputs.python_changed }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Detect Python file changes + id: detect_python + shell: bash + run: | + echo "Detecting Python file changes..." + + if [ "${{ github.event_name }}" == "pull_request" ]; then + echo "Pull request event detected" + BASE_REF="${{ github.event.pull_request.base.sha }}" + HEAD_REF="${{ github.event.pull_request.head.sha }}" + echo "Comparing $BASE_REF...$HEAD_REF" + CHANGED_FILES=$(git diff --name-only "$BASE_REF" "$HEAD_REF") + elif [ "${{ github.event_name }}" == "push" ]; then + echo "Push event detected" + BEFORE_SHA="${{ github.event.before }}" + AFTER_SHA="${{ github.sha }}" + + # Handle initial commit case + if [ "$BEFORE_SHA" == "0000000000000000000000000000000000000000" ]; then + echo "Initial commit detected, checking all files" + CHANGED_FILES=$(git ls-files) + else + echo "Comparing $BEFORE_SHA...$AFTER_SHA" + CHANGED_FILES=$(git diff --name-only "$BEFORE_SHA" "$AFTER_SHA") + fi + else + echo "Schedule or other event type - checking for any Python files in repository" + CHANGED_FILES=$(git ls-files) + fi + + echo "Changed files:" + echo "$CHANGED_FILES" + + if echo "$CHANGED_FILES" | grep -q "\.py$"; then + echo "Python files detected in changes" + echo "python_changed=true" >> $GITHUB_OUTPUT + else + echo "No Python files detected in changes" + echo "python_changed=false" >> $GITHUB_OUTPUT + fi + analyze: name: Analyze (${{ matrix.language }}) + needs: detect + # Skip Python analysis if no Python files were changed + if: matrix.language != 'python' || needs.detect.outputs.python_changed == 'true' # Runner size impacts CodeQL analysis time. To learn more, please see: # - https://gh.io/recommended-hardware-resources-for-running-codeql # - https://gh.io/supported-runners-and-hardware-resources