From b5c4ba50cd901add77be143e91ffb18112c64118 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:43:37 +0300 Subject: [PATCH] ci: smart path filtering to skip heavy Android builds on doc-only PRs (#1025) Co-authored-by: M57 --- .github/workflows/android.yml | 48 ++++++++++++++++++++++++++++++++--- .github/workflows/codeql.yml | 26 +++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 381300c0..8a792ae4 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -21,11 +21,43 @@ concurrency: cancel-in-progress: true jobs: + # ───────────────────────────────────────────────────────────────────── + # Job 0: Detect changes — skips heavy Android build/tests for doc-only PRs + # ───────────────────────────────────────────────────────────────────── + changes: + name: Detect Changes + runs-on: ubuntu-latest + timeout-minutes: 3 + outputs: + code: ${{ steps.filter.outputs.code }} + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Paths Filter + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + code: + - 'app/**' + - 'gradle/**' + - 'build.gradle.kts' + - 'settings.gradle.kts' + - 'gradle.properties' + - 'gradlew' + - 'gradlew.bat' + - '.github/workflows/android.yml' + - '.editorconfig' + - 'flake.nix' + - 'flake.lock' + # ───────────────────────────────────────────────────────────────────── # Job 1: ktlint (code style) — fastest feedback, runs in parallel. # ───────────────────────────────────────────────────────────────────── ktlint: name: ktlint — Code Style + needs: [changes] + if: github.event_name != 'pull_request' || needs.changes.outputs.code == 'true' runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -88,6 +120,8 @@ jobs: # ───────────────────────────────────────────────────────────────────── android-lint: name: Android Lint — Static Analysis + needs: [changes] + if: github.event_name != 'pull_request' || needs.changes.outputs.code == 'true' runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -125,6 +159,8 @@ jobs: # ───────────────────────────────────────────────────────────────────── unit-tests: name: Unit & Integration Tests + needs: [changes] + if: github.event_name != 'pull_request' || needs.changes.outputs.code == 'true' runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -162,7 +198,8 @@ jobs: # ───────────────────────────────────────────────────────────────────── build: name: Build Debug APK - needs: [ktlint, android-lint, unit-tests] + needs: [changes, ktlint, android-lint, unit-tests] + if: github.event_name != 'pull_request' || needs.changes.outputs.code == 'true' runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -204,7 +241,8 @@ jobs: # ───────────────────────────────────────────────────────────────────── release-compile: name: Release Compile Check - needs: [ktlint, android-lint, unit-tests] + needs: [changes, ktlint, android-lint, unit-tests] + if: github.event_name != 'pull_request' || needs.changes.outputs.code == 'true' runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -236,6 +274,8 @@ jobs: # ───────────────────────────────────────────────────────────────────── instrumented-tests: name: Instrumented Tests + needs: [changes] + if: github.event_name != 'pull_request' || needs.changes.outputs.code == 'true' runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -299,7 +339,7 @@ jobs: # ───────────────────────────────────────────────────────────────────── ci-summary: name: CI Summary - needs: [ktlint, android-lint, unit-tests, build, release-compile] + needs: [changes, ktlint, android-lint, unit-tests, build, release-compile] runs-on: ubuntu-latest timeout-minutes: 2 if: always() @@ -323,7 +363,7 @@ jobs: name="${entry%%:*}" result="${entry#*:}" echo "::notice::$name = $result" - if [[ "$result" != "success" ]]; then + if [[ "$result" != "success" && "$result" != "skipped" ]]; then FAILED=1 FAILED_JOBS+="$name " fi diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fd4acdd0..f1c19e7b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -3,8 +3,34 @@ name: "CodeQL Analysis" on: push: branches: [ "main", "dev" ] + paths-ignore: + - '**.md' + - 'docs/**' + - '.github/PULL_REQUEST_TEMPLATE.md' + - '.github/workflows/pr-labeler.yml' + - '.github/workflows/stale.yml' + - '.github/workflows/merge-conflict-detector.yml' + - 'LICENSE' + - 'fastlane/**' + - '.gitignore' + - '.editorconfig' + - '.envrc' + - '*.html' pull_request: branches: [ "main", "dev" ] + paths-ignore: + - '**.md' + - 'docs/**' + - '.github/PULL_REQUEST_TEMPLATE.md' + - '.github/workflows/pr-labeler.yml' + - '.github/workflows/stale.yml' + - '.github/workflows/merge-conflict-detector.yml' + - 'LICENSE' + - 'fastlane/**' + - '.gitignore' + - '.editorconfig' + - '.envrc' + - '*.html' schedule: - cron: '30 3 * * 1' # Runs at 03:30 UTC every Monday