Commit Graph

11 Commits

Author SHA1 Message Date
Bobby R. Bruce
3f5d7d647a misc: Run pre-commit autoupdate (#419)
1. Runs `pre-commit autoupdate`.
2. Runs `pre-commit run --all-files`.
3. Adds (2.) to ".git-blame-ignore-rev".
2023-10-10 21:41:33 -07:00
Bobby R. Bruce
317d2fb5b8 misc: Run pre-commit autoupdate
This updates the pre-commit utility from v4.3.0 to v4.5.0 and updates
black from 22.6.0 to 23.9.1.

Change-Id: I7ebb551f30e617059ce49f89a30207f739b1cb14
2023-10-10 14:00:57 -07:00
Bobby R. Bruce
da212e04b5 Merge branch 'develop' into requirements-fixer-hook 2023-10-09 22:37:25 -07:00
Bobby R. Bruce
5b09777011 misc,python: Add pre-commit-hook-yamlfmt to pre-commit
This automatically formats .yaml files. By deault has the following
parameters:

* `mapping`: 4 spaces.
* `sequence`: 6 spaces.
* `offset`: 4 spaces.
* `colons`: do not align top-level colons.
* `width`: None.

Change-Id: Iee5194cd57b7b162fd7e33aa6852b64c5578a3d2
2023-10-09 13:16:52 -07:00
Bobby R. Bruce
c53529783b misc,python: Add requirements-txt-fixer to pre-commit
This sorts entries in requirements.txt files.

Change-Id: I7ee6e31f3cbe5078f24d13471a6aa9edc482cecd
2023-10-09 13:09:21 -07:00
Bobby R. Bruce
ff75e5b30e misc,ext: Update pre-commit hook to run on ext/testlib
Though in ext, we regularly modify these files to add features and
extend our testlib testing infrastructure. Ergo, the pre-commit checks
should be run.

Change-Id: I921a263f25f850b03e5535a8a1f509921c124763
2023-09-05 00:00:25 -07:00
Bobby R. Bruce
be33be87da misc: Update black to process src/python/m5/ext/pystats
The exclusion in .pre-commit-config.yaml covered all files in
src/python/m5/ext. This excludes src/python/m5/exit/pystats, which we
want covered by black. This commit updates .pre-commit-config.yaml to
only exclude src/python/m5/ext/pyfdt.

This change also runs black on these files.

Change-Id: Iecff45ea2a27a37fc0d00b867d41300aad911c7a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63711
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
2022-11-03 22:32:36 +00:00
Bobby R. Bruce
c0df86fb3e misc: Add gerrit commit message hook to pre-commit
This pre-commit hook adds the Change-ID etc. to the commit message.

Change-Id: I43b239468ab60ce1a8aaabb53dd6905819a2ce05
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62575
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-08-24 21:47:07 +00:00
Bobby R. Bruce
64add0e04d misc: Exclude test ref directories from pre-commit
The files in "tests/*./ref" directories are used in tests to check the
output of a test is valid. As such these should not be automatically
formatted by the pre-commit.

Change-Id: I82be1a91132a0b6c66c8bbb8f6d7dcc6e72abe77
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62631
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
2022-08-24 21:47:07 +00:00
Bobby R. Bruce
ab04acc26e misc: Add the legacy gem5 .git/hooks to the pre-commit
The gem5 commit msg checker must be run during the 'commit-msg'
stage ergo this is explicitly set. The other hooks are only applicable
to the "commit" stage, the `default_stage` for the hooks.

To install all the hooks, you need to run the following:

```
pre-commit install -t pre-commit -t commit-msg
```

This ensures both the 'commit-msg' and 'pre-commit' hooks are installed.
If you run just `pre-commit install`, only the pre-commit hooks are
installed.

Change-Id: I4a0dcc7159ed5048baa120adf80bbf65f63c11dd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62552
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
2022-08-24 21:47:07 +00:00
Andreas Sandberg
616391e48a misc: Add pre-commit configuration
Add a pre-precommit configuration that can be used to run a series of
automated tests in CI. This configuration currently enforces Black
style on Python files and checks for other common errors (incorrect
json, mixed line endings etc.).

The CI system runs pre-commit using the following command:

  pre-commit run --from-ref HEAD~ --to-ref HEAD

Users can install pre-commit hooks in their git repositories using the
following command:

  pre-commit install

Note that our scons scripts automatically install a simple style
checker as a pre-commit hooks already. If the pre-commit tool is
installed after the existing hook, the existing hook will be kept and
called automatically.

The current pre-commit configuration doesn't currently doesn't run the
C++ style checker automatically. This feature could easily be added in
the future by adding the following to the pre-commit file:

  - repo: local
    hooks:
    - id: style-checker
      name: Check C++ coding style
      language: python
      entry: util/style.py -f

The main reason this isn't already in the configuration is that it is
expected that the style checker will have some false positives since
style checks will be enforced on the entire file rather than the lines
changed in a commit.

Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Change-Id: Ibbb1dc641e2979509f3259cd951c7272094d69f5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/61111
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
2022-07-12 09:28:47 +00:00