Skip to content

Commit

Permalink
Merge pull request #1 from Kiolk/dev
Browse files Browse the repository at this point in the history
Added pipelines for automate work
  • Loading branch information
Kiolk authored May 16, 2024
2 parents a39150f + 3175912 commit be52983
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 15 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/create_github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Create Github Release
on:
push:
branches:
- 'master'
permissions:
contents: write
jobs:
check_version:
name: Read release version
runs-on: ubuntu-latest
outputs:
versionName: ${{ steps.readVersion.outputs.VERSION_NAME }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read file and store value in variable
id: readVersion
run: |
MY_VERSION=$(grep '^versionName' gradle.properties | cut -d'=' -f2)
echo "Version name from gradle.properties: $MY_VERSION"
echo "VERSION_NAME=$MY_VERSION" >> "$GITHUB_OUTPUT"
shell: bash

generate_release:
name: Generate Github release
needs: check_version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
- name: Setup variables in local.properties
run: |
echo "signing_keyId=${{secrets.SIGNING_KEY_ID}}" > local.properties
echo "signing_password=${{secrets.SIGNING_PASSWORD}}" >> local.properties
echo "username=${{secrets.MAVEN_CENTRAL_USER_NAME}}" >> local.properties
echo "password=${{secrets.MAVEN_CENTRAL_PASSWORD}}" >> local.properties
- name: Setup gpg private key
run: |
echo "${{secrets.GPG_PRIVATE_KEY}}" > maven-secret-key.asc
- name: Generate jar
run: |
./gradlew jar
echo ${{ needs.check_version.outputs.versionName }}
- uses: ncipollo/release-action@v1
with:
tag: ${{ needs.check_version.outputs.versionName }}
replacesArtifacts: true
artifacts: build/libs/detekt-rules.jar
skipIfReleaseExists: true
generateReleaseNotes: true
30 changes: 30 additions & 0 deletions .github/workflows/publish_to_maven_central.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to Maven Central Repository
on:
push:
branches:
- 'master'
jobs:
build:
name: Publish to Maven Central Repository
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
- name: Setup variables in local.properties
run: |
echo "signing_keyId=${{secrets.SIGNING_KEY_ID}}" > local.properties
echo "signing_password=${{secrets.SIGNING_PASSWORD}}" >> local.properties
echo "username=${{secrets.MAVEN_CENTRAL_USER_NAME}}" >> local.properties
echo "password=${{secrets.MAVEN_CENTRAL_PASSWORD}}" >> local.properties
- name: Setup gpg private key
run: |
echo "${{secrets.GPG_PRIVATE_KEY}}" > maven-secret-key.asc
- name: Publish to new Maven Central Repository
run: |
./gradlew publishAllPublicationsToCentralPortal
31 changes: 31 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Code checks on Pull Request
on:
workflow_dispatch:
pull_request:
branches:
- 'master'
- 'release/**'
- 'dev'
jobs:
pull_request_checks:
name: Code checks on Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
- name: Setup variables in local.properties
run: |
echo "signing_keyId=${{secrets.SIGNING_KEY_ID}}" > local.properties
echo "signing_password=${{secrets.SIGNING_PASSWORD}}" >> local.properties
echo "username=${{secrets.MAVEN_CENTRAL_USER_NAME}}" >> local.properties
echo "password=${{secrets.MAVEN_CENTRAL_PASSWORD}}" >> local.properties
- name: Setup gpg private key
run: |
echo "${{secrets.GPG_PRIVATE_KEY}}" > maven-secret-key.asc
- name: Run unit tests
run: ./gradlew test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ bin/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

/local.properties
/maven-secret-key.asc
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[![](https://jitpack.io/v/Kiolk/Detekt-rules.svg)](https://jitpack.io/#Kiolk/Detekt-rules) ![Maven Central Version](https://img.shields.io/maven-central/v/io.github.kiolk/kiolk-detekt-rules) ![GitHub Release](https://img.shields.io/github/v/release/kiolk/detekt-rules?color=yellow)

# kiolk-detekt-rules

---
Hello folks. This repository contains my own Detekt rules that born in result my work how developer. I am planning to add new rules in the future. You are welcome to contribute!


# How add to the project

---
You have different options how you can add this set of rules to your project. 

## Maven
To use Maven Central repository, you should add link on `mavenCentral()` in repositories block in `build.gradle.kt` file

```kotlin
repositories {
mavenCentral()
}
```
In `dependencies` block in `build.gradle.kt` of module where you will use detekt add reference on library that points on the latest version
```kotlin
detektPlugins("io.github.kiolk:kiolk-detekt-rules:1.0.4")
```

## Jitpack
To use Jitpack, you should add link on jitpack in repositories block in `build.gradle.kt` file

```kotlin
repositories {
maven { url 'https://jitpack.io' }
}
```
In `dependencies` block in `build.gradle.kt` of module where you will use detekt add reference on library that points on the latest version
```kotlin
detektPlugins("com.github.Kiolk:Detekt-rules:v1.0.4")
```

## Local artifacts
If you want to use only locally, you should add path to `jar` file on your local machine. Latest artifacts you can find in [release section](https://github.com/Kiolk/Detekt-rules/releases) of repository.
```kotlin
detektPlugins(files("local_path_to_artifact.jar"))

```

# Configuration

---

# Rules:

---

## UseInvokeForOperator
### Motivation
### Cases
### AutoCorrection
116 changes: 103 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,109 @@
import org.jetbrains.dokka.gradle.DokkaTask
import java.io.FileInputStream
import java.util.*

plugins {
kotlin("jvm") version "1.9.22"
apply { `maven-publish` }
apply { `signing` }
id("org.jetbrains.dokka") version "1.9.20"
id("com.gradleup.nmcp") version "0.0.7"
}

group = "com.github.kiolk.detektrules"
version = "1.0.2"

repositories {
mavenCentral()
mavenLocal()
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "com.github.kiolk.detektrules"
artifactId = "KiolkDetektRules"
version = "1.0.2"
allprojects {
apply(plugin = "kotlin")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "signing")

from(components["java"])
}
val dokkaHtml by tasks.existing(DokkaTask::class)
val dokkaJar by tasks.creating(org.gradle.jvm.tasks.Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveClassifier.set("javadoc")
from(dokkaHtml)
}
repositories {
mavenLocal()

val sourcesJar by tasks.creating(org.gradle.jvm.tasks.Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

val pomArtifactId: String? by project
if (pomArtifactId != null) {
publishing {
publications {
create<MavenPublication>("maven") {
val versionName: String by project
val pomGroupId: String by project
groupId = pomGroupId
artifactId = pomArtifactId
version = versionName
from(components["java"])

artifact(dokkaJar)
artifact(sourcesJar)

pom {
val pomDescription: String by project
val pomUrl: String by project
val pomName: String by project
description.set(pomDescription)
url.set(pomUrl)
name.set(pomName)
scm {
val pomScmUrl: String by project
val pomScmConnection: String by project
val pomScmDevConnection: String by project
url.set(pomScmUrl)
connection.set(pomScmConnection)
developerConnection.set(pomScmDevConnection)
}
licenses {
license {
val pomLicenseName: String by project
val pomLicenseUrl: String by project
val pomLicenseDist: String by project
name.set(pomLicenseName)
url.set(pomLicenseUrl)
distribution.set(pomLicenseDist)
}
}
developers {
developer {
val pomDeveloperId: String by project
val pomDeveloperName: String by project
id.set(pomDeveloperId)
name.set(pomDeveloperName)
}
}
}
}
}

signing {
val file = File("maven-secret-key.asc")
val key = file.readText()
val properties = Properties()
properties.load(FileInputStream(file("local.properties")))
useGpgCmd()
useInMemoryPgpKeys(key, properties.getProperty("signing_password"))

sign(publishing.publications["maven"])
}
repositories {
maven {
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
val versionName: String by project
url = if (versionName.endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
}
}
}
}
}

Expand All @@ -38,5 +119,14 @@ tasks.test {
}
kotlin {
jvmToolchain(17)
}

nmcp {
publish("maven") {
val properties = Properties()
properties.load(FileInputStream(file("local.properties")))
username = properties.getProperty("username")
password = properties.getProperty("password")
publicationType = "USER_MANAGED"
}
}
15 changes: 15 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
kotlin.code.style=official

versionName=1.0.4
pomGroupId=io.github.kiolk
pomDescription=Detekt rules
pomUrl=https://github.com/Kiolk/Detekt-rules
pomScmUrl=https://github.com/Kiolk/Detekt-rules
pomScmConnection=scm:[email protected]:Kiolk/Detekt-rules.git
pomScmDevConnection=scm:[email protected]:Kiolk/Detekt-rules.git
pomLicenseName=The MIT License
pomLicenseUrl=https://opensource.org/licenses/MIT
pomLicenseDist=repo
pomDeveloperId=kiolk
pomDeveloperName=Yauheni Slizh
pomArtifactId=kiolk-detekt-rules
pomName=Kiolk Detekt Rules
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.resolve.scopes.findFirstFunction
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.isNullable

//@RequiresTypeResolution
class UseInvokeForOperator(config: Config) : Rule(config) {

override val issue: Issue
Expand Down

0 comments on commit be52983

Please sign in to comment.