From a4f16940d89453b3b1fb447afc480539f4b6b16a Mon Sep 17 00:00:00 2001 From: Ben Gibson Date: Thu, 29 Aug 2024 20:51:39 +0100 Subject: [PATCH] Update build (#330) --- .github/workflows/build.yml | 158 +++++++++++----- .github/workflows/release.yml | 34 +++- .github/workflows/run-ui-tests.yml | 27 +-- .gitignore | 1 + build.gradle.kts | 172 +++++++++++------- gradle.properties | 24 ++- gradle/libs.versions.toml | 24 ++- gradle/wrapper/gradle-wrapper.properties | 4 +- qodana.yml | 6 + .../link/ui/actions/vcslog/BrowserAction.kt | 10 +- .../git/link/ui/actions/vcslog/CopyAction.kt | 9 +- .../link/ui/actions/vcslog/MarkdownAction.kt | 9 +- .../ui/actions/vcslog/BrowserActionTest.kt | 11 +- 13 files changed, 313 insertions(+), 176 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c4d5ef7..df430036 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,12 @@ -# GitHub Actions Workflow created for testing and preparing the plugin release in following steps: -# - validate Gradle Wrapper, -# - run 'test' and 'verifyPlugin' tasks, -# - run Qodana inspections, -# - run 'buildPlugin' task and prepare artifact for the further tests, -# - run 'runPluginVerifier' task, -# - create a draft release. +# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps: +# - Validate Gradle Wrapper. +# - Run 'test' and 'verifyPlugin' tasks. +# - Run Qodana inspections. +# - Run the 'buildPlugin' task and prepare artifact for further tests. +# - Run the 'runPluginVerifier' task. +# - Create a draft release. # -# Workflow is triggered on push and PULL_REQUEST events. +# The workflow is triggered on push and pull_request events. # # GitHub Actions reference: https://help.github.com/en/actions # @@ -14,17 +14,19 @@ name: Build on: - # Trigger the workflow on pushes to only the 'master' branch (this avoids duplicate checks being run e.g. for dependabot pull requests) + # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests) push: - branches: [master] + branches: [ main ] # Trigger the workflow on any pull request pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: - # Run Gradle Wrapper Validation Action to verify the wrapper's checksum - # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks - # Build plugin and provide the artifact for the next workflow jobs + # Prepare environment and build the plugin build: name: Build runs-on: ubuntu-latest @@ -34,24 +36,26 @@ jobs: pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} steps: - # Free GitHub Actions Environment Disk Space - - name: Maximize Build Space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt/ghc - - # Check out current repository + # Check out the current repository - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Validate wrapper - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1.0.6 + 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: 17 # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true # Set environment variables - name: Export Properties @@ -69,8 +73,6 @@ jobs: echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier - # Build plugin - name: Build plugin run: ./gradlew buildPlugin @@ -88,25 +90,34 @@ jobs: # Store already-built plugin as an artifact for downloading - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ steps.artifact.outputs.filename }} path: ./build/distributions/content/*/* - # Run tests + # Run tests and upload a code coverage report test: name: Test - needs: build + needs: [ build ] runs-on: ubuntu-latest steps: - # Check out current repository + # Check out the current repository - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + # Set up Java environment for the next steps + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true # Run tests - name: Run Tests @@ -115,41 +126,98 @@ jobs: # Collect Tests Result of failed tests - name: Collect Tests Result if: ${{ failure() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: tests-result path: ${{ github.workspace }}/build/reports/tests + # Upload the Kover report to CodeCov + - name: Upload Code Coverage Report + uses: codecov/codecov-action@v4 + with: + files: ${{ github.workspace }}/build/reports/kover/report.xml + + # Run Qodana inspections and provide report + inspectCode: + name: Inspect code + needs: [ build ] + runs-on: ubuntu-latest + permissions: + contents: write + checks: write + pull-requests: write + steps: + + # Free GitHub Actions Environment Disk Space + - name: Maximize Build Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + large-packages: false + + # Check out the current repository + - name: Fetch Sources + uses: actions/checkout@v4 + + # Set up Java environment for the next steps + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + + # Run Qodana inspections + - name: Qodana - Code Inspection + uses: JetBrains/qodana-action@v2024.1.5 + with: + cache-default-branch-only: true + # Run plugin structure verification along with IntelliJ Plugin Verifier verify: name: Verify plugin - needs: build + needs: [ build ] runs-on: ubuntu-latest steps: - # Check out current repository + # Free GitHub Actions Environment Disk Space + - name: Maximize Build Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + large-packages: false + + # Check out the current repository - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + # Set up Java environment for the next steps + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true # Cache Plugin Verifier IDEs - name: Setup Plugin Verifier IDEs Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} # Run Verify Plugin task and IntelliJ Plugin Verifier tool - name: Run Plugin Verification tasks - run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} + run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }} # Collect Plugin Verifier Result - name: Collect Plugin Verifier Result if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: pluginVerifier-result path: ${{ github.workspace }}/build/reports/pluginVerifier @@ -159,15 +227,15 @@ jobs: releaseDraft: name: Release draft if: github.event_name != 'pull_request' - needs: [ build, test, verify ] + needs: [ build, test, inspectCode, verify ] runs-on: ubuntu-latest permissions: contents: write steps: - # Check out current repository + # Check out the current repository - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Remove old release drafts by using the curl request for the available releases with a draft flag - name: Remove Old Release Drafts @@ -183,10 +251,10 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release create v${{ needs.build.outputs.version }} \ + gh release create "v${{ needs.build.outputs.version }}" \ --draft \ --title "v${{ needs.build.outputs.version }}" \ --notes "$(cat << 'EOM' ${{ needs.build.outputs.changelog }} EOM - )" + )" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b23f6761..666c1166 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,6 @@ -# GitHub Actions Workflow created for handling the release process based on the draft release prepared -# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided. +# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow. +# Running the publishPlugin task requires all following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN. +# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information. name: Release on: @@ -8,7 +9,7 @@ on: jobs: - # Prepare and publish the plugin to the Marketplace repository + # Prepare and publish the plugin to JetBrains Marketplace repository release: name: Publish Plugin runs-on: ubuntu-latest @@ -17,15 +18,24 @@ jobs: pull-requests: write steps: - # Check out current repository + # Check out the current repository - name: Fetch Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.release.tag_name }} + # Set up Java environment for the next steps + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + # Setup Gradle - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true # Set environment variables - name: Export Properties @@ -41,7 +51,7 @@ jobs: echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - # Update Unreleased section with the current release note + # Update the Unreleased section with the current release note - name: Patch Changelog if: ${{ steps.properties.outputs.changelog != '' }} env: @@ -49,10 +59,13 @@ jobs: run: | ./gradlew patchChangelog --release-note="$CHANGELOG" - # Publish the plugin to the Marketplace + # Publish the plugin to JetBrains Marketplace - name: Publish Plugin env: PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }} run: ./gradlew publishPlugin # Upload artifact as a release asset @@ -61,7 +74,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/* - # Create pull request + # Create a pull request - name: Create Pull Request if: ${{ steps.properties.outputs.changelog != '' }} env: @@ -80,10 +93,11 @@ jobs: gh label create "$LABEL" \ --description "Pull requests with release changelog update" \ + --force \ || true gh pr create \ --title "Changelog update - \`$VERSION\`" \ --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \ --label "$LABEL" \ - --head $BRANCH + --head $BRANCH \ No newline at end of file diff --git a/.github/workflows/run-ui-tests.yml b/.github/workflows/run-ui-tests.yml index 7416d545..672b0a2e 100644 --- a/.github/workflows/run-ui-tests.yml +++ b/.github/workflows/run-ui-tests.yml @@ -1,9 +1,9 @@ # GitHub Actions Workflow for launching UI tests on Linux, Windows, and Mac in the following steps: -# - prepare and launch IDE with your plugin and robot-server plugin, which is needed to interact with UI -# - wait for IDE to start -# - run UI tests with separate Gradle task +# - Prepare and launch IDE with your plugin and robot-server plugin, which is needed to interact with the UI. +# - Wait for IDE to start. +# - Run UI tests with a separate Gradle task. # -# Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ Platform +# Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ Platform. # # Workflow is triggered manually. @@ -31,17 +31,22 @@ jobs: steps: - # Check out current repository + # Check out the current repository - name: Fetch Sources - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v4 - # Setup Java 11 environment for the next steps + # Set up Java environment for the next steps - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: zulu java-version: 17 - cache: gradle + + # Setup Gradle + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true # Run IDEA prepared for UI testing - name: Run IDE @@ -49,7 +54,7 @@ jobs: # Wait for IDEA to be started - name: Health Check - uses: jtalk/url-health-check-action@v2 + uses: jtalk/url-health-check-action@v4 with: url: http://127.0.0.1:8082 max-attempts: 15 @@ -57,4 +62,4 @@ jobs: # Run tests - name: Tests - run: ./gradlew test + run: ./gradlew test \ No newline at end of file diff --git a/.gitignore b/.gitignore index e2e5d94e..bfc79a99 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea .qodana build +.intellijPlatform \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index a0808bd1..797b4bd0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,76 +1,71 @@ 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.gradleIntelliJPlugin) // Gradle IntelliJ 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() + +// Set the JVM language level used to build the project. +kotlin { + jvmToolchain(17) +} // Configure project's dependencies repositories { mavenCentral() -} - -dependencies { - testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.0") - testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") - testImplementation("io.mockk:mockk:1.13.5") - implementation(files("libs/url-0.0.10.jar")) - implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.10") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") -} -// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+. -kotlin { - jvmToolchain(17) + // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html + intellijPlatform { + defaultRepositories() + } } -tasks.test { - useJUnitPlatform() -} +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog +dependencies { + testImplementation(libs.junit) + testImplementation(libs.junitJupiter) + testImplementation(libs.junitJupiterParams) + testImplementation(libs.mockk) -// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin -intellij { - pluginName = properties("pluginName") - version = properties("platformVersion") - type = properties("platformType") - updateSinceUntilBuild.set(false) + implementation(files("libs/url-0.0.10.jar")) - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } -} + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html + intellijPlatform { + create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion")) -// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin -changelog { - groups.empty() - repositoryUrl = properties("pluginRepositoryUrl") -} + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) -tasks { + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) - wrapper { - gradleVersion = properties("gradleVersion").get() + instrumentationTools() + pluginVerifier() + zipSigner() + testFramework(TestFrameworkType.Platform) } +} - patchPluginXml { - version = properties("pluginVersion") - sinceBuild = properties("pluginSinceBuild") - // untilBuild = properties("pluginUntilBuild") +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + pluginConfiguration { + version = providers.gradleProperty("pluginVersion") // Extract the section from README.md and provide for the plugin's manifest - pluginDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + 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") } @@ -80,7 +75,7 @@ tasks { 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()) @@ -90,29 +85,82 @@ tasks { ) } } - } - // Configure UI tests plugin - // Read more: https://github.com/JetBrains/intellij-ui-test-robot - runIdeForUiTests { - systemProperty("robot-server.port", "8082") - systemProperty("ide.mac.message.dialogs.as.sheets", "false") - systemProperty("jb.privacy.policy.text", "") - systemProperty("jb.consents.confirmation.enabled", "false") + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") + untilBuild = providers.gradleProperty("pluginUntilBuild") + } } - signPlugin { - certificateChain = environment("CERTIFICATE_CHAIN") - privateKey = environment("PRIVATE_KEY") - password = environment("PRIVATE_KEY_PASSWORD") + signing { + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") + privateKey = providers.environmentVariable("PRIVATE_KEY") + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") } - publishPlugin { - dependsOn("patchChangelog") - token = environment("PUBLISH_TOKEN") + publishing { + 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" }) } + } + + pluginVerification { + ides { + recommended() + } + } +} + +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +changelog { + groups.empty() + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") +} + +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration +kover { + reports { + total { + xml { + onCheck = true + } + } + } +} + +tasks { + wrapper { + gradleVersion = providers.gradleProperty("gradleVersion").get() + } + + 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() + } + } + } +} + +tasks.test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 8552b4e2..2e8cb63e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,34 +4,32 @@ pluginGroup = uk.co.ben_gibson.git.link pluginName = GitLink # SemVer format -> https://semver.org -pluginVersion = 4.4.0 +pluginVersion = 4.5.0 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. -pluginSinceBuild = 223 +pluginSinceBuild = 233 #pluginUntilBuild = 222.* # IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties platformType = IC -platformVersion = 2022.3 +platformVersion = 2023.3.7 # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = Git4Idea +platformPlugins = + +# Example: platformBundledPlugins = com.intellij.java +platformBundledPlugins = Git4Idea # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 8.2 +gradleVersion = 8.9 -# Opt-out flag for bundling Kotlin standard library. -# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details. -# suppress inspection "UnusedProperty" +# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency = false # Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html -org.gradle.unsafe.configuration-cache = true +org.gradle.configuration-cache = true # Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html -org.gradle.caching = true - -# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment -systemProp.org.gradle.unsafe.kotlin.assignment = true \ No newline at end of file +org.gradle.caching = true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 05d56f8f..0328263d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,16 +1,26 @@ [versions] # libraries -annotations = "24.0.1" +junit = "4.13.2" +junitJupiter = "5.8.2" # Version for junit-jupiter +junitJupiterParams = "5.9.0" # Version for junit-jupiter-params +mockk = "1.13.5" # Version for MockK # plugins -kotlin = "1.9.0" -changelog = "2.1.1" -gradleIntelliJPlugin = "1.15.0" +changelog = "2.2.1" +intelliJPlatform = "2.0.1" +kotlin = "1.9.25" +kover = "0.8.3" +qodana = "2024.1.9" [libraries] -annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +junitJupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junitJupiter" } +junitJupiterParams = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junitJupiterParams" } +mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } [plugins] changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } -gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" } -kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } \ No newline at end of file +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" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a3638774..a76cbf9c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ +#Tue Aug 27 21:05:28 BST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip -networkTimeout=10000 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/qodana.yml b/qodana.yml index dac95d31..0be93537 100644 --- a/qodana.yml +++ b/qodana.yml @@ -2,5 +2,11 @@ # https://www.jetbrains.com/help/qodana/qodana-yaml.html version: 1.0 +linter: jetbrains/qodana-jvm-community:latest +projectJDK: "17" profile: name: qodana.recommended +exclude: + - name: All + paths: + - .qodana \ No newline at end of file diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserAction.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserAction.kt index 793cf37e..b49311a1 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserAction.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserAction.kt @@ -2,7 +2,7 @@ package uk.co.ben_gibson.git.link.ui.actions.vcslog import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.Project -import com.intellij.vcs.log.VcsLogDataKeys +import com.intellij.vcs.log.VcsLogDataKeys.VCS_LOG_COMMIT_SELECTION import uk.co.ben_gibson.git.link.Context import uk.co.ben_gibson.git.link.ContextCommit import uk.co.ben_gibson.git.link.git.Commit @@ -10,16 +10,12 @@ import uk.co.ben_gibson.git.link.ui.actions.Action class BrowserAction: Action(Type.BROWSER) { override fun buildContext(project: Project, event: AnActionEvent) : Context? { - val vcsLog = event.getData(VcsLogDataKeys.VCS_LOG) ?: return null - - val vcsCommit = vcsLog.selectedDetails[0] + val vcsCommit = event.getData(VCS_LOG_COMMIT_SELECTION)?.cachedFullDetails?.get(0) ?: return null return ContextCommit(vcsCommit.root, Commit(vcsCommit.id.asString())) } override fun shouldBeEnabled(event: AnActionEvent): Boolean { - val log = event.getData(VcsLogDataKeys.VCS_LOG) ?: return false - - return log.selectedDetails.size == 1 + return event.getData(VCS_LOG_COMMIT_SELECTION)?.cachedFullDetails?.size == 1 } } \ No newline at end of file diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/CopyAction.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/CopyAction.kt index 8b9c6463..3684d652 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/CopyAction.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/CopyAction.kt @@ -2,7 +2,7 @@ package uk.co.ben_gibson.git.link.ui.actions.vcslog import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.Project -import com.intellij.vcs.log.VcsLogDataKeys +import com.intellij.vcs.log.VcsLogDataKeys.VCS_LOG_COMMIT_SELECTION import uk.co.ben_gibson.git.link.Context import uk.co.ben_gibson.git.link.ContextCommit import uk.co.ben_gibson.git.link.git.Commit @@ -10,15 +10,12 @@ import uk.co.ben_gibson.git.link.ui.actions.Action class CopyAction: Action(Type.COPY) { override fun buildContext(project: Project, event: AnActionEvent): Context? { - val vcsLog = event.getData(VcsLogDataKeys.VCS_LOG) ?: return null - val vcsCommit = vcsLog.selectedDetails[0] + val vcsCommit = event.getData(VCS_LOG_COMMIT_SELECTION)?.cachedFullDetails?.get(0) ?: return null return ContextCommit(vcsCommit.root, Commit(vcsCommit.id.toString())) } override fun shouldBeEnabled(event: AnActionEvent): Boolean { - val log = event.getData(VcsLogDataKeys.VCS_LOG) ?: return false - - return log.selectedDetails.size == 1 + return event.getData(VCS_LOG_COMMIT_SELECTION)?.cachedFullDetails?.size == 1 } } \ No newline at end of file diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/MarkdownAction.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/MarkdownAction.kt index 16dc1aa9..99c9a7a7 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/MarkdownAction.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/MarkdownAction.kt @@ -2,7 +2,7 @@ package uk.co.ben_gibson.git.link.ui.actions.vcslog import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.Project -import com.intellij.vcs.log.VcsLogDataKeys +import com.intellij.vcs.log.VcsLogDataKeys.VCS_LOG_COMMIT_SELECTION import uk.co.ben_gibson.git.link.Context import uk.co.ben_gibson.git.link.ContextCommit import uk.co.ben_gibson.git.link.git.Commit @@ -10,15 +10,12 @@ import uk.co.ben_gibson.git.link.ui.actions.Action class MarkdownAction: Action(Type.COPY_MARKDOWN) { override fun buildContext(project: Project, event: AnActionEvent): Context? { - val vcsLog = event.getData(VcsLogDataKeys.VCS_LOG) ?: return null - val vcsCommit = vcsLog.selectedDetails[0] + val vcsCommit = event.getData(VCS_LOG_COMMIT_SELECTION)?.cachedFullDetails?.get(0) ?: return null return ContextCommit(vcsCommit.root, Commit(vcsCommit.id.toString())) } override fun shouldBeEnabled(event: AnActionEvent): Boolean { - val log = event.getData(VcsLogDataKeys.VCS_LOG) ?: return false - - return log.selectedDetails.size == 1 + return event.getData(VCS_LOG_COMMIT_SELECTION)?.cachedFullDetails?.size == 1 } } \ No newline at end of file diff --git a/src/test/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserActionTest.kt b/src/test/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserActionTest.kt index dea57b4e..8f5bb2d5 100644 --- a/src/test/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserActionTest.kt +++ b/src/test/kotlin/uk/co/ben_gibson/git/link/ui/actions/vcslog/BrowserActionTest.kt @@ -3,10 +3,7 @@ package uk.co.ben_gibson.git.link.ui.actions.vcslog import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import com.intellij.vcs.log.Hash -import com.intellij.vcs.log.VcsLog -import com.intellij.vcs.log.VcsLogDataKeys -import com.intellij.vcs.log.VcsUser +import com.intellij.vcs.log.* import com.intellij.vcs.log.impl.HashImpl import com.intellij.vcs.log.impl.VcsFileStatusInfo import git4idea.GitCommit @@ -53,11 +50,11 @@ class BrowserActionTest { mockk() ) - val vcsLog = mockk() - every { vcsLog.selectedDetails } returns listOf(commit) + val vcsLog = mockk() + every { vcsLog.cachedFullDetails } returns listOf(commit) val anActionEvent = mockk() - every { anActionEvent.getData(VcsLogDataKeys.VCS_LOG) } returns vcsLog + every { anActionEvent.getData(VcsLogDataKeys.VCS_LOG_COMMIT_SELECTION) } returns vcsLog return anActionEvent }