Skip to content

Commit e070d70

Browse files
authored
release 0.0.4 (#20)
* introduce JacocoCoverageRule (#6) * introduce JacocoCoverageRule * add JacocoCoverageRuleTest * support all nested objects * improve test coverage * add more tests * make issue levels take text (#8) * config bintray * convert the Rule to abstract class (#7) * convert the Rule to abstract class * fix push.gradle * auto release (#9) * auto release * add release task to circle ci * add ci and pullRequest to Rule (#10) * add ci and pullRequest to Rule * fix test * exclude some authors from protected files rule (#11) * jacoco total coverage (#12) * introduce Github-enterprise (#15) * Unify dependencies versions by applying buildSrc (#14) * Making unify dependencies versions feature by applying buildSrc mechanism and Gradle DSL then change all the build.gradle.kts files of all the modules we have to be use the new kotlin class that I made. Since four classes are made : 1. Dependencies : that contains all the dependencies we will use. 2. MainApp : that contains the common things of the whole app. 3. MainClass : that contains the main classes of each module. 4. Projects : that contains the name of projects/modules we have tell now. 5. Versions : that contains the versions that we will use in Dependencies class. * Modify Naming of buildSrc files - Projects file renamed to Modules to be more meaningful. - MainApp file renamed to Project to be more specific. * fix file url for enterprise (#18) * fix file url for enterprise * fix file path by using filePath instead of class path * add UTs * update comment (#19) * update comment * fix parsing * make use of another github token * release 0.0.4
1 parent 172dcf4 commit e070d70

File tree

119 files changed

+3812
-643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+3812
-643
lines changed

.circleci/config.yml

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
name: Run tests
3434
command: gradle test --stacktrace
3535

36+
- run:
37+
name: Run JaCoCo
38+
command: gradle jacocoFullReport
39+
3640
- run:
3741
name: DistZip
3842
command: gradle distZip
@@ -45,3 +49,6 @@ jobs:
4549
name: Run Koshry
4650
command: app/build/distributions/app/bin/app
4751

52+
- run:
53+
name: Release only from master Koshry
54+
command: gradle release

.gitignore

-7
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ crashlytics.properties
157157
crashlytics-build.properties
158158
fabric.properties
159159

160-
### AndroidStudio Patch ###
161-
162-
!/gradle/wrapper/gradle-wrapper.jar
163-
164160
### Firebase ###
165161
.idea
166162
**/node_modules/*
@@ -302,6 +298,3 @@ $RECYCLE.BIN/
302298

303299
### Firebase Google Services file ###
304300
google-services.json
305-
306-
# git_diff
307-
.git_diff

app/build.gradle.kts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.github.tarek360.dependencies.Dependencies
2+
import io.github.tarek360.dependencies.Modules
3+
import io.github.tarek360.dependencies.MainClasses
14
import org.jetbrains.kotlin.config.KotlinCompilerVersion
25

36
plugins {
@@ -6,13 +9,14 @@ plugins {
69
}
710

811
application {
9-
mainClassName = "io.github.tarek360.app.AppKt"
12+
mainClassName = MainClasses.appKit
1013
}
1114

1215
dependencies {
13-
implementation(kotlin("stdlib-jdk8"))
14-
implementation(project(":koshry"))
15-
implementation(project(":rules"))
16+
implementation(kotlin(Dependencies.kotlinJDK))
17+
implementation(project(Modules.koshry))
18+
implementation(project(Modules.rules))
19+
implementation(project(Modules.testCoverageRule))
1620
}
1721

1822
java {

app/gradle.properties

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
pom_name=Koshry GitDiff Library
2-
pom_artifact_id=gitdiff
3-
pom_packaging=jar

app/src/main/java/io/github/tarek360/app/App.kt

+17-4
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,35 @@ package io.github.tarek360.app
22

33
import io.github.tarek360.koshry.Koshry
44
import io.github.tarek360.koshry.koshry
5+
import io.github.tarek360.rules.coverage.jacocoCoverageRule
56
import io.github.tarek360.rules.lineRule
67
import io.github.tarek360.rules.fileRule
78
import io.github.tarek360.rules.protectedFileRule
8-
import io.github.tarek360.rules.report.Level.ERROR
9+
import io.github.tarek360.rules.core.Level.ERROR
910

1011
fun main(_args: Array<String>) {
1112

1213
val configuration = koshry {
1314

15+
baseSha = ""
16+
1417
rules {
1518
rule = protectedFileRule {
1619
reportTitle = "Files are protected and can't be modified, ask @tarek360 to modify"
17-
issueLevel = ERROR
20+
issueLevel = ERROR()
1821
files {
1922
filePath = ".circleci/config.yml"
2023
filePath = ".travis.yml"
2124
}
25+
excludeAuthors {
26+
author = "tarek360"
27+
}
2228
}
2329

2430
rule = lineRule {
2531
condition = { file , line -> line.text.contains("System.getenv") }
2632
reportTitle = "Don't use System.getenv directly, use Environment.getVariable instead."
27-
issueLevel = ERROR
33+
issueLevel = ERROR()
2834
}
2935

3036
// Rule to prevent anyone from adding new java code.
@@ -33,7 +39,14 @@ fun main(_args: Array<String>) {
3339
file.isAdded && file.name.endsWith(".java")
3440
}
3541
reportTitle = "Don't add new Java files, use Kotlin instead."
36-
issueLevel = ERROR
42+
issueLevel = ERROR()
43+
}
44+
45+
// JaCoCo Test Coverage Rule
46+
rule = jacocoCoverageRule {
47+
classCoverageThreshold = 79 //79%
48+
csvFilePath = "build/reports/jacoco/jacoco.csv"
49+
// htmlFilePath = "https://tarek360.github.io/koshry/build/reports/"
3750
}
3851
}
3952
}

auto_release.gradle.kts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import java.io.BufferedReader
2+
3+
tasks.create<DefaultTask>("release") {
4+
5+
val releaseBranch = "master"
6+
val currentBranch = executeCommand("git rev-parse --abbrev-ref HEAD")[0]
7+
8+
val bintrayUploadTasks = subprojects.mapNotNull {
9+
val tasks = it.getTasksByName("bintrayUpload", false)
10+
if (tasks.isNotEmpty()) {
11+
tasks
12+
} else {
13+
null
14+
}
15+
}
16+
17+
if (currentBranch == releaseBranch) {
18+
finalizedBy(bintrayUploadTasks)
19+
}
20+
21+
doFirst {
22+
if (currentBranch == releaseBranch) {
23+
println("Releasing from master branch!")
24+
} else {
25+
println("No master! No release!")
26+
}
27+
}
28+
}
29+
30+
31+
fun executeCommand(command: String): List<String> {
32+
val proc = Runtime.getRuntime().exec(command)
33+
val lines = proc.inputStream.bufferedReader().use(BufferedReader::readLines)
34+
proc.waitFor()
35+
return lines
36+
}

build.gradle.kts

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
kotlin("jvm") version "1.2.71"
5+
}
6+
17
buildscript {
2-
val kotlinVersion = "1.2.60"
38
repositories {
49
mavenLocal()
510
google()
611
jcenter()
712
}
813
dependencies {
9-
classpath(kotlin("gradle-plugin", version = kotlinVersion))
14+
classpath(kotlin("gradle-plugin", version = "1.2.71"))
15+
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1")
1016
}
1117
}
1218

@@ -17,3 +23,24 @@ allprojects {
1723
jcenter()
1824
}
1925
}
26+
27+
apply { from("jacoco/jacocoFullReport.gradle") }
28+
apply { from("auto_release.gradle.kts") }
29+
30+
dependencies {
31+
compile(kotlin("stdlib-jdk8"))
32+
}
33+
34+
repositories {
35+
mavenCentral()
36+
}
37+
38+
val compileKotlin: KotlinCompile by tasks
39+
compileKotlin.kotlinOptions {
40+
jvmTarget = "1.8"
41+
}
42+
43+
val compileTestKotlin: KotlinCompile by tasks
44+
compileTestKotlin.kotlinOptions {
45+
jvmTarget = "1.8"
46+
}

buildSrc/build.gradle.kts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
kotlin("jvm") version "1.2.71"
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
compile(kotlin("stdlib-jdk8"))
11+
}
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.github.tarek360.dependencies
2+
3+
object Dependencies {
4+
5+
var kotlinJDK = "stdlib-jdk8"
6+
7+
var json = "org.json:json:${Versions.json}"
8+
9+
val junit = "junit:junit:${Versions.junit}"
10+
11+
val mockitoCore = "org.mockito:mockito-core:${Versions.mockitoCore}"
12+
13+
val mockitoKotlin = "com.nhaarman.mockitokotlin2:mockito-kotlin:${Versions.mockitoKotlin}"
14+
15+
val okHttp3Mock = "com.squareup.okhttp3:mockwebserver:${Versions.okHttp3}"
16+
17+
val okHttp3 = arrayOf(
18+
"com.squareup.okhttp3:logging-interceptor:${Versions.okHttp3}",
19+
"com.squareup.okhttp3:okhttp:${Versions.okHttp3}")
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.github.tarek360.dependencies
2+
3+
object MainClasses {
4+
5+
val appKit = "io.github.tarek360.app.AppKt"
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.github.tarek360.dependencies
2+
3+
object Modules {
4+
5+
val ciDetector = ":ci-detector"
6+
7+
val core = ":core"
8+
9+
val gitDiffParser = ":gitdiff-parser"
10+
11+
val gitDiffProvider = ":gitdiff-provider"
12+
13+
val gitHost = ":githost"
14+
15+
val koshry = ":koshry"
16+
17+
val rules = ":rules"
18+
19+
val rulesCore = ":rules-core"
20+
21+
val rulesTest = ":rules-test"
22+
23+
val testCoverageRule = ":test-coverage-rule"
24+
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.tarek360.dependencies
2+
3+
object Project {
4+
5+
val group = "io.github.tarek360"
6+
7+
val version = "0.0.1"
8+
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.github.tarek360.dependencies
2+
3+
object Versions {
4+
5+
val kotlin = "1.2.71"
6+
7+
val jvmTarget = "1.8"
8+
9+
val json = "20160810"
10+
11+
val okHttp3 = "3.11.0"
12+
13+
val junit = "4.12"
14+
15+
val mockitoCore = "2.22.0"
16+
17+
val mockitoKotlin = "2.0.0-RC1"
18+
19+
}

ci-detector/build.gradle.kts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
import io.github.tarek360.dependencies.Dependencies
2+
import io.github.tarek360.dependencies.Project
13
import org.jetbrains.kotlin.config.KotlinCompilerVersion
24

35
plugins {
46
kotlin("jvm")
57
id("java-library")
68
id("maven-publish")
9+
jacoco
710
}
811

9-
apply { from("../mvn-push.gradle") }
12+
apply { from("../push.gradle") }
1013

1114
repositories {
1215
mavenLocal()
1316
jcenter()
1417
mavenCentral()
1518
}
1619

17-
group = "io.github.tarek360"
18-
version = "0.0.1"
19-
20-
val okHttpVersion = "3.8.1"
20+
group = Project.group
21+
version = Project.version
2122

2223
dependencies {
23-
implementation(kotlin("stdlib-jdk8"))
24+
implementation(kotlin(Dependencies.kotlinJDK))
2425
}
2526

2627
java {

ci-detector/gradle.properties

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
pom_name=Koshry GitDiff Library
2-
pom_artifact_id=gitdiff
3-
pom_packaging=jar
1+
ARTIFACT_ID=ci-detector

ci-detector/src/main/java/io/github/tarek360/ci/Ci.kt

+11-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ package io.github.tarek360.ci
22

33
abstract class Ci {
44

5-
val gitHostToken: String? by lazy {
6-
Environment.getVariable("KOSHRY_GIT_HOST_TOKEN")
7-
}
5+
open val gitHostToken: String? by lazy {
6+
val token = Environment.getVariable("KOSHRY_GIT_HOST_TOKEN")
7+
if (token.isNullOrBlank()) {
8+
Environment.getVariable("DANGER_GITHUB_API_TOKEN")
9+
} else {
10+
token
11+
}
12+
}
813

9-
abstract val buildId: Int?
14+
abstract val buildId: Int?
1015

11-
abstract val projectOwnerNameRepoName: String?
16+
abstract val projectOwnerNameRepoName: String?
1217

13-
abstract val pullRequestId: Int?
18+
abstract val pullRequestId: Int?
1419
}

0 commit comments

Comments
 (0)