From 5865d06b28ad57e04de3f6b1c96e43367574d32b Mon Sep 17 00:00:00 2001 From: matejsemancik Date: Fri, 17 Nov 2023 15:14:59 +0100 Subject: [PATCH 1/5] Set up static analysis, run checks on CI --- .editorconfig | 15 ++++++++++ .github/workflows/pr-check.yml | 24 ++++++++++++++++ .github/workflows/publish.yml | 2 ++ Dangerfile | 28 +++++++++++++++++++ Gemfile | 7 +++++ config/detekt.yml | 42 ++++++++++++++++++++++++++++ gradle/libs.versions.toml | 6 +++- plugin-build/plugin/build.gradle.kts | 36 +++++++++++++++++++++++- 8 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/pr-check.yml create mode 100644 Dangerfile create mode 100644 Gemfile create mode 100644 config/detekt.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a478e30 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +[*.{kt,kts}] + +max_line_length = 130 +indent_style = space +indent_size = 4 + +insert_final_newline = true +trim_trailing_whitespace = true + +ij_kotlin_allow_trailing_comma = true +ij_kotlin_allow_trailing_comma_on_call_site = true + +continuation_indent_size = 4 +ktlint_standard_import-ordering = disabled +ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^ diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 0000000..8d6e735 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,24 @@ +name: Validate Gradle Wrapper +on: + pull_request: + branches: + - '*' + +jobs: + validation: + name: Validation + runs-on: ubuntu-latest + steps: + - name: Checkout latest code + uses: actions/checkout@v4 + - name: Run check + run: ./gradlew check + - name: Danger Report + uses: MeilCli/danger-action@v2 + continue-on-error: true + with: + plugins_file: 'Gemfile' + danger_file: 'Dangerfile' + danger_id: 'danger-pr' + env: + DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d01127b..72bb25b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,8 @@ jobs: uses: actions/checkout@v4 - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Run check + run: ./gradlew check - name: Publish on Plugin Portal run: ./gradlew --project-dir plugin-build setupPublishSecrets publishPlugins if: success() diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..58831e7 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,28 @@ +danger.import_dangerfile(github: "futuredapp/danger") + +def report_checkstyle(file_name) + if File.file?(file_name) + checkstyle_format.report file_name + end +end + +def report_all_ktlint_results(file_name) + # Get the absolute path of the current directory + current_directory = Dir.pwd + + # Recursively search for files in the current directory hierarchy + # and call the report function for files matching the given file name + Dir.glob("**/#{file_name}", File::FNM_PATHNAME | File::FNM_DOTMATCH) do |file_path| + report_checkstyle(file_path) + end +end + +# Setup checkstyle +checkstyle_format.base_path = Dir.pwd + +# Detekt report +report_checkstyle 'plugin/build/reports/detekt/detekt.xml' + +# Ktlint report +report_all_ktlint_results 'ktlintKotlinScriptCheck.xml' +report_all_ktlint_results 'ktlintMainSourceSetCheck.xml' diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a064d8b --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +# Android CI Gemfile + +source 'https://rubygems.org'; +gem 'thefuntasty_danger'; +gem 'danger-checkstyle_format'; +gem 'danger-android_lint'; +gem 'danger-junit' diff --git a/config/detekt.yml b/config/detekt.yml new file mode 100644 index 0000000..fa27346 --- /dev/null +++ b/config/detekt.yml @@ -0,0 +1,42 @@ +build: + maxIssues: 50 + excludeCorrectable: false + +config: + validation: true + warningsAsErrors: false + checkExhaustiveness: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' + +naming: + active: true + MatchingDeclarationName: + active: false + FunctionNaming: + active: true + excludes: ['**/test/**'] + functionPattern: '[a-z][a-zA-Z0-9]*' + excludeClassPattern: '$^' + +style: + active: true + UnusedPrivateMember: + active: true + MaxLineLength: + active: true + maxLineLength: 130 # Keep aligned with .editorconfig file to prevent false positives + MagicNumber: + active: true + DestructuringDeclarationWithTooManyEntries: + active: true + +complexity: + LongParameterList: + active: true + TooManyFunctions: + active: true + thresholdInInterfaces: 20 + thresholdInClasses: 20 + LongMethod: + active: true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cf130e9..8bea92d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,6 +2,8 @@ kotlin = "1.9.20" publish = "1.2.1" kotlinx-serialization = "1.6.1" +detekt = "1.23.3" +ktlintGradle = "11.6.1" [libraries] kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } @@ -9,4 +11,6 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -gradle-pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "publish" } \ No newline at end of file +gradle-pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "publish" } +detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt"} +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintGradle"} \ No newline at end of file diff --git a/plugin-build/plugin/build.gradle.kts b/plugin-build/plugin/build.gradle.kts index bc67c09..8c560aa 100644 --- a/plugin-build/plugin/build.gradle.kts +++ b/plugin-build/plugin/build.gradle.kts @@ -1,7 +1,12 @@ +import io.gitlab.arturbosch.detekt.Detekt +import org.jlleitschuh.gradle.ktlint.reporter.ReporterType + plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.serialization) alias(libs.plugins.gradle.pluginPublish) + alias(libs.plugins.detekt) + alias(libs.plugins.ktlint) } group = property("GROUP").toString() @@ -44,4 +49,33 @@ tasks.create("setupPublishSecrets") { System.setProperty("gradle.publish.key", key) System.setProperty("gradle.publish.secret", secret) } -} \ No newline at end of file +} + +detekt { + ignoreFailures = false + source.setFrom(files(projectDir)) + config.setFrom(files("$rootDir/config/detekt.yml")) + buildUponDefaultConfig = true +} + +tasks.withType { + reports { + sarif.required.set(false) + md.required.set(false) + txt.required.set(true) + xml.required.set(true) + } +} + +ktlint { + ignoreFailures.set(false) + android.set(true) + outputToConsole.set(true) + reporters { + reporter(ReporterType.PLAIN) + reporter(ReporterType.CHECKSTYLE) + } + filter { + exclude("**/generated/**") + } +} From 4298cc33bb472dbc45d62a052d4993590ad050d8 Mon Sep 17 00:00:00 2001 From: matejsemancik Date: Fri, 17 Nov 2023 15:15:13 +0100 Subject: [PATCH 2/5] Run ktlintFormat over source code --- .../localizer/GoogleSheetParser.kt | 17 +++++++------- .../localizer/ResourcesSerializer.kt | 4 ++-- .../localizer/SheetEntryAccumulator.kt | 14 ++++++------ .../sheethappens/localizer/XmlWriter.kt | 2 +- .../localizer/api/GoogleSpreadsheetsApi.kt | 2 +- .../sheethappens/localizer/model/Locale.kt | 2 +- .../localizer/model/SpreadsheetResponse.kt | 4 ++-- .../sheethappens/localizer/model/Table.kt | 2 +- .../localizer/model/XmlElement.kt | 6 ++--- .../plugin/LocalizationUpdateTask.kt | 22 +++++++++---------- .../plugin/SheetHappensExtension.kt | 7 +++--- .../sheethappens/plugin/SheetHappensPlugin.kt | 2 +- .../plugin/configuration/LanguageMapping.kt | 4 ++-- 13 files changed, 44 insertions(+), 44 deletions(-) diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/GoogleSheetParser.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/GoogleSheetParser.kt index 1aeb2eb..bfb22af 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/GoogleSheetParser.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/GoogleSheetParser.kt @@ -17,7 +17,7 @@ internal object GoogleSheetParser { response: SpreadsheetResponse, sectionColumn: String?, keyColumn: String, - languageMapping: List + languageMapping: List, ): List { val rows = response.rows check(rows.isNotEmpty()) { error("Provided spreadsheet is empty") } @@ -30,7 +30,7 @@ internal object GoogleSheetParser { } check(parsedColumns.any { it is TableColumn.Translation }) { "Google Sheet does not contain any columns specified in language mapping.\n" + - "Columns specified: ${languageMapping.map { it.columnName }.joinToString()}" + "Columns specified: ${languageMapping.map { it.columnName }.joinToString()}" } return parseEntries(rows.drop(1), parsedColumns) @@ -40,9 +40,8 @@ internal object GoogleSheetParser { row: TableRow, sectionColumn: String?, keyColumn: String, - languageMapping: List + languageMapping: List, ): List = buildList { - // Find section column row.indexOf(sectionColumn) .takeIf { index -> index >= 0 } @@ -88,11 +87,11 @@ internal object GoogleSheetParser { column.locale to SheetEntry.PluralResource.Item( key = key.pluralKeyValue(), quantityModifier = key.pluralKeyModifier(), - value = columnValue + value = columnValue, ) } .filterNotNull() - .toMap() + .toMap(), ) } else { return@mapNotNull SheetEntry.PlainResource( @@ -101,13 +100,13 @@ internal object GoogleSheetParser { val columnValue = row[column] ?: return@map null column.locale to SheetEntry.PlainResource.Item( key = key, - value = columnValue + value = columnValue, ) } .filterNotNull() - .toMap() + .toMap(), ) } } } -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/ResourcesSerializer.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/ResourcesSerializer.kt index 81a001e..945b303 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/ResourcesSerializer.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/ResourcesSerializer.kt @@ -13,7 +13,7 @@ internal object ResourcesSerializer { */ fun serialize( xmlElements: List, - outputStream: OutputStream + outputStream: OutputStream, ) { XmlWriter(outputStream).document { xmlElements.forEach { xmlElement -> @@ -84,4 +84,4 @@ private fun XmlWriter.writePluralResourceItem(quantityModifier: String, value: S private fun XmlWriter.flushAndClose() { flush() close() -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/SheetEntryAccumulator.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/SheetEntryAccumulator.kt index 4a8f264..13c62cc 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/SheetEntryAccumulator.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/SheetEntryAccumulator.kt @@ -32,7 +32,7 @@ internal object SheetEntryAccumulator { xmlEntries += XmlElement.PlainResource( key = translation.key, value = translation.value, - comments = commentsAccumulator.toList() + comments = commentsAccumulator.toList(), ) commentsAccumulator.clear() } @@ -47,10 +47,10 @@ internal object SheetEntryAccumulator { items = listOf( XmlElement.PluralResource.Item( translation.value, - translation.quantityModifier - ) + translation.quantityModifier, + ), ), - comments = commentsAccumulator.toList() + comments = commentsAccumulator.toList(), ) commentsAccumulator.clear() } else if (translation.key == pluralAccumulator.key) { @@ -58,8 +58,8 @@ internal object SheetEntryAccumulator { pluralAccumulator = pluralAccumulator.copy( items = pluralAccumulator.items + XmlElement.PluralResource.Item( value = translation.value, - quantityModifier = translation.quantityModifier - ) + quantityModifier = translation.quantityModifier, + ), ) } } @@ -84,4 +84,4 @@ internal object SheetEntryAccumulator { return xmlEntries.toList() } -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/XmlWriter.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/XmlWriter.kt index 1bda47e..527ef16 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/XmlWriter.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/XmlWriter.kt @@ -57,4 +57,4 @@ internal class XmlWriter(outputStream: OutputStream) { fun close() { writer.close() } -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/api/GoogleSpreadsheetsApi.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/api/GoogleSpreadsheetsApi.kt index 7a8e89c..7c0b7f0 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/api/GoogleSpreadsheetsApi.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/api/GoogleSpreadsheetsApi.kt @@ -26,4 +26,4 @@ internal class GoogleSpreadsheetsApi { return Json.decodeFromString(response) } -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Locale.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Locale.kt index fb0da6c..313a5e5 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Locale.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Locale.kt @@ -4,4 +4,4 @@ package app.futured.sheethappens.localizer.model * The [Locale] maps specific column in Google Sheet identified by [columnName] to resource directory * in mobile application. */ -internal data class Locale(val columnName: String, val subdirectory: String) \ No newline at end of file +internal data class Locale(val columnName: String, val subdirectory: String) diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/SpreadsheetResponse.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/SpreadsheetResponse.kt index 19e86a7..6973ea2 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/SpreadsheetResponse.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/SpreadsheetResponse.kt @@ -16,5 +16,5 @@ internal data class SpreadsheetResponse( val majorDimension: String, @SerialName("values") - val rows: List> -) \ No newline at end of file + val rows: List>, +) diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Table.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Table.kt index 592d271..253f143 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Table.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/Table.kt @@ -14,4 +14,4 @@ internal operator fun TableRow.get(column: TableColumn?): String? = column?.let internal fun String.isPluralKey() = contains("##") internal fun String.pluralKeyModifier() = substringAfter("{").replace("}", "").trim() -internal fun String.pluralKeyValue() = substringBefore("##") \ No newline at end of file +internal fun String.pluralKeyValue() = substringBefore("##") diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/XmlElement.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/XmlElement.kt index 8fe4269..1238b10 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/XmlElement.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/localizer/model/XmlElement.kt @@ -19,7 +19,7 @@ internal sealed interface XmlElement { data class PlainResource( val key: String, val value: String, - override val comments: List = emptyList() + override val comments: List = emptyList(), ) : XmlElement /** @@ -35,8 +35,8 @@ internal sealed interface XmlElement { data class PluralResource( val key: String, val items: List, - override val comments: List = emptyList() + override val comments: List = emptyList(), ) : XmlElement { data class Item(val value: String, val quantityModifier: String) } -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/LocalizationUpdateTask.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/LocalizationUpdateTask.kt index fba0420..1429533 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/LocalizationUpdateTask.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/LocalizationUpdateTask.kt @@ -45,21 +45,21 @@ abstract class LocalizationUpdateTask : DefaultTask() { @get:Input @get:Option( option = "languageMapping", - description = "Mapping of column names to subdirectories for each language in Google Sheet" + description = "Mapping of column names to subdirectories for each language in Google Sheet", ) abstract val languageMapping: ListProperty @get:InputDirectory @get:Option( option = "resourcesDir", - description = "Folder where to generate resources" + description = "Folder where to generate resources", ) abstract val resourcesDir: DirectoryProperty @get:Input @get:Option( option = "stringsFileName", - description = "Name of file where string resources will be generated" + description = "Name of file where string resources will be generated", ) @get:Optional abstract val stringsFileName: Property @@ -67,7 +67,7 @@ abstract class LocalizationUpdateTask : DefaultTask() { @get:Input @get:Option( option = "pluralsFileName", - description = "Name of file where plural resources will be generated if `splitResources` is set to `true`" + description = "Name of file where plural resources will be generated if `splitResources` is set to `true`", ) @get:Optional abstract val pluralsFileName: Property @@ -75,7 +75,7 @@ abstract class LocalizationUpdateTask : DefaultTask() { @get:Input @get:Option( option = "splitResources", - description = "If `true`, strings and plurals will be generated into two separate files instead of one." + description = "If `true`, strings and plurals will be generated into two separate files instead of one.", ) @get:Optional abstract val splitResources: Property @@ -97,13 +97,13 @@ abstract class LocalizationUpdateTask : DefaultTask() { val apiResponse = GoogleSpreadsheetsApi().download( spreadsheetId = spreadsheetId.get(), sheetName = sheetName.get(), - apiKey = apiKey.get() + apiKey = apiKey.get(), ) val sheetEntries = GoogleSheetParser.parse( response = apiResponse, sectionColumn = sectionColumnName, keyColumn = keyColumnName.get(), - languageMapping = languageMapping.get() + languageMapping = languageMapping.get(), ) val detectedLocales = sheetEntries .filterIsInstance() @@ -123,19 +123,19 @@ abstract class LocalizationUpdateTask : DefaultTask() { if (xmlElements.any { it is XmlElement.PlainResource }) { writeResources( xmlElements = xmlElements.filterIsInstance(), - file = stringsFile + file = stringsFile, ) } if (xmlElements.any { it is XmlElement.PluralResource }) { writeResources( xmlElements = xmlElements.filterIsInstance(), - file = pluralsFile + file = pluralsFile, ) } } else if (xmlElements.any()) { writeResources( xmlElements = xmlElements, - file = stringsFile + file = stringsFile, ) } } @@ -148,4 +148,4 @@ abstract class LocalizationUpdateTask : DefaultTask() { file.createNewFile() ResourcesSerializer.serialize(xmlElements, file.outputStream()) } -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensExtension.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensExtension.kt index 90fbd48..74dec83 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensExtension.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensExtension.kt @@ -16,9 +16,10 @@ open class SheetHappensExtension @Inject constructor(objects: ObjectFactory) { companion object { internal fun createFor(project: Project): SheetHappensExtension = - project.extensions.create(/* name = */ "sheetHappens",/* type = */ - SheetHappensExtension::class.java,/* ...constructionArguments = */ - project.objects + project.extensions.create(/* name = */ + "sheetHappens", /* type = */ + SheetHappensExtension::class.java, /* ...constructionArguments = */ + project.objects, ) } diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensPlugin.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensPlugin.kt index dab34d9..dc552ca 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensPlugin.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/SheetHappensPlugin.kt @@ -23,4 +23,4 @@ open class SheetHappensPlugin : Plugin { task.splitResources.set(extension.resourcesLayout.splitResources) } } -} \ No newline at end of file +} diff --git a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/configuration/LanguageMapping.kt b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/configuration/LanguageMapping.kt index fb94b6d..7e2105f 100644 --- a/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/configuration/LanguageMapping.kt +++ b/plugin-build/plugin/src/main/kotlin/app/futured/sheethappens/plugin/configuration/LanguageMapping.kt @@ -10,5 +10,5 @@ import java.io.Serializable */ data class LanguageMapping( val columnName: String, - val subdirectory: String -) : Serializable \ No newline at end of file + val subdirectory: String, +) : Serializable From 895aca0ef2bad70b3c565e5dd966b1f7f0b18689 Mon Sep 17 00:00:00 2001 From: matejsemancik Date: Fri, 17 Nov 2023 15:17:21 +0100 Subject: [PATCH 3/5] Rename workflow --- .github/workflows/pr-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 8d6e735..c403ba5 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -1,4 +1,4 @@ -name: Validate Gradle Wrapper +name: Check Pull Request on: pull_request: branches: From 4979471ca60df1fafe3db92307e35d8456560248 Mon Sep 17 00:00:00 2001 From: matejsemancik Date: Fri, 17 Nov 2023 15:17:46 +0100 Subject: [PATCH 4/5] Add concurrency to PR check workflow, cancel in progress --- .github/workflows/pr-check.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index c403ba5..4e11ce9 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -4,6 +4,10 @@ on: branches: - '*' +concurrency: + group: ${{ github.head_ref }} + cancel-in-progress: true + jobs: validation: name: Validation From ad9c29209a8c45d9b2b711d2a302196a4c82365e Mon Sep 17 00:00:00 2001 From: matejsemancik Date: Mon, 20 Nov 2023 18:58:52 +0100 Subject: [PATCH 5/5] Update workflows for composite build, remove Danger --- .../workflows/gradle-wrapper-validation.yml | 2 +- .github/workflows/pr-check.yml | 15 ++-------- .github/workflows/publish.yml | 2 +- Dangerfile | 28 ------------------- Gemfile | 7 ----- config/detekt.yml | 2 +- plugin-build/gradle/libs.versions.toml | 14 ---------- plugin-build/plugin/build.gradle.kts | 2 +- plugin-build/settings.gradle.kts | 8 +++++- 9 files changed, 14 insertions(+), 66 deletions(-) delete mode 100644 Dangerfile delete mode 100644 Gemfile delete mode 100644 plugin-build/gradle/libs.versions.toml diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index aa6c8b9..bafb330 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -9,7 +9,7 @@ on: jobs: validation: - name: Validation + name: Gradle Wrapper Validation runs-on: ubuntu-latest steps: - name: Checkout latest code diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 4e11ce9..977ef65 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -9,20 +9,11 @@ concurrency: cancel-in-progress: true jobs: - validation: - name: Validation + check: + name: Check runs-on: ubuntu-latest steps: - name: Checkout latest code uses: actions/checkout@v4 - name: Run check - run: ./gradlew check - - name: Danger Report - uses: MeilCli/danger-action@v2 - continue-on-error: true - with: - plugins_file: 'Gemfile' - danger_file: 'Dangerfile' - danger_id: 'danger-pr' - env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + run: ./gradlew --project-dir plugin-build check \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 72bb25b..ecd5b61 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,7 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Run check - run: ./gradlew check + run: ./gradlew --project-dir plugin-build check - name: Publish on Plugin Portal run: ./gradlew --project-dir plugin-build setupPublishSecrets publishPlugins if: success() diff --git a/Dangerfile b/Dangerfile deleted file mode 100644 index 58831e7..0000000 --- a/Dangerfile +++ /dev/null @@ -1,28 +0,0 @@ -danger.import_dangerfile(github: "futuredapp/danger") - -def report_checkstyle(file_name) - if File.file?(file_name) - checkstyle_format.report file_name - end -end - -def report_all_ktlint_results(file_name) - # Get the absolute path of the current directory - current_directory = Dir.pwd - - # Recursively search for files in the current directory hierarchy - # and call the report function for files matching the given file name - Dir.glob("**/#{file_name}", File::FNM_PATHNAME | File::FNM_DOTMATCH) do |file_path| - report_checkstyle(file_path) - end -end - -# Setup checkstyle -checkstyle_format.base_path = Dir.pwd - -# Detekt report -report_checkstyle 'plugin/build/reports/detekt/detekt.xml' - -# Ktlint report -report_all_ktlint_results 'ktlintKotlinScriptCheck.xml' -report_all_ktlint_results 'ktlintMainSourceSetCheck.xml' diff --git a/Gemfile b/Gemfile deleted file mode 100644 index a064d8b..0000000 --- a/Gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# Android CI Gemfile - -source 'https://rubygems.org'; -gem 'thefuntasty_danger'; -gem 'danger-checkstyle_format'; -gem 'danger-android_lint'; -gem 'danger-junit' diff --git a/config/detekt.yml b/config/detekt.yml index fa27346..52e995b 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -1,5 +1,5 @@ build: - maxIssues: 50 + maxIssues: 5 excludeCorrectable: false config: diff --git a/plugin-build/gradle/libs.versions.toml b/plugin-build/gradle/libs.versions.toml deleted file mode 100644 index ef10e7e..0000000 --- a/plugin-build/gradle/libs.versions.toml +++ /dev/null @@ -1,14 +0,0 @@ -[versions] -kotlin = "1.9.20" -publish = "1.2.1" -kotlinx-serialization = "1.6.1" -sheetHappens = "0.5.6" - -[libraries] -kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } - -[plugins] -kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -gradle-pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "publish" } -sheetHappens = { id = "app.futured.sheethappens", version.ref = "sheetHappens" } \ No newline at end of file diff --git a/plugin-build/plugin/build.gradle.kts b/plugin-build/plugin/build.gradle.kts index 8c560aa..e191c6e 100644 --- a/plugin-build/plugin/build.gradle.kts +++ b/plugin-build/plugin/build.gradle.kts @@ -54,7 +54,7 @@ tasks.create("setupPublishSecrets") { detekt { ignoreFailures = false source.setFrom(files(projectDir)) - config.setFrom(files("$rootDir/config/detekt.yml")) + config.setFrom(files("$rootDir/../config/detekt.yml")) buildUponDefaultConfig = true } diff --git a/plugin-build/settings.gradle.kts b/plugin-build/settings.gradle.kts index de65bdd..a08482c 100644 --- a/plugin-build/settings.gradle.kts +++ b/plugin-build/settings.gradle.kts @@ -9,8 +9,14 @@ dependencyResolutionManagement { repositories { mavenCentral() } + + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } } rootProject.name = "app.futured.sheethappens" -include(":plugin") \ No newline at end of file +include(":plugin")