[wiki migration] Engine team pages (#148696)

This sorts the wiki pages owned by the Engine team in the docs/ directory as planned in [flutter.dev/go/migrate-flutter-wiki-spreadsheet](https://docs.google.com/spreadsheets/d/1x65189ZBdNiLRygpUYoU08pwvXD4M-Z157c6pm8deGI/edit?usp=sharing) 

It also adds the engine and team-engine labels to the bot for future PRs.

Changes to the content were only updating cross links. The remaining wiki links will be updated after the rest of the pages are relocated, the original wiki links still work in the meantime.

Part of https://github.com/flutter/flutter/issues/145009
This commit is contained in:
Kate Lovett
2024-05-20 18:40:42 -05:00
committed by GitHub
parent 40b5bc3117
commit 722c8d62fd
34 changed files with 74 additions and 66 deletions

View File

@@ -0,0 +1,56 @@
# Engine Clang Tidy Linter
## Description
In May 2020, [`clang-tidy`](https://clang.llvm.org/extra/clang-tidy/) was added as a CI step to the Flutter Engine. Previously the only lint checks that were happening in the engine were formatting, there were no semantic checks. Now there are, but that means there is work to be done migrating all the code to conform to all the lint checks.
If a file has `// FLUTTER_NOLINT` at the top, it has issues with the lint that haven't been addressed and the linter will ignore it. As the issues are fixed the comments should be removed.
You can run the linter locally by running `flutter/ci/lint.sh`.
## CI background information
* The clang-tidy ci step is run 4 times: host_debug on mac, ios_debug on mac, host_debug on linux, android_debug_arm64 on linux.
* Before the linter can run, the target must be built in order to generate code.
* Clang-tidy jobs are sharded such that the intersection of files in iOS and macOS are shared, similarly for Linux and Android.
## FAQs
### I don't understand this lint error, where do I get help?
You can ask on the `hackers-engine` discord channel. Ping @gaaclarke or @zanderso if you don't get the response you want.
### Hey, why are/aren't you checking for X?
The checks that are enabled are negotiable. If you think we are missing something, please discuss it on `hacker-engine`.
### Can I just use `NOLINT` to turn off the error?
You can, but please get explicit approval to do from someone on the team.
### How do I turn on a large new lint?
Here are things that can make it easier to land large new lints.
#### Tips
* Try to reduce the number of checks you are turning on at a time, they can have cascading effects where fixing one check with "clang-tidy fix" can cause violations with other checks.
* Prefer using NOLINTNEXTLINE over NOLINT since auto formatting can move NOLINT comments and break them.
#### Clang-tidy fix on CI
Instead of running clang-tidy fix locally on your machines 4 times you can get the CI bots to print out the fix. Here's steps on how to do that:
1. Edit `//ci/clang_tidy.sh`:
```diff
# To run on CI, just uncomment the following line:
-# FLUTTER_LINT_PRINT_FIX=1
+FLUTTER_LINT_PRINT_FIX=1
```
This will run on _all_ files, and print out the patch generated by `clang-tidy fix` in the CI bots.
2. Make a draft PR with the check added and FLUTTER_LINT_PRINT_FIX=1
3. Look at the output of failed clang-tidy runs and make sure that it didn't garble the fix. Sometimes that happens and if it does, you'll have to manually fix where it garbled the fix or use NOLINTNEXTLINE.
4. Copy the patch the CI bot printed out to the clipboard, in the terminal, at the engine repo, use `git apply`, paste the patch, press ctrl+d then enter. Watch out that there can be overlapping patches between the mac runs and the linux runs since we don't shard across platforms.
5. Commit and push that.
6. When the 4 CI runs are green, remove FLUTTER_LINT_PRINT_FIX=1 and put up for review

View File

@@ -0,0 +1,79 @@
The Flutter engine repo runs both pre-submit (before merging) and post-submit (after merging) suites of tests and checks, defined in [`.ci.yaml`](https://github.com/flutter/engine/blob/main/.ci.yaml).
> [!TIP]
> See [Cocoon Scheduler](https://github.com/flutter/cocoon/blob/main/CI_YAML.md) for details.
Failure to run appropriate tests for changes can (and do) result in the engine tree turning red, which in turn causes an expensive cascade of developers being blocked, investigative work, reverts, and roll-forwards. Where possible, all attempts should be made to run any/all tests _before_ merging a PR. See nuances (below) for exceptional cases.
<!-- Github Wikis do not support an automatic index, sorry -->
* [Pre-submit](#pre-submit)
* [Post-submit](#post-submit)
* [Running post-submits eagerly](#running-post-submits-eagerly)
## Pre-submit
Presubmits run (and are required to be passing) to merge a PR:
<img width="839" alt="Checks" src="https://github.com/flutter/flutter/assets/168174/dff8e2b4-2a71-4929-b163-2ac437675380">
<p>
For example, the `linux_host_engine` target above runs based on the configuration in [`ci/builders/linux_host_engine.json`](https://github.com/flutter/engine/blob/458956228dad9837956aeb78b2988879e764a0b2/ci/builders/linux_host_engine.json).
### Nuances
Typically, pre-submits _always_ run on every PR, and don't need any special attention (other than keeping them green). There are two exceptions:
1. Targets that provide a `runIf: ...` configuration
2. Changes that impact Clang Tidy
> [!WARNING]
>
> `runIf: ...` is a powerful (but dangerous) feature that trades predictability for speed.
>
> `runIf` will skip certain targets if a particular file (or commonly, sets of files) are not changed in a given PR.
>
> For example, the [`linux_clang_tidy_presubmit`](https://github.com/flutter/engine/blob/991676f3bc9482eaaeb3764b6b835f0e3ff8b3c5/.ci.yaml#L219-L235) target will not run if only markdown (`*.md`) files are changed.
Clang Tidy, on the other hand, is only run on _files that have changed in a given PR_. For example, if you have:
```h
// impeller/a.h
struct A {}
```
... files that import that header, such as `impeller/foo/bar/baz.cc`, will _not_ be run in pre-submit. This means that changing (or updating the `DEPS` of libraries that provide) headers is _not_ a safe change, and will _not_ be detected in pre-submit. As an example, [#48705](https://github.com/flutter/engine/pull/48705) had to be reverted (despite passing all pre-submit checks), because the Clang Tidy _post-submit_ caught a failure.
See [post-submit](#post-submit) below for options to run post-submits eagerly (i.e. as a pre-submit).
## Post-submit
Some (albeit fewer) targets are configured with the property `presubmit: false`:
```yaml
- name: Mac mac_clang_tidy
recipe: engine_v2/engine_v2
presubmit: false
```
These targets will _not_ show up during a PR, and will not be executed, but can (and do) turn the tree red.
### Running post-submits eagerly
We've intentionally chosen to make it _easier_ to land PRs, at the cost of turning the tree red periodically because post-submit checks catch something that the developer did not intend (or even know about). As a code author (or reviewer), you can optionally turn on post-submits to run eagerly (during pre-submit) by adding the label `test: all` (available only in the `flutter/engine` repo).
Add the label, and push the PR (or a new commit, **the scheduler will not understand the label being added without a commit**):
<img width="311" alt="Screenshot 2023-12-07 at 1 55 48 PM" src="https://github.com/flutter/flutter/assets/168174/9a4d88b8-8e67-4e96-805a-adb21f06a4c2">
<p>
For example, [#48158](https://github.com/flutter/engine/pull/48158) ran _all_ of the checks, including what is typically post-submits:
<img width="319" alt="Screenshot 2023-12-07 at 1 55 39 PM" src="https://github.com/flutter/flutter/assets/168174/67abd263-c516-4240-b82b-a9b691543951">
<p>
> [!WARNING]
> This increases the use of workers/capacity, and should be discouraged to be used on _all_ PRs.