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

common: add default pre-commit configuration #6068

Merged
merged 2 commits into from
Oct 4, 2024
Merged

Conversation

grom72
Copy link
Contributor

@grom72 grom72 commented Mar 25, 2024

A simple pre-commit configuration file that enables usage of pre-commit hook.
https://pre-commit.com/index.html


This change is Reviewable

@grom72 grom72 added the no changelog Add to skip the changelog check on your pull request label Mar 25, 2024
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.13%. Comparing base (457c61d) to head (5820200).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6068      +/-   ##
==========================================
- Coverage   70.14%   70.13%   -0.02%     
==========================================
  Files         133      133              
  Lines       19568    19568              
  Branches     3261     3261              
==========================================
- Hits        13726    13724       -2     
- Misses       5842     5844       +2     

@grom72 grom72 requested review from janekmi and osalyk March 25, 2024 10:17
@grom72 grom72 added this to the 2.1.1 milestone Mar 27, 2024
@janekmi janekmi modified the milestones: 2.1.1, 2.1.0 Mar 27, 2024
@grom72 grom72 modified the milestones: 2.1.0, 2.x Mar 28, 2024
Copy link
Contributor

@janekmi janekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @grom72 and @osalyk)

a discussion (no related file):
Please squash these commits.


a discussion (no related file):
Can you please document how to use them?


a discussion (no related file):
Till now we tend to use *.yml instead of *.yaml in this repo.



.pre-commit-config.yaml line 2 at r2 (raw file):

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

It might be useful for those reluctant to go through the 51-page documentation just to find these two lines. Please condier.

Suggestion:

# pip install pre-commit
# pre-commit install (in the repository directory)
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

.pre-commit-config.yaml line 5 at r2 (raw file):

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0

Suggestion:

v4.6.0

.pre-commit-config.yaml line 10 at r2 (raw file):

    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files

Odd formatting. Please adjust to what we tend to use till now. Despite it serving other purposes it is the same type of file like e.g. our workflows.

Suggestion:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v3.2.0
  hooks:
  - id: trailing-whitespace
  - id: end-of-file-fixer
  - id: check-yaml
  - id: check-added-large-files

@grom72 grom72 force-pushed the pre-commit branch 3 times, most recently from 2b9d41b to a237c35 Compare October 2, 2024 05:38
Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r1.
Reviewable status: 1 of 2 files reviewed, 5 unresolved discussions (waiting on @janekmi and @osalyk)

a discussion (no related file):

Previously, janekmi (Jan Michalski) wrote…

Till now we tend to use *.yml instead of *.yaml in this repo.

*.yaml is expected by pre-commit hook


a discussion (no related file):

Previously, janekmi (Jan Michalski) wrote…

Please squash these commits.

Done.



.pre-commit-config.yaml line 5 at r2 (raw file):

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0

Done.


.pre-commit-config.yaml line 10 at r2 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Odd formatting. Please adjust to what we tend to use till now. Despite it serving other purposes it is the same type of file like e.g. our workflows.

Done.

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3.
Reviewable status: all files reviewed (commit messages unreviewed), 5 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r1.
Reviewable status: all files reviewed (commit messages unreviewed), 5 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r4.
Reviewable status: all files reviewed (commit messages unreviewed), 5 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r5, 10 of 10 files at r6, 25 of 25 files at r7, 1 of 1 files at r8, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @janekmi and @osalyk)

a discussion (no related file):

Previously, janekmi (Jan Michalski) wrote…

Can you please document how to use them?

Done.


Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 15 of 15 files at r9, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @janekmi and @osalyk)

@grom72 grom72 force-pushed the pre-commit branch 2 times, most recently from 6d08036 to 9cefd50 Compare October 2, 2024 13:17
Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 4 files at r10, 17 of 32 files at r11, 3 of 10 files at r12, 14 of 26 files at r13, all commit messages.
Reviewable status: 19 of 36 files reviewed, 5 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 32 files at r11, 5 of 26 files at r13.
Reviewable status: 26 of 36 files reviewed, 5 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor

@janekmi janekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r14.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @grom72 and @osalyk)


.pre-commit-config.yml line 16 at r14 (raw file):

      (?x)(\.match$|
           unicode_match_script|
           src\/test\/util_poolset_parse\/pool32.set|

As far as I can tell all of these escapes are redundant or am I missing something?

Suggestion:

src/test/util_poolset_parse/pool32.set|

.pre-commit-config.yml line 21 at r14 (raw file):

           src\/core\/valgrind\/memcheck.h|
           src\/core\/valgrind\/valgrind.h|
           src\/test\/util_map_proc)

Why is this directory excluded?

Code quote:

           src\/test\/util_map_proc)

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 10 files at r15, all commit messages.
Reviewable status: 42 of 44 files reviewed, 4 unresolved discussions (waiting on @janekmi and @osalyk)


src/.clang-format line 18 at r14 (raw file):

Previously, janekmi (Jan Michalski) wrote…
  1. Can you elaborate on why it is necessary? It seems unrelated.
  2. The default is true? The documentation does not seem to be explicit about this.

Ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Because of that:

 pre-commit run --config ./.pre-commit-config.yml --all
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Failed
- hook id: check-yaml
- exit code: 1

while constructing a mapping
  in "src/.clang-format", line 1, column 1
found duplicate key "IndentCaseLabels" with value "True" (original value: "False")
  in "src/.clang-format", line 27, column 1

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

check for added large files..............................................Passed

.gitignore line 8 at r1 (raw file):

Previously, janekmi (Jan Michalski) wrote…

It seems counterintuitive. Why is it not necessary anymore?

Done.


.pre-commit-config.yml line 16 at r14 (raw file):

Previously, janekmi (Jan Michalski) wrote…

As far as I can tell all of these escapes are redundant or am I missing something?

Please try w/o.
My Rocky Linux requires them. ;)


.pre-commit-config.yml line 21 at r14 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Why is this directory excluded?

Done.

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 10 files at r15.
Reviewable status: 43 of 44 files reviewed, 4 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 10 files at r15.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @janekmi and @osalyk)

Copy link
Contributor

@janekmi janekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 10 of 10 files at r15, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @grom72 and @osalyk)

a discussion (no related file):
Now I see why the util_map_proc test is tricky. Are you 100% sure it still works?



src/.clang-format line 18 at r14 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…

Because of that:

 pre-commit run --config ./.pre-commit-config.yml --all
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Failed
- hook id: check-yaml
- exit code: 1

while constructing a mapping
  in "src/.clang-format", line 1, column 1
found duplicate key "IndentCaseLabels" with value "True" (original value: "False")
  in "src/.clang-format", line 27, column 1

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

check for added large files..............................................Passed

😆


.gitignore line 8 at r1 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…

Done.

Nope. Please revisit.


.pre-commit-config.yml line 16 at r14 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…

Please try w/o.
My Rocky Linux requires them. ;)

I tried and it worked just fine. Hence the question. Let's settle it offline.

@grom72 grom72 force-pushed the pre-commit branch 10 times, most recently from d7958fa to b3f7945 Compare October 3, 2024 04:54
Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r16, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @janekmi and @osalyk)

a discussion (no related file):

Previously, janekmi (Jan Michalski) wrote…

Now I see why the util_map_proc test is tricky. Are you 100% sure it still works?

Hmmm ... Yes(?)



.gitignore line 8 at r1 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Nope. Please revisit.

Done.


.pre-commit-config.yml line 16 at r14 (raw file):

Previously, janekmi (Jan Michalski) wrote…

I tried and it worked just fine. Hence the question. Let's settle it offline.

Done.

@grom72 grom72 added the sprint goal This pull request is part of the ongoing sprint label Oct 3, 2024
Copy link
Contributor

@janekmi janekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r16, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @osalyk)

Copy link
Contributor

@janekmi janekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @osalyk)

Copy link
Contributor

@osalyk osalyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1, 5 of 10 files at r12, 22 of 26 files at r13, 8 of 10 files at r15, 2 of 2 files at r16, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @grom72)

A simple pre-commit configuration file that enables usage of
pre-commit hook.

You must instal pre-commit and configure your project to use it:
$ pip install pre-commit
$ pre-commit install --config .pre-commit-config.yml (in the repository root directory)
See https://pre-commit.com for more information
See https://pre-commit.com/hooks.html for more hooks

Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
Excluded files that should not be touched by pre-commit:
- Valgrind headers from trailing-whitespace
- files for checksum tests from end-of-file-fixer
- pool32.set from trailing-whitespace check
- unicodetest files from trailing-whitespace check

Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
Copy link
Contributor Author

@grom72 grom72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r18, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @grom72)

Copy link
Contributor

@osalyk osalyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 3 files at r18, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @grom72)


utils/ansible/opensuse-setup.yml line 24 at r18 (raw file):

#   connection: local
  vars:
    new_user: null

You also need to improve the README.md file

Code quote:

new_user

Copy link
Contributor

@osalyk osalyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @grom72)

Copy link
Contributor

@janekmi janekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r18, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @grom72)


.pre-commit-config.yml line 2 at r18 (raw file):

# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024, Intel Corporation

It is a bummer you put the (c) here. I could have merged this PR now. Let's discuss it offline and decide the direction for the whole repo instead of injecting a new approach on a completely different occasion.

Copy link
Contributor

@janekmi janekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @grom72)


.pre-commit-config.yml line 2 at r18 (raw file):

Previously, janekmi (Jan Michalski) wrote…

It is a bummer you put the (c) here. I could have merged this PR now. Let's discuss it offline and decide the direction for the whole repo instead of injecting a new approach on a completely different occasion.

I will just merge it. It is relatively easy to clean up. No point in blocking this change because of it.

Let's discuss it on Monday.

@janekmi janekmi merged commit 09024d2 into pmem:master Oct 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog Add to skip the changelog check on your pull request sprint goal This pull request is part of the ongoing sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants