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

ci: Added pre-commit-hook #1320

Merged
merged 11 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .githooks/linkHooks.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
echo Changing git config for hooks to .githooks
call git config --local core.hooksPath .githooks/
echo Complete!
5 changes: 5 additions & 0 deletions .githooks/linkHooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set echo off
echo Changing git config for hooks to .githooks
git config --local core.hooksPath .githooks/
echo Complete!
17 changes: 17 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

echo "Running detekt check"
OUTPUT="/tmp/detekt-$(date +%s)"
./gradlew detekt > $OUTPUT
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
cat $OUTPUT
rm $OUTPUT
echo
echo "***********************************************"
echo " Detekt failed "
echo " Please fix the above issues before committing "
echo "***********************************************"
exit $EXIT_CODE
fi
rm $OUTPUT
9 changes: 0 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ repositories {
mavenCentral()
}

subprojects {
afterEvaluate {
if (tasks.findByName("detekt") != null) {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
dependsOn(tasks["detekt"])
}
}
}
}

tasks.named("dependencyUpdates", DependencyUpdatesTask::class.java).configure {

Expand Down
2 changes: 1 addition & 1 deletion config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ formatting:
autoCorrect: true
ParameterListWrapping:
excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt']
active: false
active: true
autoCorrect: true
indentSize: 4
SpacingAroundColon:
Expand Down
4 changes: 4 additions & 0 deletions docs/onboarding/1_environment_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ export GITHUB_TOKEN="type your gihub token here"
1. You can clone https://github.com/Flank/gcloud_cli
1. Or follow official instruction https://cloud.google.com/sdk/docs/quickstarts
1. Don't forget about exports for python and gcloud
1. Ensure Git hooks is configured correctly so detekt is run on a commit
1. Navigate to the .githooks folder
1. Execute linkHooks.sh or linkHooks.bat (depends on the current development OS)
1. Attempting a `git commit ...` should now trigger a detekt check and will not allow committing until it is successful
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ object Xctestrun {
}

private fun findTestNamesForTarget(
testTarget: String,
xctestrun: File
testTarget: String,
xctestrun: File
): List<String> =
testsForTarget(
testDictionary = parse(xctestrun)[testTarget]
Expand Down