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 1651946
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
26 changes: 9 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,8 @@ jobs:
-Pdiktat.githubActions=true
-Pdetekt.multiplatform.disabled=true
--continue
--stacktrace
--debug
-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")
}
}

0 comments on commit 1651946

Please sign in to comment.