WIP - Implement code freeze mechanism at autosubmit#4998
Conversation
| this, | ||
| cache, | ||
| ); | ||
| final codeFreezeFile = File( |
There was a problem hiding this comment.
This only happens at boot time - what do you think about using something like DynamicConfig?
code: https://github.com/flutter/cocoon/blob/main/app_dart/lib/src/service/flags/dynamic_config.dart
e.g. usage (the fetcher reads from github HEAD every 5 minutes, so no code push needed):
cocoon/app_dart/bin/gae_server.dart
Lines 48 to 50 in ccfc427
There's no file reading there either; we use build hooks to codify the config at compile time.
There was a problem hiding this comment.
Updated, is this more what you were thinking? :)
|
More to think about: how many PRs are merged with the merge button vs using autosubmit? A label that only blocks autosubmit will not prevent PRs from landing. I do like the frozen paths, but honestly - a workflow that fails if the path is modified would ensure you do not land anything since it will be "failing" for those paths. Autosubmit should respect that. |
Yeah, definitely room for folks to still sneak in, even though we don't want people to use the merge button. Do you mean we should maybe do both this and the presubmit check from the analyzer? |
| extension _YamlMapToMap on YamlMap { | ||
| Map<String, dynamic> get asMap => <String, dynamic>{ | ||
| for (final MapEntry(:key, :value) in entries) | ||
| if (value is YamlMap) | ||
| '$key': value.asMap | ||
| else if (value is YamlList) | ||
| '$key': value.asList | ||
| else if (value is YamlScalar) | ||
| '$key': value.value | ||
| else | ||
| '$key': value, | ||
| }; | ||
| } | ||
|
|
||
| extension _YamlListToList on YamlList { | ||
| List<dynamic> get asList => <dynamic>[ | ||
| for (final node in nodes) | ||
| if (node is YamlMap) | ||
| node.asMap | ||
| else if (node is YamlList) | ||
| node.asList | ||
| else if (node is YamlScalar) | ||
| node.value | ||
| else | ||
| node, | ||
| ]; | ||
| } |
There was a problem hiding this comment.
This was older code that I think can be deleted... but I could be wrong if Map<String, dynamic>.from(yamlMap) doesn't handle children.
| frozenLabels: | ||
| (json['frozen_labels'] as List<dynamic>?) | ||
| ?.map((e) => e as String) | ||
| .toSet() ?? |
There was a problem hiding this comment.
the fact that json serializable auto handled this as a "toSet()" is awesome.
|
Closing in favor of a workflow |
This PR introduces a new GitHub Actions workflow to enforce a temporary code freeze on core Material and Cupertino directories. Implements #184093 (instead of flutter/cocoon#4998) Any pull request attempting to modify files in the frozen paths will trigger a failing check, providing authors with clear instructions on how to proceed if they have a critical emergency fix. Frozen Paths Included (everything that will be moving over to flutter/packages): - Core Library - `packages/flutter/lib/src/material/` - `packages/flutter/lib/src/cupertino/` - Tests - `packages/flutter/test/material/` - `packages/flutter/test/cupertino/` - API Examples - `examples/api/lib/material/` - `examples/api/lib/cupertino/` - `examples/api/test/material/` - `examples/api/test/cupertino/` - Fix Data - `packages/flutter/lib/fix_data/fix_cupertino.yaml` - `packages/flutter/lib/fix_data/fix_material/` - `packages/flutter/test_fixes/material/` - `packages/flutter/test_fixes/cupertino/` Trigger Logic: - Target branch: master - Events: opened, reopened, synchronize, and ready_for_review - The workflow only executes if changes are detected within the specified directories. Override is possible with a label for emergencies, or necessary work we will land in service of decoupling during the freeze. #### 🛡️ Catching Existing PRs To ensure this freeze is applied to exiting pull requests, we can add this as a Required Status Check in a branch protection rule. <details><summary>How to enable Required Status Check</summary> 1. Go to the repository Settings on GitHub. 2. Select Branches from the left sidebar. 3. Find the branch protection rule for master and click Edit. 4. Enable "Require status checks to pass before merging". 5. Search for the new check name: "Check Code Freeze" and add it to the required list. 6. Click Save changes. </details> How this affects open PRs: Once the check is required: - Existing PRs opened before this workflow will be blocked from merging because the "Check Code Freeze" status will be missing or failed. - Authors of open PRs can trigger the check by: - Pushing a new commit (even a trivial one). - Closing and reopening the PR. - If the PR is a draft, marking it as "Ready for Review". - GitHub evaluates the entire diff of the PR. If an existing PR contains changes to packages/flutter/lib/src/material/, the workflow will trigger and fail the moment the PR is updated, regardless of when the original Material changes were pushed. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This PR introduces a new GitHub Actions workflow to enforce a temporary code freeze on core Material and Cupertino directories. Implements flutter#184093 (instead of flutter/cocoon#4998) Any pull request attempting to modify files in the frozen paths will trigger a failing check, providing authors with clear instructions on how to proceed if they have a critical emergency fix. Frozen Paths Included (everything that will be moving over to flutter/packages): - Core Library - `packages/flutter/lib/src/material/` - `packages/flutter/lib/src/cupertino/` - Tests - `packages/flutter/test/material/` - `packages/flutter/test/cupertino/` - API Examples - `examples/api/lib/material/` - `examples/api/lib/cupertino/` - `examples/api/test/material/` - `examples/api/test/cupertino/` - Fix Data - `packages/flutter/lib/fix_data/fix_cupertino.yaml` - `packages/flutter/lib/fix_data/fix_material/` - `packages/flutter/test_fixes/material/` - `packages/flutter/test_fixes/cupertino/` Trigger Logic: - Target branch: master - Events: opened, reopened, synchronize, and ready_for_review - The workflow only executes if changes are detected within the specified directories. Override is possible with a label for emergencies, or necessary work we will land in service of decoupling during the freeze. #### 🛡️ Catching Existing PRs To ensure this freeze is applied to exiting pull requests, we can add this as a Required Status Check in a branch protection rule. <details><summary>How to enable Required Status Check</summary> 1. Go to the repository Settings on GitHub. 2. Select Branches from the left sidebar. 3. Find the branch protection rule for master and click Edit. 4. Enable "Require status checks to pass before merging". 5. Search for the new check name: "Check Code Freeze" and add it to the required list. 6. Click Save changes. </details> How this affects open PRs: Once the check is required: - Existing PRs opened before this workflow will be blocked from merging because the "Check Code Freeze" status will be missing or failed. - Authors of open PRs can trigger the check by: - Pushing a new commit (even a trivial one). - Closing and reopening the PR. - If the PR is a draft, marking it as "Ready for Review". - GitHub evaluates the entire diff of the PR. If an existing PR contains changes to packages/flutter/lib/src/material/, the workflow will trigger and fail the moment the PR is updated, regardless of when the original Material changes were pushed. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This adds the ability to implement a code freeze in Flutter repositories based on PR labels or specific code paths.
In preparation for decoupling, we will be putting a code freeze in place for material and cupertino. This will not happen for a few weeks.
We discussed a few ways to do this:
Overview of the preferred approach here
auto_submit/lib/configuration/code_freeze.yaml. This file maps repository slugs to specific "frozen" labels and file paths.f: material design) or specific directories (e.g.,packages/flutter/lib/src/material/). Because it's repo-specific, a freeze on flutter/flutter will not affect flutter/packages unless explicitly configured.To modify the code freeze in the future, simply update the
auto_submit/lib/configuration/code_freeze.yamlfile.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.