Menu

PR Checks Workflow

Relevant source files

Purpose and Scope

This document details the automated checks that run on pull requests (PRs) in the Flutter Mobile Project Template. The PR Checks Workflow helps maintain code quality, prevent regressions, and ensure the codebase follows established standards through a series of automated validations. For information about general CI/CD configurations, see CI/CD and Automation.

Overview

The PR Checks Workflow is implemented as a GitHub Actions workflow that executes whenever a pull request is created or updated. The system performs targeted checks based on the types of files modified in the PR, optimizing CI time by only running relevant validations.

Sources: .github/workflows/check-pr.yaml1-175 .github/workflows/wc-changes.yml1-83

File Change Detection

The workflow begins by detecting which types of files have been changed in the PR and categorizes them to determine which checks should run.

Sources: .github/workflows/wc-changes.yml41-82

The file categorization system works as follows:

CategoryFile TypesTriggers
actionsGitHub Actions workflows and configurationscheck-actions job
genDart files, YAML files, pubspec.lockdiff-gen job
lintDart files, YAML files, pubspec.lockcustom-lint job
markdownMarkdown (.md) filesmarkdown job
srcDart files, YAML files, pubspec.lock, scriptscheck job
dependenciesRequires dependency resolution based on changescache-dependencies job

Sources: .github/workflows/wc-changes.yml46-67

Check Jobs

Skip Comment

If no relevant files were changed in the PR, the workflow posts a comment indicating that checks were skipped.

Sources: .github/workflows/check-pr.yaml14-30

Check Actions

Validates GitHub Actions workflows using actionlint to ensure they're correctly configured.

Sources: .github/workflows/check-pr.yaml31-49

Cache Dependencies

Sets up the Flutter runtime environment and caches dependencies to speed up subsequent jobs.

Sources: .github/workflows/check-pr.yaml51-64 .github/actions/setup-application-runtime/action.yaml1-27

Check

Performs static analysis, code formatting checks, and tests on the codebase.

Sources: .github/workflows/check-pr.yaml65-114

Custom Lint

Runs custom lint checks to enforce project-specific coding standards.

Sources: .github/workflows/check-pr.yaml117-142

Diff-Gen

Verifies that generated code is up to date by regenerating it and checking for differences.

Sources: .github/workflows/check-pr.yaml143-148 .github/workflows/wc-check-diff.yaml1-38

Markdown

Validates markdown files for proper formatting and broken links.

Sources: .github/workflows/check-pr.yaml158-161

Status Check

Aggregates the results of all checks. If any check fails, this job fails, preventing the PR from being merged.

Sources: .github/workflows/check-pr.yaml163-174

Environment Setup Process

The workflow relies on a reusable action called setup-application-runtime to configure the development environment:

Sources: .github/actions/setup-application-runtime/action.yaml1-27

Source Code Analysis Tools

The workflow employs several tools to analyze code quality:

ToolPurposeConfiguration
Dart AnalyzerStatic analysisFatal on infos
Flutter FormatCode formattingChecks for formatting issues
Test ReporterTest resultsReports test outcomes from JSON files
actionlintGitHub Actions validationIgnores SC2153
Custom LintProject-specific rulesUses problem matcher for better reporting

Sources: .github/workflows/check-pr.yaml82-86 .github/workflows/check-pr.yaml87-88 .github/workflows/check-pr.yaml106-114 .github/workflows/check-pr.yaml42-49 .github/workflows/check-pr.yaml133-141

Integration with Pull Requests

The workflow integrates with GitHub's pull request system in several ways:

  1. Skip notification: Posts a comment when no checks were needed
  2. Review comments: Adds inline review comments for code issues
  3. Status checks: Updates PR status based on check results
  4. Test reports: Shows test outcomes directly in the PR

Sources: .github/workflows/check-pr.yaml23-29 .github/workflows/check-pr.yaml106-114 .github/workflows/check-pr.yaml163-174

Concurrency Management

The workflow uses GitHub Actions' concurrency features to ensure that only one instance of the workflow runs at a time for a given PR, automatically canceling any in-progress workflows when new commits are pushed.

concurrency:
  group: check-pr-${{ github.ref }}
  cancel-in-progress: true

Sources: .github/workflows/check-pr.yaml6-8

The PR Checks Workflow works alongside other GitHub workflows in the repository:

  • Firebase Hosting Preview: Deploys preview environments for PRs
  • Issue and PR Management: Handles labeling and assignment
  • Project Initialization: Sets up new repositories from the template

For more information on these workflows, see Issue and PR Management and Project Initialization.

Sources: .github/workflows/firebase-hosting-pull-request.yaml1-52