-
-
Notifications
You must b 8000 e signed in to change notification settings - Fork 171
[feature] affected or status (staged) files token #1865
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
Comments
Not sure if this will solve this problem exactly, but have you tried this task option? https://moonrepo.dev/docs/config/project#affectedfiles |
How should that actually work, when I enable this option it will also pass other files to e.g. ESLint which will prints a lot of warnings for JSON files, but these are relevant for the group "app" which I wanted to re-use for eslint. I might have to be more explicit with my groups then. |
Hm, no this is not what I was looking for, but maybe I just need some help settings this up. So this is for ex 8000 ample for stylelint task: run-stylelint:
command:
- 'stylelint'
- '--ignore-path'
- '@in(0)'
- '--ignore-path'
- '@in(1)'
- '--allow-empty-input'
- '--cache'
options:
affectedFiles: true
inputs:
- '/.gitignore'
- '/.stylelintignore'
- '**/.stylelintrc.json'
- '@group(styles)' Stylelint will exit with 1 if it cannot parse a file. So running I thought inputs would also "filter" affected files, or did I missunderstood that? |
Oh, ok, got it now I guess. Stylelint is special. I had to explicitly ignore these kind of files because implicit inputs were passed to it when using it from the cli not the hook. Now it works as far as I can see. run-eslint:
command:
- 'eslint'
- '--cache'
options:
affectedFiles: true
inputs:
- '**/eslint.config.mjs'
- '@group(sources)'
run-stylelint:
command:
- 'stylelint'
- '--cache'
- '--ignore-path'
- '@in(0)'
- '--ignore-path'
- '@in(1)'
- '--allow-empty-input'
options:
affectedFiles: true
affectedPassInputs: true
inputs:
- '/.gitignore'
- '/.stylelintignore'
- '**/.stylelintrc.json'
- '@group(styles)' *** Insert "What a Week, Huh?" for "Web programming" *** |
No, now CI fails, because Moon seems to also add deleted files to the list of affected files.
I am also seeing it passing files not actually in "inputs" (see config above):
|
That's unfortunate. Let me think about a way to handle this. |
I think "inputs" are not the way to handle actual "inputs" for a program, these are 2 different things, one that says "this tool should run again" and "this tool has these inputs". I might be wrong, but from my persepctive this seems more correct. So MAYBE it would be more appropriate to allow |
@muuvmuuv You can use |
Isnt that just a little bit of a workaround |
Just a temporary solution. You could create a file group that only has files that are valid for the specific command (eslint, etc)? |
Yeah that was what I did before and then I tried "affected" so that it only lint affected files on git hooks but both together does not really work like I expected. |
It seems to somewhat work, all warnings about files not beeing processed by tool X can be ignored (could not try with args but guess this will solve that) but that it also passes deleted files makes it always fail in CI. Truncated trace logs:
|
I am big impressed by your rust programming btw. Just scrolled a bit through it, really like https://github.com/moonrepo/moon/blob/master/crates/app/src/queries/touched_files.rs#L148. I think its valid to pass deleted files as well for other tools, not linters, like for danger-js. So I guess besides tasks:
format:
options:
mergeArgs: prepend
runDepsInParallel: false
deps:
- target: 'run-eslint'
args: '--fix'
run-eslint:
command:
- 'eslint'
- '--cache'
options:
affectedFiles: 'args'
affectedFilesStatus:
- modified
- added
args:
- '@group(app)'
- '@group(sources)'
inputs:
- '**/eslint.config.mjs'
- '/libs/plugin-eslint/**/*.js'
- '@group(configs)'
- '@group(app)'
- '@group(sources)' |
Is your feature request related to a problem? Please describe.
I do know my dev-workflow is kind of wild here but maybe some can relate.
While I have set up hooks I noticed that affected and status=staged have no possibility to just lint these affected files. In other words I cannot develop 4 features simultaneously when some files create errors that I have not staged yet but came across and error that I was able to fix on-the-fly in the same application.
Describe the solution you'd like
A token or something like
@affected
with a fallback option like@affected(@in(0))
. That will just append all affected files or fall back to what is described.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: