Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.*.dart linguist-generated=true
47 changes: 18 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,60 @@ jobs:
strategy:
matrix:
package:
- benchmarks/
- packages/freezed
- packages/freezed/example
- packages/freezed_annotation
- packages/freezed_lint
- packages/freezed_lint/example
channel:
- master
- stable
dependencies:
- get
- downgrade
exclude:
- channel: stable
- channel: master
dependencies: downgrade
- package: packages/freezed_lint
channel: stable

defaults:
run:
working-directory: ${{ matrix.package }}

steps:
- uses: actions/checkout@v5

- uses: subosito/flutter-action@v2
with:
channel: ${{ matrix.channel }}
cache: ${{ matrix.channel == 'stable' }}

# It is executed separately
- name: Removing example folder
# Retain example for lint golden test
if: matrix.package != 'packages/freezed_lint'
run: rm -rf example
working-directory: ${{ matrix.package }}
cache: ${{ matrix.channel == 'master' }}

- name: Install dependencies
run: |
flutter pub ${{ matrix.dependencies }}
working-directory: ${{ matrix.package }}
run: flutter pub ${{ matrix.dependencies }}

- name: Check format
# Check dart format only on stable
if: matrix.channel == 'stable'
run: dart format --set-exit-if-changed .
working-directory: ${{ matrix.package }}

- name: Generate
run: |
if grep -q build_runner "pubspec.yaml"; then
dart pub run build_runner build --delete-conflicting-outputs
fi
working-directory: ${{ matrix.package }}
if: matrix.package != 'packages/freezed_lint/example'
continue-on-error: true
run: dart run build_runner build --delete-conflicting-outputs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
run: dart run build_runner build --delete-conflicting-outputs
run: dart run build_runner build

I believe that flag is now deprecated, but I'm also coming back to dart after a hiatus, so maybe I'm wrong about that.


Comment on lines +56 to 59
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Gate codegen on dependency; drop continue-on-error.

Instead of relying on continue-on-error, conditionally run build_runner only when declared. This avoids masking real failures on packages that should generate code.

-      - name: Generate
-        if: matrix.package != 'packages/freezed_lint/example'
-        continue-on-error: true
-        run: dart run build_runner build --delete-conflicting-outputs
+      - name: Generate
+        if: matrix.package != 'packages/freezed_lint/example'
+        run: |
+          if grep -Eq '^\s*build_runner\s*:' pubspec.yaml; then
+            dart run build_runner build --delete-conflicting-outputs
+          else
+            echo "Skipping build_runner (no dependency found)"
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if: matrix.package != 'packages/freezed_lint/example'
continue-on-error: true
run: dart run build_runner build --delete-conflicting-outputs
- name: Generate
if: matrix.package != 'packages/freezed_lint/example'
run: |
if grep -Eq '^\s*build_runner\s*:' pubspec.yaml; then
dart run build_runner build --delete-conflicting-outputs
else
echo "Skipping build_runner (no dependency found)"
fi
🤖 Prompt for AI Agents
In .github/workflows/build.yml lines 56-59, the step currently uses a simple
matrix.package check and continue-on-error to avoid failing runs; instead remove
continue-on-error and gate the run with an explicit condition that only selects
packages that declare codegen (e.g., detect packages that list
build_runner/build_* in dev_dependencies or include a build.yaml) — implement
this by adding a prior job/step that scans package/pubspec.yaml files and emits
an output (a list or map) of packages requiring codegen, then change the step's
if to check membership (for example using
contains(needs.scan.outputs.packages_with_codegen, matrix.package)) and keep
run: dart run build_runner build --delete-conflicting-outputs so failures
surface for packages that should generate code.

- name: Analyze
run: flutter analyze
run: flutter analyze --fatal-infos
working-directory: ${{ matrix.package }}

- name: Run tests
run: |
if grep -q "name: example" "pubspec.yaml"; then
if grep -q "flutter_test:" "pubspec.yaml"; then
flutter test
else
elif grep -q "test:" "pubspec.yaml"; then
dart test
fi
working-directory: ${{ matrix.package }}

- name: Lint golden test
if: matrix.package == 'packages/freezed_lint'
run: |
dart pub get
dart analyze
dart run custom_lint
working-directory: 'packages/freezed_lint/example'
if: matrix.package == 'packages/freezed_lint/example'
run: dart run custom_lint --fatal-infos
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.dart_tool
.idea/
*.iml
build/
node_modules
/package-lock.json
/package-lock.json
3 changes: 0 additions & 3 deletions benchmarks/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/.dart_tool
/test/**/*.g.dart
/test/**/*.freezed.dart
.packages
# Remove the following pattern if you wish to check in your lock file
pubspec.lock
4 changes: 1 addition & 3 deletions benchmarks/lib/src/copy_with.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ abstract class Model with _$Model {

@freezed
abstract class ModelWrapper with _$ModelWrapper {
factory ModelWrapper({
required Model model,
}) = _ModelWrapper;
factory ModelWrapper({required Model model}) = _ModelWrapper;
}

void main(List<String> arguments) {
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/lib/src/copy_with.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions benchmarks/lib/src/equal.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 6 additions & 14 deletions benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
name: example
name: freezed_benchmarks
description: A new Flutter project.
publish_to: none

environment:
sdk: ^3.5.0

resolution: workspace

dependencies:
flutter:
sdk: flutter
freezed_annotation:
path: ../packages/freezed_annotation
json_annotation: ^4.4.0
freezed_annotation: ^3.0.0
json_annotation: ^4.9.0

dev_dependencies:
freezed:
path: ../packages/freezed
freezed: ^3.0.2
json_serializable: ^6.1.3
build_runner:
flutter_test:
sdk: flutter

dependency_overrides:
freezed:
path: ../packages/freezed
freezed_annotation:
path: ../packages/freezed_annotation
3 changes: 0 additions & 3 deletions packages/freezed/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/.dart_tool
/test/**/*.g.dart
/test/**/*.freezed.dart
.packages
# Remove the following pattern if you wish to check in your lock file
pubspec.lock
5 changes: 4 additions & 1 deletion packages/freezed/build.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
targets:
$default:
sources:
exclude:
- example/*

builders:
freezed:
enabled: true
generate_for:
exclude:
- example
- test/source_gen_src.dart
include:
- test/*
Expand Down
3 changes: 0 additions & 3 deletions packages/freezed/example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
*.freezed.dart
*.g.dart

Comment on lines -1 to -3
Copy link
Owner

Choose a reason for hiding this comment

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

Why did you change gitignores?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's been a while, I honestly don't remember.

Copy link
Contributor Author

@lishaduck lishaduck Sep 3, 2025

Choose a reason for hiding this comment

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

Oh, I remember now. This was in the example, if the code wasn't checked in the order that CI ran tripped something up. c5d83a7

Probably not strictly needed anymore, but feels like a nice QoL improvement?

# Miscellaneous
*.class
*.log
Expand Down
Loading
Loading