-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support GitHub actions #1
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f53c3d
Support GitHub actions
sanyavertolet 5bccdfd
Support GitHub actions
sanyavertolet 7a7c172
Support GitHub actions
sanyavertolet 48fa246
Support GitHub actions
sanyavertolet d2c4af0
Support GitHub actions
sanyavertolet 801eb35
Support GitHub actions
sanyavertolet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,2 @@ | ||
* text=auto | ||
*.bat eol=crlf |
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,63 @@ | ||
name: Build and test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
concurrency: | ||
# https://docs.github.com/en/actions/using-jobs/using-concurrency | ||
# The latest queued workflow is preferred; the ones already in progress get cancelled | ||
# Workflows on master branch shouldn't be cancelled, that's why they are identified by commit SHA | ||
group: ${{ github.ref == 'refs/heads/master' && format('{0}-{1}', github.workflow, github.sha) || format('{0}-{1}', github.workflow, github.ref) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build_and_test_with_code_coverage: | ||
name: Build, test and upload code coverage | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
# required for correct codecov upload | ||
fetch-depth: 0 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: temurin | ||
- name: Retrieve Kotlin version | ||
run: | | ||
kv=$(cat gradle/libs.versions.toml | grep '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ') | ||
echo KOTLIN_VERSION=$kv >> $GITHUB_ENV | ||
- name: Cache konan | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.konan | ||
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }} | ||
- name: Build | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
gradle-version: wrapper | ||
gradle-home-cache-cleanup: true | ||
arguments: | | ||
build | ||
-x detekt | ||
-Pdetekt.multiplatform.disabled=true | ||
-PgprUser=${{ github.actor }} | ||
-PgprKey=${{ secrets.GITHUB_TOKEN }} | ||
--scan | ||
--build-cache | ||
- name: Upload gradle reports | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: gradle-reports | ||
path: '**/build/reports/' | ||
retention-days: 1 | ||
- name: Code coverage report | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
fail_ci_if_error: false |
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,41 @@ | ||
name: Run deteKT | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
|
||
jobs: | ||
detekt_check: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# required for all workflows | ||
security-events: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: temurin | ||
- uses: gradle/gradle-build-action@v2 | ||
with: | ||
gradle-version: wrapper | ||
arguments: | | ||
detektAll | ||
--build-cache | ||
--continue | ||
-PgprUser=${{ github.actor }} | ||
-PgprKey=${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload SARIF report to Github | ||
uses: github/codeql-action/upload-sarif@v2 | ||
if: ${{ always() }} | ||
with: | ||
sarif_file: build/detekt-sarif-reports/detekt-merged.sarif | ||
- name: Upload SARIF artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ failure() }} | ||
with: | ||
name: sarif-reports | ||
path: "**/build/detekt-sarif-reports/" | ||
retention-days: 1 |
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,44 @@ | ||
name: Run diKTat | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
|
||
jobs: | ||
diktat_check: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# required for all workflows | ||
security-events: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: temurin | ||
- uses: gradle/gradle-build-action@v2 | ||
with: | ||
gradle-version: wrapper | ||
arguments: | | ||
diktatCheck | ||
mergeDiktatReports | ||
-Pdiktat.githubActions=true | ||
-Pdetekt.multiplatform.disabled=true | ||
--build-cache | ||
--continue | ||
-PgprUser=${{ github.actor }} | ||
-PgprKey=${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload SARIF report to Github | ||
uses: github/codeql-action/upload-sarif@v2 | ||
if: ${{ always() }} | ||
with: | ||
sarif_file: build/reports/diktat/diktat-merged.sarif | ||
- name: Upload SARIF artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ failure() }} | ||
with: | ||
name: sarif-reports | ||
path: "**/build/reports/diktat" | ||
retention-days: 1 |
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,14 @@ | ||
|
||
import com.saveourtool.processbuilder.configureDiktat | ||
import com.saveourtool.processbuilder.createDetektTask | ||
|
||
group = "com.saveourtool" | ||
description = "Kotlin Process Builder" | ||
|
||
plugins { | ||
id("org.cqfn.diktat.diktat-gradle-plugin") | ||
id("io.gitlab.arturbosch.detekt") | ||
} | ||
|
||
configureDiktat() | ||
createDetektTask() |
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,16 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
// workaround https://github.com/gradle/gradle/issues/15383 | ||
implementation(files(project.libs.javaClass.superclass.protectionDomain.codeSource.location)) | ||
implementation(libs.diktat.gradle.plugin) | ||
implementation(libs.detekt.gradle.plugin) | ||
implementation(libs.kotlin.gradle.plugin) | ||
} |
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,7 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
buildSrc/src/main/kotlin/com/saveourtool/processbuilder/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,53 @@ | ||
/** | ||
* Configuration for detekt static analysis | ||
*/ | ||
|
||
package com.saveourtool.processbuilder | ||
|
||
import io.gitlab.arturbosch.detekt.Detekt | ||
import io.gitlab.arturbosch.detekt.DetektPlugin | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension | ||
import io.gitlab.arturbosch.detekt.report.ReportMergeTask | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.TaskProvider | ||
import org.gradle.kotlin.dsl.* | ||
|
||
/** | ||
* Configure Detekt for a single project | ||
*/ | ||
fun Project.configureDetekt() { | ||
apply<DetektPlugin>() | ||
configure<DetektExtension> { | ||
config = rootProject.files("detekt.yml") | ||
basePath = rootDir.canonicalPath | ||
buildUponDefaultConfig = true | ||
} | ||
} | ||
|
||
/** | ||
* Register a unified detekt task | ||
*/ | ||
fun Project.createDetektTask() { | ||
val detektAllTask = tasks.register("detektAll") { | ||
allprojects { | ||
[email protected](tasks.withType<Detekt>()) | ||
} | ||
} | ||
|
||
tasks.register("mergeDetektReports", ReportMergeTask::class) { | ||
mustRunAfter(detektAllTask) | ||
output.set(buildDir.resolve("detekt-sarif-reports/detekt-merged.sarif")) | ||
} | ||
|
||
@Suppress("GENERIC_VARIABLE_WRONG_DECLARATION") | ||
val reportMerge: TaskProvider<ReportMergeTask> = rootProject.tasks.named<ReportMergeTask>("mergeDetektReports") { | ||
input.from( | ||
tasks.withType<Detekt>().map { it.sarifReportFile } | ||
) | ||
shouldRunAfter(tasks.withType<Detekt>()) | ||
} | ||
tasks.withType<Detekt>().configureEach { | ||
reports.sarif.required.set(true) | ||
finalizedBy(reportMerge) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
buildSrc/src/main/kotlin/com/saveourtool/processbuilder/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,27 @@ | ||
/** | ||
* Configuration for diktat static analysis | ||
*/ | ||
|
||
package com.saveourtool.processbuilder | ||
|
||
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") | ||
githubActions = findProperty("diktat.githubActions")?.toString()?.toBoolean() ?: false | ||
inputs { | ||
include("src/**/*.kt", "*.kts", "src/**/*.kts") | ||
exclude("build/**") | ||
} | ||
} | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
core/src/commonMain/kotlin/com/saveourtool/processbuilder/utils/Constants.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,7 @@ | ||
/** | ||
* File containing constants | ||
*/ | ||
|
||
package com.saveourtool.processbuilder.utils | ||
|
||
const val NOT_IMPLEMENTED_IN_JS = "Not implemented in JS" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
it's the same task as created on prev line
tasks.register("mergeDetektReports", ReportMergeTask::class) {
why not merged them?