Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mach fmt calls clang-format #24552

Merged
merged 2 commits into from Nov 4, 2019
Merged

mach fmt calls clang-format #24552

merged 2 commits into from Nov 4, 2019

Conversation

@paulrouget
Copy link
Contributor

paulrouget commented Oct 25, 2019

Fix #24031

What would be the right way to also integrate this with tidy?

@highfive
Copy link

highfive commented Oct 25, 2019

Heads up! This PR modifies the following files:

@SimonSapin
Copy link
Member

SimonSapin commented Oct 25, 2019

Does clang-format have something like rustfmt --check, which prints a diff and returns an error exit code if it would make any change? ./mach test-tidy does this here:

self.install_rustfmt()
rustfmt_failed = self.call_rustup_run(["cargo", "fmt", "--", "--check"])
if rustfmt_failed:
print("Run `./mach fmt` to fix the formatting")

@paulrouget
Copy link
Contributor Author

paulrouget commented Oct 28, 2019

Does clang-format have something like rustfmt --check

No. clang-format is very limited. I'm gonna have to implement that manually.

Also, note to self, clang-format is not guaranteed to be installed on Mac and Linux.

@paulrouget
Copy link
Contributor Author

paulrouget commented Oct 28, 2019

There's an option to get a XML output. I will use that.

@paulrouget paulrouget force-pushed the paulrouget:clangformat branch from c2ae624 to 7caefb4 Oct 28, 2019
@paulrouget
Copy link
Contributor Author

paulrouget commented Oct 28, 2019

@paulrouget paulrouget force-pushed the paulrouget:clangformat branch from 7caefb4 to 68e3952 Oct 28, 2019
@paulrouget
Copy link
Contributor Author

paulrouget commented Oct 28, 2019

We will need to install clang-format on the CI machines.

@SimonSapin
Copy link
Member

SimonSapin commented Oct 29, 2019

Since this requires an externally-installed tool I’d prefer we make this either opt-in or opt-out.

How fast is clang-format? If not very, can we only run it on files that have been changed like tidy

Dependencies for Linux CI tasks are installed here https://github.com/servo/servo/blob/master/etc/taskcluster/docker/build.dockerfile. Modifying this file in your PR should Just Work.

r? @jdm

@paulrouget paulrouget changed the title mach fmt calls clang-format [WIP] mach fmt calls clang-format Oct 29, 2019
@paulrouget
Copy link
Contributor Author

paulrouget commented Oct 29, 2019

Note to self:

  • make it optin or optout
  • check speed
  • version differences on Windows and MacOS (6 vs 9)
  • update etc/taskcluster/docker/build.dockerfile and etc/taskcluster/macos/Brewfile
@SimonSapin
Copy link
Member

SimonSapin commented Oct 29, 2019

update etc/taskcluster/docker/build.dockerfile and etc/taskcluster/macos/Brewfile

Do we need both? Isn’t it enough if CI runs clang-format once on all source files?

@bors-servo
Copy link
Contributor

bors-servo commented Oct 29, 2019

The latest upstream changes (presumably #24547) made this pull request unmergeable. Please resolve the merge conflicts.

@paulrouget paulrouget force-pushed the paulrouget:clangformat branch from 68e3952 to ea0fadc Oct 30, 2019
@paulrouget
Copy link
Contributor Author

paulrouget commented Oct 30, 2019

I change the logic a bit:

  • if --no-cpp is passed, clang-format is not used
  • if clang-format is not available, or has the wrong version (not v6), it skips the check (no failure) and print a message

There's an issue where Visual Studio use clang-format 6, not 9 (the one available on MacOS and probably Linux). And the clang format configurations files are not compatible between versions (that's why I'm checking the clang-format version).

As for the speed, now it only scan files that have changed. It's fast.

I am not changing the CI configuration for osx or linux, as I think it should only be tested on Windows, where the supported version is supposed to be installed. Also, for now, we only check HoloLens code, so it makes sense to support the Windows version. I'm not sure though how my Visual Studio version got clang-format. And I don't know if the CI will have it. Will see from the logs.

@paulrouget paulrouget force-pushed the paulrouget:clangformat branch from ea0fadc to b6a8d03 Oct 30, 2019
@paulrouget paulrouget changed the title [WIP] mach fmt calls clang-format mach fmt calls clang-format Oct 30, 2019
@paulrouget paulrouget force-pushed the paulrouget:clangformat branch from b6a8d03 to 222ad71 Oct 30, 2019
@paulrouget
Copy link
Contributor Author

paulrouget commented Nov 1, 2019

@jdm r?

@jdm
jdm approved these changes Nov 1, 2019
return False, None, None
gitcmd = ['git', 'ls-files']
if not all_files:
gitcmd.append('-m')

This comment has been minimized.

Copy link
@jdm

jdm Nov 1, 2019

Member

nit: unindent this one level.

@paulrouget paulrouget force-pushed the paulrouget:clangformat branch from 222ad71 to 36c1669 Nov 4, 2019
@paulrouget
Copy link
Contributor Author

paulrouget commented Nov 4, 2019

@bors-servo r=jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

📌 Commit 36c1669 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

Testing commit 36c1669 with merge 5caa241...

bors-servo added a commit that referenced this pull request Nov 4, 2019
mach fmt calls clang-format

Fix #24031

What would be the right way to also integrate this with tidy?
@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

💔 Test failed - linux-rel-css

@CYBAI
Copy link
Collaborator

CYBAI commented Nov 4, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

Testing commit 36c1669 with merge e0d81e1...

bors-servo added a commit that referenced this pull request Nov 4, 2019
mach fmt calls clang-format

Fix #24031

What would be the right way to also integrate this with tidy?
@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

💔 Test failed - status-taskcluster

@CYBAI
Copy link
Collaborator

CYBAI commented Nov 4, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

💣 Failed to start rebuilding: Unknown error

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

Testing commit 36c1669 with merge f626355...

bors-servo added a commit that referenced this pull request Nov 4, 2019
mach fmt calls clang-format

Fix #24031

What would be the right way to also integrate this with tidy?
@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing f626355 to master...

@bors-servo bors-servo merged commit 36c1669 into servo:master Nov 4, 2019
1 of 2 checks passed
1 of 2 checks passed
Taskcluster (pull_request) TaskGroup: failure
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.