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

release 0.0.4 #20

Merged
merged 14 commits into from
Nov 18, 2018
Merged
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
name: Run tests
command: gradle test --stacktrace

- run:
name: Run JaCoCo
command: gradle jacocoFullReport

- run:
name: DistZip
command: gradle distZip
Expand All @@ -45,3 +49,6 @@ jobs:
name: Run Koshry
command: app/build/distributions/app/bin/app

- run:
name: Release only from master Koshry
command: gradle release
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties

### AndroidStudio Patch ###

!/gradle/wrapper/gradle-wrapper.jar

### Firebase ###
.idea
**/node_modules/*
Expand Down Expand Up @@ -302,6 +298,3 @@ $RECYCLE.BIN/

### Firebase Google Services file ###
google-services.json

# git_diff
.git_diff
12 changes: 8 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import io.github.tarek360.dependencies.Dependencies
import io.github.tarek360.dependencies.Modules
import io.github.tarek360.dependencies.MainClasses
import org.jetbrains.kotlin.config.KotlinCompilerVersion

plugins {
Expand All @@ -6,13 +9,14 @@ plugins {
}

application {
mainClassName = "io.github.tarek360.app.AppKt"
mainClassName = MainClasses.appKit
}

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(project(":koshry"))
implementation(project(":rules"))
implementation(kotlin(Dependencies.kotlinJDK))
implementation(project(Modules.koshry))
implementation(project(Modules.rules))
implementation(project(Modules.testCoverageRule))
}

java {
Expand Down
3 changes: 0 additions & 3 deletions app/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
pom_name=Koshry GitDiff Library
pom_artifact_id=gitdiff
pom_packaging=jar
21 changes: 17 additions & 4 deletions app/src/main/java/io/github/tarek360/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@ package io.github.tarek360.app

import io.github.tarek360.koshry.Koshry
import io.github.tarek360.koshry.koshry
import io.github.tarek360.rules.coverage.jacocoCoverageRule
import io.github.tarek360.rules.lineRule
import io.github.tarek360.rules.fileRule
import io.github.tarek360.rules.protectedFileRule
import io.github.tarek360.rules.report.Level.ERROR
import io.github.tarek360.rules.core.Level.ERROR

fun main(_args: Array<String>) {

val configuration = koshry {

baseSha = ""

rules {
rule = protectedFileRule {
reportTitle = "Files are protected and can't be modified, ask @tarek360 to modify"
issueLevel = ERROR
issueLevel = ERROR()
files {
filePath = ".circleci/config.yml"
filePath = ".travis.yml"
}
excludeAuthors {
author = "tarek360"
}
}

rule = lineRule {
condition = { file , line -> line.text.contains("System.getenv") }
reportTitle = "Don't use System.getenv directly, use Environment.getVariable instead."
issueLevel = ERROR
issueLevel = ERROR()
}

// Rule to prevent anyone from adding new java code.
Expand All @@ -33,7 +39,14 @@ fun main(_args: Array<String>) {
file.isAdded && file.name.endsWith(".java")
}
reportTitle = "Don't add new Java files, use Kotlin instead."
issueLevel = ERROR
issueLevel = ERROR()
}

// JaCoCo Test Coverage Rule
rule = jacocoCoverageRule {
classCoverageThreshold = 79 //79%
csvFilePath = "build/reports/jacoco/jacoco.csv"
// htmlFilePath = "https://tarek360.github.io/koshry/build/reports/"
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions auto_release.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.io.BufferedReader

tasks.create<DefaultTask>("release") {

val releaseBranch = "master"
val currentBranch = executeCommand("git rev-parse --abbrev-ref HEAD")[0]

val bintrayUploadTasks = subprojects.mapNotNull {
val tasks = it.getTasksByName("bintrayUpload", false)
if (tasks.isNotEmpty()) {
tasks
} else {
null
}
}

if (currentBranch == releaseBranch) {
finalizedBy(bintrayUploadTasks)
}

doFirst {
if (currentBranch == releaseBranch) {
println("Releasing from master branch!")
} else {
println("No master! No release!")
}
}
}


fun executeCommand(command: String): List<String> {
val proc = Runtime.getRuntime().exec(command)
val lines = proc.inputStream.bufferedReader().use(BufferedReader::readLines)
proc.waitFor()
return lines
}
31 changes: 29 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.2.71"
}

buildscript {
val kotlinVersion = "1.2.60"
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath(kotlin("gradle-plugin", version = kotlinVersion))
classpath(kotlin("gradle-plugin", version = "1.2.71"))
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1")
}
}

Expand All @@ -17,3 +23,24 @@ allprojects {
jcenter()
}
}

apply { from("jacoco/jacocoFullReport.gradle") }
apply { from("auto_release.gradle.kts") }

dependencies {
compile(kotlin("stdlib-jdk8"))
}

repositories {
mavenCentral()
}

val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "1.8"
}

val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
jvmTarget = "1.8"
}
12 changes: 12 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
kotlin("jvm") version "1.2.71"
}

repositories {
mavenCentral()
}

dependencies {
compile(kotlin("stdlib-jdk8"))
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.tarek360.dependencies

object Dependencies {

var kotlinJDK = "stdlib-jdk8"

var json = "org.json:json:${Versions.json}"

val junit = "junit:junit:${Versions.junit}"

val mockitoCore = "org.mockito:mockito-core:${Versions.mockitoCore}"

val mockitoKotlin = "com.nhaarman.mockitokotlin2:mockito-kotlin:${Versions.mockitoKotlin}"

val okHttp3Mock = "com.squareup.okhttp3:mockwebserver:${Versions.okHttp3}"

val okHttp3 = arrayOf(
"com.squareup.okhttp3:logging-interceptor:${Versions.okHttp3}",
"com.squareup.okhttp3:okhttp:${Versions.okHttp3}")

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.tarek360.dependencies

object MainClasses {

val appKit = "io.github.tarek360.app.AppKt"

}
25 changes: 25 additions & 0 deletions buildSrc/src/main/java/io/github/tarek360/dependencies/Modules.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.github.tarek360.dependencies

object Modules {

val ciDetector = ":ci-detector"

val core = ":core"

val gitDiffParser = ":gitdiff-parser"

val gitDiffProvider = ":gitdiff-provider"

val gitHost = ":githost"

val koshry = ":koshry"

val rules = ":rules"

val rulesCore = ":rules-core"

val rulesTest = ":rules-test"

val testCoverageRule = ":test-coverage-rule"

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.tarek360.dependencies

object Project {

val group = "io.github.tarek360"

val version = "0.0.1"

}
19 changes: 19 additions & 0 deletions buildSrc/src/main/java/io/github/tarek360/dependencies/Versions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.tarek360.dependencies

object Versions {

val kotlin = "1.2.71"

val jvmTarget = "1.8"

val json = "20160810"

val okHttp3 = "3.11.0"

val junit = "4.12"

val mockitoCore = "2.22.0"

val mockitoKotlin = "2.0.0-RC1"

}
13 changes: 7 additions & 6 deletions ci-detector/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import io.github.tarek360.dependencies.Dependencies
import io.github.tarek360.dependencies.Project
import org.jetbrains.kotlin.config.KotlinCompilerVersion

plugins {
kotlin("jvm")
id("java-library")
id("maven-publish")
jacoco
}

apply { from("../mvn-push.gradle") }
apply { from("../push.gradle") }

repositories {
mavenLocal()
jcenter()
mavenCentral()
}

group = "io.github.tarek360"
version = "0.0.1"

val okHttpVersion = "3.8.1"
group = Project.group
version = Project.version

dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin(Dependencies.kotlinJDK))
}

java {
Expand Down
4 changes: 1 addition & 3 deletions ci-detector/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pom_name=Koshry GitDiff Library
pom_artifact_id=gitdiff
pom_packaging=jar
ARTIFACT_ID=ci-detector
17 changes: 11 additions & 6 deletions ci-detector/src/main/java/io/github/tarek360/ci/Ci.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ package io.github.tarek360.ci

abstract class Ci {

val gitHostToken: String? by lazy {
Environment.getVariable("KOSHRY_GIT_HOST_TOKEN")
}
open val gitHostToken: String? by lazy {
val token = Environment.getVariable("KOSHRY_GIT_HOST_TOKEN")
if (token.isNullOrBlank()) {
Environment.getVariable("DANGER_GITHUB_API_TOKEN")
} else {
token
}
}

abstract val buildId: Int?
abstract val buildId: Int?

abstract val projectOwnerNameRepoName: String?
abstract val projectOwnerNameRepoName: String?

abstract val pullRequestId: Int?
abstract val pullRequestId: Int?
}
Loading