Menu

CI/CD and Automation

Relevant source files

This document provides a comprehensive overview of the continuous integration (CI), continuous deployment (CD), and automation tools implemented in the Flutter Mobile Project Template. These systems ensure code quality, streamline development workflows, and automate repetitive tasks throughout the development lifecycle.

Overview

The template includes several automated workflows that handle various aspects of the development process:

  1. Pull Request Validation - Automated checks that run on pull requests to ensure code quality
  2. Issue and PR Management - Automated labeling and reviewer assignment
  3. Project Initialization - Automated setup when creating a new project from this template
  4. Preview Deployments - Automated deployment of previews for pull requests

The diagram below illustrates the high-level CI/CD architecture:

Sources: .github/workflows/check-pr.yaml .github/workflows/auto-assign.yaml .github/workflows/initialization.yaml .github/workflows/firebase-hosting-pull-request.yaml

Pull Request Validation

The template includes a robust pull request validation system that automatically runs various checks based on the files changed in the PR.

Change Detection and Selective Testing

The workflow first detects which files have been changed and only runs the necessary checks, optimizing CI performance.

Sources: .github/workflows/check-pr.yaml10-20 .github/workflows/wc-changes.yml

Static Analysis and Testing

When source files are changed, the workflow runs static analysis and tests:

  1. Static Analysis - Uses Dart Analyzer to check for issues
  2. Format Check - Ensures code follows consistent formatting
  3. Circular Dependencies - Checks for circular package dependencies
  4. Unit Tests - Runs tests and generates a report

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

Custom Lint

For changes to lintable files, the workflow runs custom lint checks and reports any issues as PR comments.

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

Generated Code Verification

When files that affect code generation are changed, the workflow regenerates the code and verifies that the checked-in generated code is up-to-date.

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

GitHub Actions Validation

For changes to GitHub Actions or workflow files, the workflow runs actionlint to validate the syntax and configuration.

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

Markdown Validation

For changes to Markdown files, the workflow runs checks to ensure they follow the project's standards.

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

Issue and PR Management

The template includes several automation features for managing issues and pull requests.

Automatic PR Labeling

Pull requests are automatically labeled based on which files they change, using a pre-defined set of labels.

The labels are defined in .github/labels.yml and the path patterns are defined in .github/labeler.yml.

Sources: .github/workflows/labeler.yml .github/labels.yml .github/labeler.yml

Reviewer Assignment

When a pull request is created or moved from draft to ready, the auto-assign.yaml workflow automatically:

  1. Checks if the PR already has reviewers
  2. If not, assigns configured reviewers from repository variables
  3. Assigns the PR author as the assignee
  4. Adds a "Ready for review" comment

Sources: .github/workflows/auto-assign.yaml

Project Initialization

When a new repository is created from this template, the initialization.yaml workflow automatically runs to set up the project.

The initialization process:

  1. Creates initial issues to guide setup
  2. Cleans up GitHub Copilot settings
  3. Removes sample code
  4. Removes files only needed for the template (not for derived projects)
  5. Updates project name references
  6. Commits and pushes all changes

Sources: .github/workflows/initialization.yaml removal_list_on_use_template.txt .github/actions/cleanup-samples/action.yaml

Preview Deployments

For pull requests that don't modify the main app code, the template automatically deploys a preview version to Firebase Hosting.

This allows reviewers to see visual changes (especially to the component catalog) without having to check out and build the code locally.

Sources: .github/workflows/firebase-hosting-pull-request.yaml

Application Runtime Setup

Several workflows depend on a shared action that sets up the application runtime. This action:

  1. Uses mise to install the correct Flutter version
  2. Sets up Dart pub cache environment variables
  3. Activates and bootstraps Melos for mono-repo management

This shared setup ensures consistent behavior across different workflows.

Sources: .github/actions/setup-application-runtime/action.yaml

Conclusion

The CI/CD and automation systems in the Flutter Mobile Project Template provide:

  1. Quality Assurance - Ensures code quality through automated checks
  2. Efficiency - Optimizes workflows by only running necessary checks
  3. Consistency - Enforces project standards and practices
  4. Productivity - Automates repetitive tasks

For more specific information about individual workflows, refer to: