Closed LecrisUT closed 2 months ago
This means we need a way to propagate --root
for tmt commands and for path=
argument used in git ls-files
Might be easy enough. Docs to read about hooks: https://pre-commit.com/#new-hooks
Indeed, if it was such a simple fix, I would have made a PR with the feature. If we can create a simple wrapper I think it's trivial, but otherwise I don't see how to extract a specific args
in the .pre-commit-hooks.yaml
format. Do you think it worth making a small wrapper file for that?
I'm afraid we will have to. If tmt could accept args everywhere it would be easy but it doesn't (we need to add it as the first option).... The 'entry point' with current 'bash -c' is too hackish to my liking anyway, dedicated scripts might be easier to fix/extend .
I did a bit of quick testing, and there is a more crucial issue that tmt --root path/to/fmf_root lint
fails:
fail No tree found in repo 'None', missing an '.fmf' directory?
Running the tmt --root ... run
works though so this is a bug in lint.
Which tmt version is that?
$ tmt --version
tmt version: 1.22.0 (ea71a188)
$ tree -a
.
└── a
├── .fmf
│ └── version
└── t.fmf
3 directories, 2 files
$ tmt t lint
No metadata found in the '.' directory. Use 'tmt init' to get started.
$ tmt --root a t lint
/t
pass test script must be defined
pass directory path must be absolute
pass directory path must exist
warn summary is very useful for quick inspection
pass correct attributes are used
I have tried with both 1.21
and 1.22
. Try with this minimal example plan and with a git repo:
summary:
simple example
discover:
how: fmf
filter: "tag: something"
execute:
how: tmt
@lukaszachy Let me know if you can confirm this behaviour
Confirmed. Please create the issue for lint
Ok, separated in #2006
As for the pre-commit
, I've tried a hack as:
- id: tmt
name: tmt
entry: tmt
files: '.*\.fmf$'
verbose: true
pass_filenames: true
language: python
language_version: python3
and
- repo: https://github.com/LecrisUT/tmt.git
rev: pre-commit
hooks:
- id: tmt
args:
- "--root"
- "test"
- "lint"
- "--source"
It sort-of works, but it is not a good solution. We should still maybe make different executable that is not installed outside of a pypi environment (or maybe not even there?). Is it ok if this one is not using click
and entry-point
for this one?
Also, what do you think about modernizing the build to PEP621 (requires dropping python 3.6 support and rhel8 at least and switching the versioning to git tags)
I'd say rhel-8 support (so python 3.6) is required for now and we will start thinking about being python3.9+ once centos-8 is EOL or rhel-8 moves to AUS
@LecrisUT If you find a way how to create helper script just for the pre-commit usage it would be nice. All I can think of now is to create separate project (e.g. teemtee/precommit) and let it live there.
Allow to run
pre-commit
with fmf root in a subpath