Skip to content

chore: ignore non-code files from triggering builds#3176

Merged
marcnause merged 1 commit into
fossasia:flutterfrom
rahul31124:ci_non_code_file
Apr 12, 2026
Merged

chore: ignore non-code files from triggering builds#3176
marcnause merged 1 commit into
fossasia:flutterfrom
rahul31124:ci_non_code_file

Conversation

@rahul31124

@rahul31124 rahul31124 commented Apr 12, 2026

Copy link
Copy Markdown
Member

Fixes #3168

Changes

Previously, paths-ignore was used to skip CI builds for documentation and media files.
Since Android and iOS builds are marked as required checks, skipping these jobs meant no status was reported, which blocked the Merge button even for documentation-only PRs.

Solution

Added a Detect Changes gatekeeper job that checks the PR diff.
Instead of skipping the workflow, heavy build/test steps are skipped for non-code changes while still reporting successful CI checks.

How It Works

Detect Changes Logic

The Detect Changes job determines whether a PR contains code changes or only documentation/media files.

  1. Git Diff Check

    • Runs git diff --name-only between the PR base SHA and head SHA.
    • This checks the entire PR change, even if it contains multiple commits.
  2. Filtering Non-Code Files
    The file list is filtered using grep:

    • Extension filter: removes files like .md, .png, .jpg, .svg, .txt, .arb
    • Path filter: removes files inside the docs/ directory
  3. Decision

    • If files remain → is_code = true (code changes detected)
    • If nothing remains → is_code = false (documentation/media only)

CI Workflow Behavior

  • Doc-only changes

    • Build and test steps are skipped
    • CI finishes in a few seconds
  • Code changes

    • Full CI pipeline runs
  • Mixed changes

    • Full CI pipeline runs

Result

I tested the changes in my fork: rahul31124#35

The CI workflow runs successfully and required checks are reported correctly.
Documentation-only changes now skip heavy build steps while still completing the required CI jobs.

As a result, PR #3150 can now be merged.

Screenshots / Recordings

N/A

Checklist:

  • No hard coding: I have used values from constants.dart or localization files instead of hard-coded values.
  • No end of file edits: No modifications done at end of resource files.
  • Code reformatting: I have formatted the code using dart format or the IDE formatter.
  • Code analysis: My code passes checks run in flutter analyze and tests run in flutter test.

Summary by Sourcery

Introduce a change-detection gate in the pull request workflow so required CI jobs always report status while heavy build steps are skipped for non-code changes.

Build:

  • Replace pull_request paths-ignore filters with a Detect Changes job that classifies PRs as code vs non-code changes and exposes this via a workflow output.

CI:

  • Condition all platform build and screenshot jobs on the Detect Changes result so code changes run full builds while documentation/media-only PRs complete quickly with lightweight no-op steps.

Summary by Sourcery

Introduce a change-detection gate in the pull request workflow so required CI jobs always report status while heavy platform builds are skipped for non-code changes.

Build:

  • Replace pull_request paths-ignore filters with a Detect Changes job that classifies PRs as code vs non-code changes and exposes this via a workflow output.

CI:

  • Condition all platform build and screenshot jobs on the change-detection output so code changes run full builds while documentation/media-only PRs complete quickly with lightweight no-op steps.

@sourcery-ai

sourcery-ai Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR replaces the previous paths-ignore-based skipping of pull_request workflows with an explicit Detect Changes job that classifies PRs as code vs non-code changes, then conditions all build and screenshot jobs (and their runners) on that result so required checks always report while heavy work is skipped for documentation/media-only PRs.

Sequence diagram for PR-triggered CI with Detect Changes gate

sequenceDiagram
  actor Dev
  participant GitHub
  participant BuildWorkflow
  participant ChangesJob as "changes job"
  participant CommonJob as "common job"
  participant PlatformJobs as "platform and screenshot jobs"

  Dev->>GitHub: Open or update pull request
  GitHub->>BuildWorkflow: Trigger pull_request workflow
  BuildWorkflow->>ChangesJob: Run Detect Changes job
  ChangesJob->>ChangesJob: git diff base_sha head_sha
  ChangesJob->>ChangesJob: Filter non-code extensions and docs/
  ChangesJob-->>BuildWorkflow: Output is_code true or false

  alt is_code == true (code changes)
    BuildWorkflow->>CommonJob: Run Common Build job
    CommonJob-->>BuildWorkflow: Artifacts and shared setup
    BuildWorkflow->>PlatformJobs: Run Android/iOS/desktop builds and screenshots
  else is_code != true (non-code changes)
    BuildWorkflow->>CommonJob: Job runs but heavy steps are skipped
    BuildWorkflow->>PlatformJobs: Run lightweight Non-Code Change steps
  end

  PlatformJobs-->>GitHub: Report required check statuses
  GitHub-->>Dev: Enable Merge button once all checks succeed
Loading

Flow diagram for Detect Changes gate logic

flowchart TD
  Start[Start Detect Changes job]
  Checkout[Checkout repository with full history]
  Diff[Run git diff --name-only base_sha head_sha]
  FilterExt[Filter out non-code extensions md/png/jpg/jpeg/gif/svg/webp/txt/arb]
  FilterDocs[Filter out files under docs/]
  AnyFiles{Any files left?}
  IsCodeTrue[Set is_code output to true]
  IsCodeFalse[Set is_code output to false]
  End[End Detect Changes job]

  Start --> Checkout --> Diff --> FilterExt --> FilterDocs --> AnyFiles
  AnyFiles -- Yes --> IsCodeTrue --> End
  AnyFiles -- No --> IsCodeFalse --> End
Loading

File-Level Changes

Change Details Files
Introduce a Detect Changes gatekeeper job to classify PRs as code vs non-code based on git diff output.
  • Add a changes job that checks out the repo with full history and diffs between the pull request base and head SHAs.
  • Filter the changed file list via grep to exclude documentation/media extensions and the docs/ directory.
  • Set an is_code output on the job indicating whether any code files remain after filtering.
.github/workflows/pull-request.yml
Condition the common build job and its steps on the Detect Changes result while preserving required check reporting.
  • Declare the common job as needing the changes job so it has access to the is_code output.
  • Guard checkout, common workflow, PR-number artifact creation, and artifact upload steps with is_code == 'true'.
  • Add a lightweight Non-Code Change step that runs when is_code is not true so the job still completes successfully for doc-only PRs.
.github/workflows/pull-request.yml
Wire Android, iOS, desktop, and screenshot jobs to the Detect Changes gate and adjust runners to be lightweight for non-code changes.
  • Update all platform build and screenshot jobs to depend on the changes job (and common where required) and gate their existing steps on is_code == 'true'.
  • Introduce Non-Code Change echo steps in each job to ensure they succeed quickly when there are only documentation/media changes.
  • Condition the runs-on labels using the is_code output so expensive macOS/Windows/ARM runners are only used for code changes while doc-only runs execute on ubuntu-latest where possible.
  • Remove the pull_request paths-ignore configuration so the workflow always runs and required checks always receive a status.
.github/workflows/pull-request.yml

Assessment against linked issues

Issue Objective Addressed Explanation
#3168 Ensure the pull_request CI workflow is triggered even when a PR contains only documentation/media files (e.g., .md) instead of being skipped by path-based filters.
#3168 Ensure required platform checks (notably Android and iOS build jobs) report a successful status for documentation-only PRs so that such PRs can be merged via the GitHub web interface.

Possibly linked issues

  • #unknown: PR removes paths-ignore behavior by adding a Detect Changes job, ensuring required Android/iOS checks report on MD-only PRs.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@rahul31124 rahul31124 requested a review from marcnause April 12, 2026 13:16

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The repeated Non-Code Change steps and if: needs.changes.outputs.is_code == 'true' guards in every job could be simplified by using job-level if: conditions (e.g. one job for code changes and a lightweight, shared no-op job for non-code PRs), which would reduce duplication and make the workflow easier to maintain.
  • Instead of dynamically switching runs-on between platform-specific runners and ubuntu-latest for non-code changes, consider using a single appropriate runner per job plus a job-level if to skip the entire job when is_code is false, which keeps the workflow more readable and avoids unnecessary indirection in runs-on expressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The repeated `Non-Code Change` steps and `if: needs.changes.outputs.is_code == 'true'` guards in every job could be simplified by using job-level `if:` conditions (e.g. one job for code changes and a lightweight, shared no-op job for non-code PRs), which would reduce duplication and make the workflow easier to maintain.
- Instead of dynamically switching `runs-on` between platform-specific runners and `ubuntu-latest` for non-code changes, consider using a single appropriate runner per job plus a job-level `if` to skip the entire job when `is_code` is false, which keeps the workflow more readable and avoids unnecessary indirection in `runs-on` expressions.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions

Copy link
Copy Markdown
Contributor

Build Status

Build successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/24307619242/artifacts/6392925986.

Screenshots

Android Screenshots
iPhone Screenshots
iPad Screenshots

@marcnause marcnause merged commit 04c2089 into fossasia:flutter Apr 12, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI does not run required steps if PR contains only MD files

2 participants