-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What's done: * Diktat code analysis * Detekt code analysis * Git hooks * Fixed code style
- Loading branch information
Showing
22 changed files
with
1,222 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
commit_pattern="(Merge (remote-tracking )?branch|### What's done:)" | ||
error_msg="Your commit message doesn't match the pattern $commit_pattern. Please fix it." | ||
|
||
if [[ ! $( cat "$1" ) =~ $commit_pattern ]] | ||
then | ||
echo "$error_msg" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
branch_name="$(git rev-parse --abbrev-ref HEAD)" | ||
branch_pattern="^(feature|bugfix|hotfix|infra)/.*$" | ||
error_message="Your branch name doesn't match the pattern $branch_pattern. Please correct it before committing." | ||
|
||
if [[ ! $branch_name =~ $branch_pattern ]] | ||
then | ||
echo "$error_message" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Run deteKT | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
detekt_check: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
GRADLE_OPTS: -Dorg.gradle.daemon=false | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.11 | ||
- name: Cache gradle caches | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches/ | ||
~/.gradle/wrapper/ | ||
key: ${{ runner.os }}-gradle-detekt-${{ hashFiles('**/*.gradle*') }} | ||
restore-keys: ${{ runner.os }}-gradle-detekt | ||
- name: Run detekt | ||
run: ./gradlew detektAll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Run diKTat | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
diktat_check: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
GRADLE_OPTS: -Dorg.gradle.daemon=false | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.11 | ||
- name: Cache gradle caches | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches/ | ||
~/.gradle/wrapper/ | ||
key: ${{ runner.os }}-gradle-diktat-${{ hashFiles('**/*.gradle*') }} | ||
restore-keys: ${{ runner.os }}-gradle-diktat | ||
- name: Run diktat | ||
run: ./gradlew diktatCheckAll |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import org.cqfn.save.buildutils.configureDetekt | ||
import org.cqfn.save.buildutils.configureDiktat | ||
import org.cqfn.save.buildutils.createDetektTask | ||
import org.cqfn.save.buildutils.createDiktatTask | ||
import org.cqfn.save.buildutils.installGitHooks | ||
|
||
plugins { | ||
kotlin("jvm") version "1.4.21" apply false | ||
id("com.github.ben-manes.versions") version "0.36.0" | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
configureDiktat() | ||
configureDetekt() | ||
} | ||
|
||
createDiktatTask() | ||
createDetektTask() | ||
installGitHooks() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
object Versions { | ||
val kotlin = "1.4.30" | ||
val springBoot = "2.4.2" | ||
val springSecurity = "5.4.2" | ||
val hibernate = "5.4.2.Final" | ||
val liquibase = "4.2.2" | ||
val slf4j = "1.7.30" | ||
val logback = "1.2.3" | ||
val dockerJavaApi = "3.2.7" | ||
const val kotlin = "1.4.30" | ||
const val springBoot = "2.4.2" | ||
const val springSecurity = "5.4.2" | ||
const val hibernate = "5.4.2.Final" | ||
const val liquibase = "4.3.0" | ||
const val slf4j = "1.7.30" | ||
const val logback = "1.2.3" | ||
const val dockerJavaApi = "3.2.7" | ||
} |
33 changes: 33 additions & 0 deletions
33
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/DetektConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Configuration for detekt static analysis | ||
*/ | ||
|
||
package org.cqfn.save.buildutils | ||
|
||
import io.gitlab.arturbosch.detekt.DetektPlugin | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
/** | ||
* Configure Detekt for a single project | ||
*/ | ||
fun Project.configureDetekt() { | ||
apply<DetektPlugin>() | ||
configure<DetektExtension> { | ||
config = rootProject.files("detekt.yml") | ||
buildUponDefaultConfig = true | ||
} | ||
} | ||
|
||
/** | ||
* Register a unified detekt task | ||
*/ | ||
fun Project.createDetektTask() { | ||
tasks.register("detektAll") { | ||
allprojects { | ||
this@register.dependsOn(tasks.getByName("detekt")) | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/DiktatConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Configuration for diktat static analysis | ||
*/ | ||
|
||
package org.cqfn.save.buildutils | ||
|
||
import org.cqfn.diktat.plugin.gradle.DiktatExtension | ||
import org.cqfn.diktat.plugin.gradle.DiktatGradlePlugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
/** | ||
* Applies diktat gradle plugin and configures diktat for [this] project | ||
*/ | ||
fun Project.configureDiktat() { | ||
apply<DiktatGradlePlugin>() | ||
configure<DiktatExtension> { | ||
diktatConfigFile = rootProject.file("diktat-analysis.yml") | ||
inputs = files("src/**/*.kt") | ||
} | ||
} | ||
|
||
/** | ||
* Creates unified tasks to run diktat on all projects | ||
*/ | ||
fun Project.createDiktatTask() { | ||
tasks.register("diktatCheckAll") { | ||
allprojects { | ||
this@register.dependsOn(tasks.getByName("diktatCheck")) | ||
} | ||
} | ||
tasks.register("diktatFixAll") { | ||
allprojects { | ||
this@register.dependsOn(tasks.getByName("diktatFix")) | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
buildSrc/src/main/kotlin/org/cqfn/save/buildutils/GitHookInstallation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Gradle tasks to install git hooks as a part of the build | ||
*/ | ||
|
||
package org.cqfn.save.buildutils | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.Copy | ||
import org.gradle.kotlin.dsl.register | ||
|
||
/** | ||
* Task of type [Copy] that install git hooks from directory in repo to .git directory | ||
*/ | ||
fun Project.installGitHooks() { | ||
val installGitHooksTask = tasks.register("installGitHooks", Copy::class) { | ||
from(file("$rootDir/.git-hooks")) | ||
into(file("$rootDir/.git/hooks")) | ||
} | ||
// add git hooks installation to build by adding it as a dependency for some common task | ||
subprojects.mapNotNull { | ||
it.tasks.findByName("build") | ||
} | ||
.firstOrNull() | ||
?.dependsOn(installGitHooksTask) | ||
} |
Oops, something went wrong.
31ce1b6
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.
I wasn't able to retrieve PDD puzzles from the code base and submit them to GitHub. If you think that it's a bug on our side, please submit it to yegor256/0pdd:
Please, copy and paste this stack trace to GitHub: