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

Add CI lint checking to enforce rustfmt code formatting. #594

Merged
merged 2 commits into from
Jun 1, 2016

Conversation

fnichol
Copy link
Collaborator

@fnichol fnichol commented May 31, 2016

This change applies formatting from a stock rustfmt 0.5.0 configuration (i.e. no project overrides) and introduces a linting script that runs after unit tests have passed. If running rustfmt against Rust files in the changeset cause a diff, then the build fails with a report.

The script support/ci/lint.sh has 4 detection modes to trigger slightly different behavior depending on the context or use case:

  • If a LINT_ALL environment variable is set, all *.rs under the components/ directory will be checked with rustfmt. This may only be useful when upgrading the version of rustfmt as it will also flag any currently vendored crates also under ./components/.
  • If there are unstaged files, check all Rust files that are unstaged. This is most useful when actively developing a commit or feature.
  • If there are staged files, check all Rust files that are staged (also known as cached). This is most useful as a pre-commit activity before writing a commit.
  • Otherwise, use the last commit (i.e. HEAD) to select the files to check. This is most useful in a CI environment where the last commit is assumed to contain most of the work. If a TRAVIS_COMMIT_RANGE environment varible is present, this will be used instead to get all files for the pull request under review.

@thesentinels
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @metadave, @reset and @adamhjk to be potential reviewers

@fnichol
Copy link
Collaborator Author

fnichol commented May 31, 2016

Per @reset's request, I'm going to strip the Builder components out of this PR so we can deal with that after. Standby for merging this

@fnichol fnichol force-pushed the fnichol/rustfmt-0.5.0 branch from 767c8e7 to f9c638f Compare May 31, 2016 23:23
@reset
Copy link
Collaborator

reset commented May 31, 2016

@fnichol appreciate that!

@fnichol fnichol force-pushed the fnichol/rustfmt-0.5.0 branch 2 times, most recently from 5b00a4e to 16b84f3 Compare June 1, 2016 14:27
@thesentinels
Copy link
Contributor

☔ The latest upstream changes (presumably 0bab710) made this pull request unmergeable. Please resolve the merge conflicts.

fnichol added 2 commits June 1, 2016 16:21
The script `support/ci/lint.sh` has 4 detection modes to trigger
slightly different behavior depending on the context or use case:

* If a `LINT_ALL` environment variable is set, all `*.rs` under the
  `components/` directory will be checked with `rustfmt`. This may only
  be useful when upgrading the version of `rustfmt` as it will also flag
  any currently vendored crates also under `./components/`.
* If there are unstaged files, check all Rust files that are unstaged.
  This is most useful when actively developing a commit or feature.
* If there are staged files, check all Rust files that are staged (also
  known as cached). This is most useful as a pre-commit activity before
  writing a commit.
* Otherwise, use the last commit (i.e. `HEAD`) to select the files to
  check. This is most useful in a CI environment where the last commit
  is assumed to contain most of the work. If a `TRAVIS_COMMIT_RANGE`
  environment varible is present, this will be used instead to get all
  files for the pull request under review.

Signed-off-by: Fletcher Nichol <[email protected]>
@fnichol fnichol force-pushed the fnichol/rustfmt-0.5.0 branch from 16b84f3 to 10d38bf Compare June 1, 2016 22:43
@fnichol
Copy link
Collaborator Author

fnichol commented Jun 1, 2016

The formatting, it is so enforced

gif-keyboard-5437177192225927808

@thesentinels r+

@thesentinels
Copy link
Contributor

📌 Commit 10d38bf has been approved by fnichol

@thesentinels
Copy link
Contributor

⌛ Testing commit 10d38bf with merge 85185ce...

thesentinels pushed a commit that referenced this pull request Jun 1, 2016
The script `support/ci/lint.sh` has 4 detection modes to trigger
slightly different behavior depending on the context or use case:

* If a `LINT_ALL` environment variable is set, all `*.rs` under the
  `components/` directory will be checked with `rustfmt`. This may only
  be useful when upgrading the version of `rustfmt` as it will also flag
  any currently vendored crates also under `./components/`.
* If there are unstaged files, check all Rust files that are unstaged.
  This is most useful when actively developing a commit or feature.
* If there are staged files, check all Rust files that are staged (also
  known as cached). This is most useful as a pre-commit activity before
  writing a commit.
* Otherwise, use the last commit (i.e. `HEAD`) to select the files to
  check. This is most useful in a CI environment where the last commit
  is assumed to contain most of the work. If a `TRAVIS_COMMIT_RANGE`
  environment varible is present, this will be used instead to get all
  files for the pull request under review.

Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #594
Approved by: fnichol
thesentinels pushed a commit that referenced this pull request Jun 1, 2016
Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #594
Approved by: fnichol
@reset
Copy link
Collaborator

reset commented Jun 1, 2016

gif-keyboard-6598196827127285535

@adamhjk
Copy link
Contributor

adamhjk commented Jun 1, 2016

gif-keyboard-14861773642927712292

@thesentinels
Copy link
Contributor

☀️ Test successful - travis

@thesentinels thesentinels merged commit 10d38bf into master Jun 1, 2016
@fnichol fnichol deleted the fnichol/rustfmt-0.5.0 branch June 10, 2016 04:19
jtimberman pushed a commit that referenced this pull request Jun 12, 2016
The script `support/ci/lint.sh` has 4 detection modes to trigger
slightly different behavior depending on the context or use case:

* If a `LINT_ALL` environment variable is set, all `*.rs` under the
  `components/` directory will be checked with `rustfmt`. This may only
  be useful when upgrading the version of `rustfmt` as it will also flag
  any currently vendored crates also under `./components/`.
* If there are unstaged files, check all Rust files that are unstaged.
  This is most useful when actively developing a commit or feature.
* If there are staged files, check all Rust files that are staged (also
  known as cached). This is most useful as a pre-commit activity before
  writing a commit.
* Otherwise, use the last commit (i.e. `HEAD`) to select the files to
  check. This is most useful in a CI environment where the last commit
  is assumed to contain most of the work. If a `TRAVIS_COMMIT_RANGE`
  environment varible is present, this will be used instead to get all
  files for the pull request under review.

Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #594
Approved by: fnichol
jtimberman pushed a commit that referenced this pull request Jun 12, 2016
Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #594
Approved by: fnichol
raskchanky pushed a commit that referenced this pull request Apr 16, 2019
Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #594
Approved by: fnichol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants