# Add GitHub Actions CI to a Flutter App

Yes. An agent adds a workflow that runs flutter analyze and flutter test on every push and PR of your Flutter app, pinned to your SDK version, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-github-actions-ci/flutter/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads what the app already runs before it writes a workflow, because the wrong SDK version or a test that needs a simulator makes CI red on the first run. In an app shaped like simplezhli/flutter_deer, `pubspec.yaml` asks for Dart `>=3.4.0 <4.0.0` and Flutter `>=3.19.0`, turns on `generate: true` for the `l10n.yaml` localizations in `lib/l10n`, and lists `flutter_test`, `flutter_driver`, `integration_test` and `test` under dev dependencies. `.github/workflows/flutter-drive.yml` already exists but runs only `flutter drive` on a macOS runner with an iPhone simulator, pinned to Flutter 3.47.4, and `flutter-web-deploy.yml` triggers on a file name that does not exist, so no push ever runs `flutter analyze` or `flutter test`.

The tests that can run on Linux are in `test/`: `widget_test.dart` pumps `MessagePage`, `net/dio_test.dart` calls the GitHub API through `DioUtils` and so depends on the network, and `accessibility_test.dart` gathers eight per-module files that check tap-target semantics with `meetsGuideline(labeledTapTargetGuideline)` under `MyApp` and the `ThemeProvider` theme. `analysis_options.yaml` enables `strict-casts` and `strict-inference`. `test_driver/` and `integration_test/` need a device and stay with the existing macOS workflow.

The agent adds `.github/workflows/ci.yml` on `push` and `pull_request` with one `ubuntu-latest` job: `actions/checkout`, `subosito/flutter-action` with the same `3.47.4` the drive workflow pins and `cache: true`, `flutter pub get`, `flutter gen-l10n` so `deer_localizations.dart` exists before analysis, `flutter analyze`, and `flutter test --exclude-tags network` after tagging `dio_test.dart` with a `network` tag in a new `dart_test.yaml`, so a GitHub API hiccup cannot fail the build. A second job runs `flutter build web` to prove the web target still compiles, since the repository deploys it. A `concurrency` group cancels superseded runs on the same branch.

Before pushing, the agent installs that Flutter version in the sandbox and runs the same commands, so an analyzer finding that was never checked in CI, or a widget test that needs a font or asset, is fixed or reported in the pull request rather than discovered on the first red run. It adds a badge for the new workflow next to the existing text in `README.md` and `README-EN.md`.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add GitHub Actions CI to this Flutter app and open a pull request. Read pubspec.yaml, l10n.yaml, analysis_options.yaml, .github/workflows/flutter-drive.yml, .github/workflows/flutter-web-deploy.yml, test/widget_test.dart, test/accessibility_test.dart, test/net/dio_test.dart and README-EN.md first. Add .github/workflows/ci.yml on push and pull_request with an ubuntu-latest job that checks out, sets up Flutter with subosito/flutter-action at the version the drive workflow pins with caching, runs flutter pub get, flutter gen-l10n, flutter analyze and flutter test excluding a network tag, and a second job that runs flutter build web. Add dart_test.yaml and tag test/net/dio_test.dart as network. Add a concurrency group that cancels superseded runs. Leave the drive and web deploy workflows as they are. Install the same Flutter version in the sandbox, run the same commands, fix any analyzer finding or test setup problem you can and list what you could not, paste the output in the pull request, and add a badge to README.md and README-EN.md. Do not change application code beyond what the analyzer requires.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request with `.github/workflows/ci.yml`, a `dart_test.yaml` with the `network` tag, a one-line `@Tags` annotation on `test/net/dio_test.dart`, and a badge line in both READMEs. The description shows the output of `flutter analyze` and `flutter test --exclude-tags network` from the sandbox on Flutter 3.47.4, with the count of tests found and any analyzer finding it fixed.

Because the workflow runs on `pull_request`, the pull request that adds it is its first run, so the reviewer sees the analyze, test and web build jobs on the pull request itself. The existing `flutter_deer driver` workflow still runs on macOS beside it.

A reviewer checks that the pinned Flutter version matches the one the team develops on, that the network-tagged test is the only one excluded, that `flutter gen-l10n` runs before `flutter analyze` so the generated localizations resolve, and that the web build job does not need secrets. Then they make the new checks required on the default branch.

## Run it on every Flutter repository without an analyze-and-test workflow

A script on your server lists repositories through `GET /o/{org}/github`, checks each `pubspec.yaml` for a `flutter` dependency and each `.github/workflows` for a job that runs `flutter test`, and sends one `POST /o/{org}/sessions` per repository that has none, with that repository in `resources`. Each run reads its own `pubspec.yaml` and existing workflows, so an app that pins a different SDK or has no tests yet gets a workflow that fits it, and each opens its own pull request.

Give the API key a `webhook_url` and Rush POSTs `run.completed` when each turn ends, with the `session_url` to read the pull request from.

## Why run it on Rush?

Flutter CI fails for setup reasons more than code reasons: the SDK version, a generated file that is not checked in, a test that quietly calls the network. In a Rush sandbox the agent installs the exact SDK the repository pins, runs `gen-l10n`, `analyze` and `test` before it pushes, and keeps every command and its output in the run's record, so the workflow it proposes has already passed once.

The existing drive workflow needs a macOS runner and a simulator, so nobody wanted to add a second slow job by hand. The agent adds the fast Linux job that catches analyzer and widget failures in minutes, and the same request works unchanged on every Flutter app a team owns.

## Frequently asked questions

### Will it change the existing driver workflow?

No. `flutter-drive.yml` keeps running `flutter drive` on macOS with the iPhone simulator. The new `ci.yml` only adds the Linux `analyze`, `test` and `build web` jobs that need no device.

### Why exclude the dio test?

`test/net/dio_test.dart` sets the base URL to `api.github.com` and makes a real request, so it fails when the runner is rate limited or offline. Tagging it `network` in `dart_test.yaml` keeps it runnable locally with `flutter test` and out of the required check.

### Which Flutter version does it pin?

The one the repository already pins in `flutter-drive.yml`, 3.47.4, so both workflows test the same SDK. If `pubspec.yaml` later raises the constraint, the version is one line to change in each file.

### Do the accessibility tests run in CI?

Yes. `test/accessibility_test.dart` and its per-module files are widget tests that pump pages under `MyApp` and check semantics, so they run on `ubuntu-latest` with `flutter test`. The agent runs them in the sandbox first and reports any page that fails a guideline.

## More Flutter jobs

- [Add i18n to a Flutter App](https://getrush.ai/run/add-i18n/flutter/)
- [Add Integration Tests to a Flutter App](https://getrush.ai/run/add-integration-tests/flutter/)
- [Add Local Notifications to a Flutter App](https://getrush.ai/run/add-local-notifications/flutter/)

## The same job on other stacks

- [Set Up GitHub Actions CI for a Gatsby Site](https://getrush.ai/run/add-github-actions-ci/gatsby/)
- [Set Up GitHub Actions CI for a Hono Worker](https://getrush.ai/run/add-github-actions-ci/hono/)
- [Add GitHub Actions CI to a Leptos App](https://getrush.ai/run/add-github-actions-ci/leptos/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
