microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
10.2k stars 1.51k forks source link

GitHub: Investigate GitHub Actions for clang-format and validate #521

Closed StephanTLavavej closed 6 months ago

StephanTLavavej commented 4 years ago

We currently use Azure Pipelines to check whether PRs follow our clang-format and other conventions:

https://github.com/microsoft/STL/blob/fffbd8fe05cd1a21adf2284eb6acef69e982b3c7/azure-devops/run_build.yml#L52-L67 https://github.com/microsoft/STL/blob/fffbd8fe05cd1a21adf2284eb6acef69e982b3c7/azure-devops/enforce-clang-format.cmd#L3-L12 https://github.com/microsoft/STL/blob/fffbd8fe05cd1a21adf2284eb6acef69e982b3c7/tools/validate/validate.cpp#L140-L146

This is extremely useful, but suboptimal. The user experience is somewhat non-intuitive for new contributors, as we perform these checks within the x64 build. (Edit: #682 improved this, running Code Format Validation separately.) While their error messages are informative, they're hidden behind a Details link. Additionally, our clang-format enforcement complains about problems, but doesn't fix them - the user has to install and run clang-format themselves, or manually edit their files until clang-format is happy.

It appears that GitHub Actions could provide a better experience. They can post "check notices" on specific lines of PRs, and they can push changes to branches. They can also be triggered by comments. So, we could automatically push clang-format changes, and post check notices for validate.cpp failures (as those are less amenable to automatic fixing).

Originally suggested by @barcharcraz: https://github.com/microsoft/STL/pull/509#issuecomment-589386547

StephanTLavavej commented 3 years ago

@cbezault notes that our Azure Pipelines infrastructure could be changed to simply push a commit when clang-format fails. One contributor has requested this; I believe we should run a poll/survey to judge whether this would be generally desirable for contributors.

StephanTLavavej commented 2 years ago

After thinking about this, I'm opposed to automatically pushing formatting changes. That could have ugly results, which should be noticed before creating a PR instead of during review. Additionally, I believe it would encourage behavior that we should not encourage - one's editor should be properly configured to format-on-save. (clang-format/validate failures are generally an indication that one's development process is incomplete.)

After #2671 and #2697, we now have a convenient way to format all files (I use this when updating clang-format versions, but it could also be used before pushing changes, if one is using an editor that can't format-on-save). There are potential improvements to how we display clang-format and validation failures (clang-format failures are displayed in the Azure Pipelines results with a downloadable diff, although the discoverability of these messages could probably be improved; #2378 is exploring how to report more detailed failures from validation). Automatically creating comments for failures would probably be too noisy, even if we could do so.

We might be able to close this tracking issue now.

StephanTLavavej commented 2 years ago

We talked about this at the weekly maintainer meeting and concluded:

StephanTLavavej commented 6 months ago

I proposed closing this as "won't do". We've got Azure Pipelines via 1ES Hosted Pools working nicely, so maintaining parallel infra would be more work, and with increasing scrutiny of infrastructure security, adding GitHub Actions to the mix is moving in the wrong direction. Auto-commenting on formatting issues doesn't seem valuable; people should be encouraged to configure format-on-save, whereas auto-commenting seems likely to increase reliance on PR checks - also it would involve granting more repo permissions to scripts and we've been encouraged to lock that down as much as possible.

We talked about this again at the weekly maintainer meeting and agreed to wontfix this.