From 3eb6d79303be668cdcac8090406eae5dba5fa82f Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 16 Nov 2020 10:19:06 +0100 Subject: [PATCH 01/11] Added hooks --- build.gradle.kts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bee117591d..c62b45fb0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,15 +21,6 @@ repositories { mavenCentral() } -subprojects { - afterEvaluate { - if (tasks.findByName("detekt") != null) { - tasks.withType { - dependsOn(tasks["detekt"]) - } - } - } -} tasks.named("dependencyUpdates", DependencyUpdatesTask::class.java).configure { From eb050b5ceb9b5b5ec2f069fbac38a4a3ce48eded Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 16 Nov 2020 11:50:05 +0100 Subject: [PATCH 02/11] Added hooks --- .../src/main/kotlin/ftl/run/platform/android/ResolveApks.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt b/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt index 674f375e85..937c41fd07 100644 --- a/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt +++ b/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt @@ -16,7 +16,7 @@ import ftl.util.asFileReference @VisibleForTesting internal fun AndroidArgs.resolveApks(): List = listOfNotNull( mainApkContext(), - *additionalApksContexts() + *additionalApksContexts() ) private fun AndroidArgs.mainApkContext() = appApk?.let { appApk -> From 91532c705b55f05d4655564b7b7ddf3eaa463831 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 16 Nov 2020 11:50:43 +0100 Subject: [PATCH 03/11] Added hooks --- .githooks/linkHooks.bat | 4 ++++ .githooks/linkHooks.sh | 5 +++++ .githooks/pre-commit | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 .githooks/linkHooks.bat create mode 100644 .githooks/linkHooks.sh create mode 100644 .githooks/pre-commit diff --git a/.githooks/linkHooks.bat b/.githooks/linkHooks.bat new file mode 100644 index 0000000000..88397d4856 --- /dev/null +++ b/.githooks/linkHooks.bat @@ -0,0 +1,4 @@ +@echo off +echo Changing git config for hooks to .githooks +call git config --local core.hooksPath .githooks/ +echo Complete! \ No newline at end of file diff --git a/.githooks/linkHooks.sh b/.githooks/linkHooks.sh new file mode 100644 index 0000000000..6b28bba963 --- /dev/null +++ b/.githooks/linkHooks.sh @@ -0,0 +1,5 @@ +#!/bin/bash +@echo off +echo Changing git config for hooks to .githooks +git config --local core.hooksPath .githooks/ +echo Complete! \ No newline at end of file diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000000..4ef19e2fb2 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,17 @@ +#!C:/Program\ Files/Git/usr/bin/sh.exe + +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 From 1f4950cb2f9a2d8d34b63e5c20de75a1f2f3c5d9 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 16 Nov 2020 11:52:07 +0100 Subject: [PATCH 04/11] Basic fixup --- .githooks/linkHooks.bat | 2 +- .githooks/linkHooks.sh | 2 +- .../src/main/kotlin/ftl/run/platform/android/ResolveApks.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.githooks/linkHooks.bat b/.githooks/linkHooks.bat index 88397d4856..589f9358f3 100644 --- a/.githooks/linkHooks.bat +++ b/.githooks/linkHooks.bat @@ -1,4 +1,4 @@ @echo off echo Changing git config for hooks to .githooks call git config --local core.hooksPath .githooks/ -echo Complete! \ No newline at end of file +echo Complete! diff --git a/.githooks/linkHooks.sh b/.githooks/linkHooks.sh index 6b28bba963..597bffb08e 100644 --- a/.githooks/linkHooks.sh +++ b/.githooks/linkHooks.sh @@ -2,4 +2,4 @@ @echo off echo Changing git config for hooks to .githooks git config --local core.hooksPath .githooks/ -echo Complete! \ No newline at end of file +echo Complete! diff --git a/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt b/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt index 937c41fd07..674f375e85 100644 --- a/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt +++ b/test_runner/src/main/kotlin/ftl/run/platform/android/ResolveApks.kt @@ -16,7 +16,7 @@ import ftl.util.asFileReference @VisibleForTesting internal fun AndroidArgs.resolveApks(): List = listOfNotNull( mainApkContext(), - *additionalApksContexts() + *additionalApksContexts() ) private fun AndroidArgs.mainApkContext() = appApk?.let { appApk -> From 1dcdb6b4c6e6a3303440ace6138f4538a7c8c9b2 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 16 Nov 2020 11:58:54 +0100 Subject: [PATCH 05/11] parameter list wrapping --- config/detekt.yml | 2 +- test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/detekt.yml b/config/detekt.yml index ea4700d87a..50da7640a1 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -189,7 +189,7 @@ formatting: autoCorrect: true ParameterListWrapping: excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt'] - active: false + active: true autoCorrect: true indentSize: 4 SpacingAroundColon: diff --git a/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt b/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt index 52e6e29869..cbd783f120 100644 --- a/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt +++ b/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt @@ -92,8 +92,8 @@ object Xctestrun { } private fun findTestNamesForTarget( - testTarget: String, - xctestrun: File + testTarget: String, + xctestrun: File ): List = testsForTarget( testDictionary = parse(xctestrun)[testTarget] From 27bcb923bec5cc20de0c184a22ce19e7d968ca21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janek=20G=C3=B3ral?= Date: Tue, 17 Nov 2020 09:10:28 +0100 Subject: [PATCH 06/11] Make linkHooks.sh executable --- .githooks/linkHooks.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .githooks/linkHooks.sh diff --git a/.githooks/linkHooks.sh b/.githooks/linkHooks.sh old mode 100644 new mode 100755 From 35dfcbe3b06dc239184487ab5ccd20706740b594 Mon Sep 17 00:00:00 2001 From: Sloox Date: Tue, 17 Nov 2020 11:29:42 +0100 Subject: [PATCH 07/11] link test --- .githooks/linkHooks.bat | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .githooks/linkHooks.bat diff --git a/.githooks/linkHooks.bat b/.githooks/linkHooks.bat old mode 100644 new mode 100755 From 6360fc33ecd113f215cdca8bdbd65c0a94f8dd8e Mon Sep 17 00:00:00 2001 From: Sloox Date: Tue, 17 Nov 2020 12:12:03 +0100 Subject: [PATCH 08/11] Updates --- .githooks/linkHooks.sh | 2 +- .githooks/pre-commit | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 .githooks/pre-commit diff --git a/.githooks/linkHooks.sh b/.githooks/linkHooks.sh index 597bffb08e..b2d416a636 100755 --- a/.githooks/linkHooks.sh +++ b/.githooks/linkHooks.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh @echo off echo Changing git config for hooks to .githooks git config --local core.hooksPath .githooks/ diff --git a/.githooks/pre-commit b/.githooks/pre-commit old mode 100644 new mode 100755 index 4ef19e2fb2..4b93da9b5f --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,4 +1,4 @@ -#!C:/Program\ Files/Git/usr/bin/sh.exe +#!/bin/sh echo "Running detekt check" OUTPUT="/tmp/detekt-$(date +%s)" From ccda09efc5d0748eb5044e3b6042c6a6943d8ced Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 17 Nov 2020 15:53:01 +0100 Subject: [PATCH 09/11] fixed script on macOS --- .githooks/linkHooks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.githooks/linkHooks.sh b/.githooks/linkHooks.sh index b2d416a636..df1e0f9ecc 100755 --- a/.githooks/linkHooks.sh +++ b/.githooks/linkHooks.sh @@ -1,5 +1,5 @@ #!/bin/sh -@echo off +set echo of echo Changing git config for hooks to .githooks git config --local core.hooksPath .githooks/ echo Complete! From 072cf4197fc6ccbba1381fbe147c5b2fc09c6a1e Mon Sep 17 00:00:00 2001 From: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> Date: Tue, 17 Nov 2020 16:55:41 +0100 Subject: [PATCH 10/11] Update .githooks/linkHooks.sh --- .githooks/linkHooks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.githooks/linkHooks.sh b/.githooks/linkHooks.sh index df1e0f9ecc..91d239b1aa 100755 --- a/.githooks/linkHooks.sh +++ b/.githooks/linkHooks.sh @@ -1,5 +1,5 @@ #!/bin/sh -set echo of +set echo off echo Changing git config for hooks to .githooks git config --local core.hooksPath .githooks/ echo Complete! From 17c1d0c5a9804039cf0cc58ac1a81db204ef1fcd Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Tue, 17 Nov 2020 17:08:05 +0100 Subject: [PATCH 11/11] Added documentation --- docs/onboarding/1_environment_setup.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/onboarding/1_environment_setup.md b/docs/onboarding/1_environment_setup.md index 050c822eeb..b2b17fb2b5 100644 --- a/docs/onboarding/1_environment_setup.md +++ b/docs/onboarding/1_environment_setup.md @@ -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