From 5f3046325fd1c9beb38b8ff95912f6f24647b540 Mon Sep 17 00:00:00 2001 From: Enzo Mallard Date: Wed, 4 Dec 2024 21:21:31 +0000 Subject: [PATCH] Update CI --- .github/workflows/build.yml | 22 ++---- .github/workflows/release.yml | 4 +- .github/workflows/run-ui-tests.yml | 4 +- build.gradle.kts | 116 ++++++++++++++++------------- gradle.properties | 4 +- gradle/libs.versions.toml | 12 +-- settings.gradle.kts | 4 + 7 files changed, 87 insertions(+), 79 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87773a4..8ae6115 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true - + jobs: # Prepare environment and build the plugin @@ -36,26 +36,24 @@ jobs: pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} steps: - # Check out current repository + # Check out the current repository - name: Fetch Sources uses: actions/checkout@v4 # Validate wrapper - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v3 + uses: gradle/actions/wrapper-validation@v3 # Set up Java environment for the next steps - name: Setup Java uses: actions/setup-java@v4 with: distribution: zulu - java-version: 21 + java-version: 17 # Setup Gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - with: - gradle-home-cache-cleanup: true # Set environment variables - name: Export Properties @@ -111,13 +109,11 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 21 + java-version: 17 # Setup Gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - with: - gradle-home-cache-cleanup: true # Run tests - name: Run Tests @@ -167,11 +163,11 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 21 + java-version: 17 # Run Qodana inspections - name: Qodana - Code Inspection - uses: JetBrains/qodana-action@v2024.2.6 + uses: JetBrains/qodana-action@v2024.2 with: cache-default-branch-only: true @@ -198,13 +194,11 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 21 + java-version: 17 # Setup Gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - with: - gradle-home-cache-cleanup: true # Cache Plugin Verifier IDEs - name: Setup Plugin Verifier IDEs Cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f9c819..767e7c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,13 +29,11 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 21 + java-version: 17 # Setup Gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - with: - gradle-home-cache-cleanup: true # Set environment variables - name: Export Properties diff --git a/.github/workflows/run-ui-tests.yml b/.github/workflows/run-ui-tests.yml index dfd1d38..c924cb9 100644 --- a/.github/workflows/run-ui-tests.yml +++ b/.github/workflows/run-ui-tests.yml @@ -40,13 +40,11 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 21 + java-version: 17 # Setup Gradle - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - with: - gradle-home-cache-cleanup: true # Run IDEA prepared for UI testing - name: Run IDE diff --git a/build.gradle.kts b/build.gradle.kts index 2ce3866..a53e48d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,20 +1,18 @@ import org.jetbrains.changelog.Changelog import org.jetbrains.changelog.markdownToHTML - -fun properties(key: String) = providers.gradleProperty(key) -fun environment(key: String) = providers.environmentVariable(key) +import org.jetbrains.intellij.platform.gradle.TestFrameworkType plugins { id("java") // Java support alias(libs.plugins.kotlin) // Kotlin support - alias(libs.plugins.intelliJPlatformPlugin) // IntelliJ Platform Plugin + alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin alias(libs.plugins.changelog) // Gradle Changelog Plugin alias(libs.plugins.qodana) // Gradle Qodana Plugin alias(libs.plugins.kover) // Gradle Kover Plugin } -group = properties("pluginGroup").get() -version = properties("pluginVersion").get() +group = providers.gradleProperty("pluginGroup").get() +version = providers.gradleProperty("pluginVersion").get() // Configure project's dependencies repositories { @@ -26,42 +24,40 @@ repositories { // Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { - implementation(libs.annotations) + testImplementation(libs.junit) + + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html intellijPlatform { - create(properties("platformType"), properties("platformVersion")) + create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion")) pluginVerifier() zipSigner() instrumentationTools() - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins(properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }) - bundledPlugins(properties("platformBundledPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }) + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) + + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) } } -// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, Java 17 for 2022.2+, and Java 21 for 2024.2+. +// Set the JVM language level used to build the project. kotlin { - jvmToolchain(properties("javaVersion").get().toInt()) + jvmToolchain(17) } -// Configure IntelliJ Platform Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html intellijPlatform { pluginConfiguration { - name = properties("pluginName") - version = properties("pluginVersion") - - ideaVersion { - sinceBuild = properties("pluginSinceBuild") - untilBuild = properties("pluginUntilBuild") - } + version = providers.gradleProperty("pluginVersion") // Extract the section from README.md and provide for the plugin's manifest description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { val start = "" val end = "" - with (it.lines()) { + with(it.lines()) { if (!containsAll(listOf(start, end))) { throw GradleException("Plugin description section not found in README.md:\n$start ... $end") } @@ -71,7 +67,7 @@ intellijPlatform { val changelog = project.changelog // local variable for configuration cache compatibility // Get the latest available change notes from the changelog file - changeNotes = properties("pluginVersion").map { pluginVersion -> + changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> with(changelog) { renderItem( (getOrNull(pluginVersion) ?: getUnreleased()) @@ -81,60 +77,78 @@ intellijPlatform { ) } } + + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") + untilBuild = providers.gradleProperty("pluginUntilBuild") + } + } + + signing { + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") + privateKey = providers.environmentVariable("PRIVATE_KEY") + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") } publishing { - //dependsOn("patchChangelog") - token = environment("PUBLISH_TOKEN") + token = providers.environmentVariable("PUBLISH_TOKEN") // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel - channels = properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) } + channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } } - signing { - certificateChain = environment("CERTIFICATE_CHAIN") - privateKey = environment("PRIVATE_KEY") - password = environment("PRIVATE_KEY_PASSWORD") + pluginVerification { + ides { + recommended() + } } } // Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin changelog { groups.empty() - repositoryUrl = properties("pluginRepositoryUrl") + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") } // Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration -koverReport { - defaults { - xml { - onCheck = true +kover { + reports { + total { + xml { + onCheck = true + } } } } tasks { wrapper { - gradleVersion = properties("gradleVersion").get() + gradleVersion = providers.gradleProperty("gradleVersion").get() } - // Configure UI tests plugin - // Read more: https://github.com/JetBrains/intellij-ui-test-robot - intellijPlatformTesting.runIde.register("runIdeForUiTests") { - task { - jvmArgumentProviders += CommandLineArgumentProvider { - listOf( - "-Drobot-server.port=8082", - "-Dide.mac.message.dialogs.as.sheets=false", - "-Djb.privacy.policy.text=", - "-Djb.consents.confirmation.enabled=false", - ) + publishPlugin { + dependsOn(patchChangelog) + } +} + +intellijPlatformTesting { + runIde { + register("runIdeForUiTests") { + task { + jvmArgumentProviders += CommandLineArgumentProvider { + listOf( + "-Drobot-server.port=8082", + "-Dide.mac.message.dialogs.as.sheets=false", + "-Djb.privacy.policy.text=", + "-Djb.consents.confirmation.enabled=false", + ) + } } - } - plugins { - robotServerPlugin() + plugins { + robotServerPlugin() + } } } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ed4c054..88d2882 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ pluginRepositoryUrl = https://plugins.jetbrains.com/plugin/17450-ngtranslate-too # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild = 242 +pluginSinceBuild = 233 pluginUntilBuild = 243.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#custom-target-platforms @@ -22,7 +22,7 @@ platformPlugins = platformBundledPlugins = JavaScript, AngularJS # Java language level used to compile sources and to generate the files for - Java 17 is required since 2022.2 -javaVersion = 21 +# DELETE: javaVersion = 21 # Gradle Releases -> https://github.com/gradle/gradle/releases gradleVersion = 8.10.2 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2a495a9..9a9fe08 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,18 +3,18 @@ annotations = "24.1.0" # plugins -kotlin = "1.9.23" -changelog = "2.2.0" -intelliJPlatformPlugin = "2.1.0" -qodana = "2023.3.1" -kover = "0.7.6" +kotlin = "1.9.25" +changelog = "2.2.1" +intelliJPlatform = "2.1.0" +qodana = "2024.2.3" +kover = "0.8.3" [libraries] annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" } [plugins] changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } -intelliJPlatformPlugin = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatformPlugin" } +intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" } kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" } diff --git a/settings.gradle.kts b/settings.gradle.kts index cb2ecf0..3b81db3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,5 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} + rootProject.name = "idea-ngx-translate-autocomplete"