Translate annotation line numbers from merge to head (#55569)
Summary:
This PR
- adds a `tools/translate_annotations.py` script that
- parses annotations into JSON using the regexes that we were previously passing to [`pytorch/add-annotations-github-action`](https://github.com/pytorch/add-annotations-github-action) and
- uses `git diff-index` to translate the line numbers for those annotations from the PR `merge` onto the PR `head`, since (as of https://github.com/pytorch/pytorch/issues/54967) we now run CI on the former instead of the latter;
- modifies the `flake8-py3` and `clang-tidy` jobs to use that script and thus upload JSON in their artifacts instead of raw text; and
- modifies the "Add annotations" workflow to specify `mode: json` to allow it to use those preprocessed annotations.
Depends on https://github.com/pytorch/add-annotations-github-action/pull/18.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55569
Test Plan:
You can run the unit tests with this command:
```
python tools/test/test_translate_annotations.py
```
I also tested the entire system together in my personal sandbox repo.
Reviewed By: malfet
Differential Revision: D27662161
Pulled By: samestep
fbshipit-source-id: ecca51b79b9cf00c90fd89f0d41d0c7b89d69c63