Skip to content

Conversation

@jmarrec
Copy link
Contributor

@jmarrec jmarrec commented May 23, 2025

Pull request overview

  • Fixes Clang Format woefully out of date #11073

  • I initially bumped to 18, which is what Ubuntu has. But Latest MSVC using clang-format 19.1.5, and this is harder for windows users to install a specific version

  • Issue was that there was formatting differences (minor) being 18 and 19, but you CANNOT configure that (it's the internal parser), so for these I basically did a bit of refactoring where possible, and I turned off clang format for that (it's like 2 lines in src/ and 3 in tst/)

  • There are 0 formatting differences in clang-format-18, 19 and 20 right now!

  • I have redone the clang format action to move away from jidicula to a custom one

  • I ran clang-tidy-18 with --checks=-*,readability-braces-around-statements, and I enabled the InsertBraces: true in clang-format as discussed with @Myoldmopar previously

THIS SHOULD PROBABLY BE SQUASHED AND ADDED to .git-blame-ignore-revs before merging

Please merge this one instead

@Myoldmopar this is the PR to review, but #11082 should be the one merged (I should have made this one a draft)

New clang format action

Replaces clang-format action with custom implementation
Benefit:

  • Only run for changed files for a Pull Request, NOT the entire code base
  • Run clang-format in parallel, not serially like the jidicula action does
    • it takes 4min to run for src/ and tst/ and both will individually spin a new docker container on develop, it takes about 20 seconds here, even though this touched 304 files!
  • For a PR: uploads a patch diff that can be applied locally
  • For a push to develop, this will AUTOCORRECT + do another commit that adds it to .git-blame-ignore-revs
  • I'm providing clearer logs + a github step summary markdown table

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

jmarrec added 24 commits May 23, 2025 09:06
I'm doing this

```
clang-format-10 --style=file -i  --fallback-style=none -dump-config > .clang-format-10
```

Then comparing
….clang-format-10 && mv .clang-format-10 .clang-format
…clang-format-10)

The correct config value is "Standard: c++11", this is why it was misunderstood as "Latest"...
```
$ clang-format --version
Ubuntu clang-format version 18.1.8 (++20240731025043+3b5b5c1ec4a3-1~exp1~20240731145144.92)

```
…p-config --assume-filename=.clang-format > .clang-format-18
This is coming from an ubuntu:noble image from 2 days ago, so it has 18.1.8 as well (edit: it has 18.1.3...)

https://github.com/jidicula/clang-format-action/pkgs/container/clang-format/420191370?tag=18
…nts"

```python
def run_clang_tidy_check(fp: Path):
    cmd_args = [
        'clang-tidy',
        "--checks=-*,readability-braces-around-statements",
        "--format-style=file",
        '--fix', '--quiet',
        str(fp)
    ]

    subprocess.run(cmd_args)
```
This reformatted things that weren't fixed via clang-tidy because of preprocessor definitions, or because the file failed to compile (missing declaration Sched:: namespace in Fans.hh for eg)
This is Visual Studio 2022, 17.14.0 (fully up to date)

cd "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin"
.\clang-format.exe --version
clang-format version 19.1.5

jidicula action will get plucky's version which is 19.1.7 (noble gets 19.1.1, but if you add the apt.llvm.org deb source you get 19.1.7)
…at differently but not crash) as far back as clang-format-15 (InsertBraces was added there)
… diff differently between clang format 18 and 19
Switches from using the `jidicula/clang-format-action` to a custom, in-house implementation for running clang-format.

Benefit:
* Only run for changed files for a Pull Request, NOT the entire code base (it takes 4min to run for src/ and tst/ and both will individually spin a new docker container)
* Run clang-format in parallel, not serially like the jidicula action does
* For a PR: uploads a patch diff that can be applied locally
* For a push to develop, this will AUTOCORRECT + do another commit that adds it to .git-blame-ignore-revs
* I'm providing clearer logs + a github step summary markdown table
@jmarrec jmarrec self-assigned this May 23, 2025
@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc) labels May 23, 2025
@Myoldmopar
Copy link
Member

And closing this since it's not needed, right @jmarrec !

@Myoldmopar Myoldmopar closed this May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clang Format woefully out of date

5 participants