Skip to content

Commit

Permalink
Github action for snapshot diktat
Browse files Browse the repository at this point in the history
  • Loading branch information
orchestr7 committed Jun 9, 2023
1 parent 8e3b755 commit 6beb4c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/diktat_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,15 @@ jobs:
- name: 'Small hack to inject implementation and to run diktat properly from snapshot'
run: |
#!/bin/bash
line_number=26
file_path=gradle/plugins/build.gradle.kts
string_to_insert='implementation(libs.diktat.gradle.plugin) {
exclude("io.github.detekt.sarif4k", "sarif4k")
}'
string_to_insert='
dependencies {
implementation(libs.diktat.gradle.plugin) {
exclude("io.github.detekt.sarif4k", "sarif4k")
}
}'
# Escape the special characters in the string
escaped_string=$(sed 's/[\/&]/\\&/g' <<< "$string_to_insert")
# Create a temporary file
tmp_file=$(mktemp)
# Insert the string as multiple lines after the specified line number
sed "${line_number}r /dev/stdin" "$file_path" <<< "$escaped_string" > "$tmp_file"
# Move the temporary file to overwrite the original file
mv "$tmp_file" "$file_path"
echo "String inserted successfully."
echo $string_to_insert >> $file_path
# copied from .github/workflows/diktat.yml
- uses: gradle/gradle-build-action@v2
Expand All @@ -101,6 +91,7 @@ jobs:
-Pdiktat.githubActions=true
-Pdetekt.multiplatform.disabled=true
--continue
--build-cache
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
- name: Upload SARIF report to Github
Expand Down
12 changes: 6 additions & 6 deletions gradle/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ repositories {
gradlePluginPortal()
}

tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}

@Suppress("COMMENTED_OUT_CODE", "WRONG_INDENTATION")
dependencies {
// workaround https://github.com/gradle/gradle/issues/15383
Expand All @@ -39,9 +45,3 @@ dependencies {
implementation(libs.kotlin.stdlib.jdk8)
implementation(libs.jetbrains.annotations)
}

tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.saveourtool.diktat.buildutils

@Suppress("AVOID_NULL_CHECKS")
// FixMe: remove after 2.0.0
@Suppress("RUN_IN_SCRIPT", "AVOID_NULL_CHECKS")
plugins {
id("com.saveourtool.diktat.buildutils.detekt-convention-configuration")
// FixMe: remove after 2.0.0
Expand Down

0 comments on commit 6beb4c1

Please sign in to comment.