-
Notifications
You must be signed in to change notification settings - Fork 163
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
Fix pre-commit hook command not found error #564
Conversation
@rbleuse I noticed your PR too late and fixed the same issue. Please check out my changes from #568. You don't need Regex to improve the tests. I also suggest to switch to underscore_case for consistency (e.g. CHANGED_FILES). Also I don't see a need for a const val only for Maybe you can apply my changes to your PR. |
Hi @G00fY2 thanks for the suggestion ! |
Not sure why the tests on windows are not passing. Looks like they are somewhat flaky. I tried to reproduce this on my windows machine but actually for me all tests are failing (maybe because I use JDK 17). |
Here's the exception, I don't think this was caused by you. I've re-kicked the jobs: |
It seems it failed again :
|
Any reasons this is not merged yet? |
@@ -54,13 54,12 @@ private fun postCheck( | |||
git add ${'$'}file | |||
fi | |||
done | |||
""".trimIndent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't some kind of trimming need to happen here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JLLeitschuh No because if we keep it, formatUsesGradleExitCode
fails to find gradle_command_exit_code=$?
as there is indentation before :
With trimming (original)
Expecting:
<["#!/bin/sh",
"######## KTLINT-GRADLE HOOK START ########",
"",
" CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $NF ~ /\.kts?$/ { print $NF }')"",
"",
" if [ -z "$CHANGED_FILES" ]; then",
" echo "No Kotlin staged files."",
" exit 0",
" fi;",
"",
" echo "Running ktlint over these files:"",
" echo "$CHANGED_FILES"",
"",
" diff=.git/unstaged-ktlint-git-hook.diff",
" git diff --color=never > $diff",
" if [ -s $diff ]; then",
" git apply -R $diff",
" fi",
"",
" ./gradlew --quiet ktlintFormat -PinternalKtlintGitFilter="$CHANGED_FILES"",
" gradle_command_exit_code=$?",
"",
" echo "Completed ktlint run."",
" echo "$CHANGED_FILES" | while read -r file; do",
" if [ -f $file ]; then",
" git add $file",
" fi",
"done",
"",
" if [ -s $diff ]; then",
" git apply --ignore-whitespace $diff",
" fi",
" rm $diff",
" unset diff",
"",
" echo "Completed ktlint hook."",
" exit $gradle_command_exit_code",
"######## KTLINT-GRADLE HOOK END ########"]>
to contain:
<["gradle_command_exit_code=$?"]>
but could not find:
<["gradle_command_exit_code=$?"]>
Without trimming
"######## KTLINT-GRADLE HOOK START ########",
"",
"CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $NF ~ /\.kts?$/ { print $NF }')"",
"",
"if [ -z "$CHANGED_FILES" ]; then",
" echo "No Kotlin staged files."",
" exit 0",
"fi;",
"",
"echo "Running ktlint over these files:"",
"echo "$CHANGED_FILES"",
"",
"diff=.git/unstaged-ktlint-git-hook.diff",
"git diff --color=never > $diff",
"if [ -s $diff ]; then",
" git apply -R $diff",
"fi",
"",
"./gradlew --quiet ktlintFormat -PinternalKtlintGitFilter="$CHANGED_FILES"",
"gradle_command_exit_code=$?",
"",
"echo "Completed ktlint run."",
"",
"echo "$CHANGED_FILES" | while read -r file; do",
" if [ -f $file ]; then",
" git add $file",
" fi",
"done",
"",
"",
"if [ -s $diff ]; then",
" git apply --ignore-whitespace $diff",
"fi",
"rm $diff",
"unset diff",
"",
"echo "Completed ktlint hook."",
"exit $gradle_command_exit_code",
"######## KTLINT-GRADLE HOOK END ########"]>
But if you tell me that the first indentation with trimIndent
(while it's supposed to remove indentation) is expected, then I'll add it back and look for exit $gradle_command_exit_code
with indentation in the test instead.
The tests were failing. I was waiting for a green run |
Hey @JLLeitschuh will this get merged soon? We just updated to |
Happy to merge this. @rbleuse can you rebase your changes and I'll merge! 😄 |
@JLLeitschuh done :) |
@JLLeitschuh It seems there's an OOM when running tests on windows :
|
#I've been returning these tests multiple times and every time they fail with an OOM error. I have no idea why, but master doesn't fail. This failure is consistently reproducible with your changes and I have no idea why. |
@JLLeitschuh When you twice merged into my fix, the two builds were successful : I can confirm that this OOM is not because of this fix. My guess is, parallel tests are enabled, and somehow there's a memory issue with parallel tests which use too much memory Also one note, tests always fail into OOM on the Reference failed builds : |
I can aggree. I also run these tests on my local Windows machine. No such error occurred. |
* master: testAnnotations use version_current and upload memory dump
Updated the GH Action to upload memory dumps. Let's see what it says: Link to zip: |
* master: Also grab the replay_pid log file on crash Log test events during test execution
* master: Fix formatting of build file
* master: Disable the Gradle Daemon on Windows tests
I 100% agree with you, but unfortunately, I can't merge this PR knowing that it will break I'm trying one last thing with this change: bbc0c94 If we can't figure out the root cause of this OOM issue I can't merge this PR. Unfortunately, as I spelled out in this issue here #569 I'm not really available anymore to maintain this project beyond merging PRs from the community. I don't actively use ktlint-gradle anymore, and I'm now a full-time security researcher not working on any Kotlin or Gradle based projects actively at this time. I'm more than happy to merge any PRs that adequately fix this overall OOM error, or even PRs that help debug what's going wrong, but I don't think I have the time to continue to figure out what's wrong here. I'm really sorry as that's probably pretty disappointing to hear. |
* master: Fix failing test from Daemon disable
* master: Fix formatting
Yes I don't have much time to investigate where this OOM comes from either, but as I mentioned it doesn't come from this PR :( As far as we can investigate from builds history is that the PR #543 has also an OOM when the PR has been merged to master Anyway, your last commit didn't pass either, so what should we do ? |
I'm not certain. Maybe this is caused by a specific version of the Ktlint library on windows? If so, and someone can figure that out, a PR to disable that in our tests would be accepted. I just can't merge a PR I know breaks the main branch as I won't be able to publish releases. I'm really sorry. |
* master: Fix "Unknown command-line option '--no-daemon'" error
With all due respect, did you notice that almost all your What about increasing tests memory ? Same as mentioned in the readme
Or disable parallel tests ? |
I actually didn't. So that 100% confirms this isn't your change breaking things. Okay, I'll merge it. Thanks for pointing out my mistake here. Sorry. |
* master: Remove windows tests from critical path
I've removed the windows tests from the critical path, so the other checks should theoretically now run |
No worries :) |
It should be ok now |
* master: Fix `fail-fast` declaration
Merged, thanks for bearing with me on this one. Much appreciated |
Fixes #562