Skip to content

Commit

Permalink
Merge pull request #461 from koxudaxi/support_242_EAP
Browse files Browse the repository at this point in the history
Support 242 EAP
  • Loading branch information
koxudaxi committed Jul 24, 2024
2 parents a4f6813 + 9a38700 commit df941b9
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 89 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
gradle-version: 8.6

# Set environment variables
- name: Export Properties
Expand All @@ -81,7 +82,7 @@ jobs:
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
./gradlew printProductsReleases # prepare list of IDEs for Plugin Verifier
# Build plugin
- name: Build plugin
Expand Down Expand Up @@ -232,11 +233,11 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
key: plugin-verifier-${{ hashFiles('build/printProductsReleases.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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## [Unreleased]
- Support 242 EAP[[#461](https://github.com/koxudaxi/pydantic-pycharm-plugin/pull/#461)]

## [0.0.34] - 2024-06-28

Expand Down
123 changes: 61 additions & 62 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.extensions.intellijPlatform

fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)
Expand All @@ -19,6 +21,10 @@ version = properties("pluginVersion").get()
// Configure project's dependencies
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
snapshots()
}
}

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
Expand All @@ -27,6 +33,17 @@ dependencies {
compileOnly(libs.ini4j)
compileOnly(libs.kotlinxSerialization)
testImplementation(kotlin("test"))
intellijPlatform {
val type = properties("platformType")
val version = properties("platformVersion")
val bundledPlugins = properties("platformBundledPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
create(type, version, useInstaller = false)
bundledPlugins(bundledPlugins)
instrumentationTools()
testFramework(TestFrameworkType.Bundled)
pluginVerifier()
zipSigner()
}
}

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
Expand All @@ -39,50 +56,16 @@ kotlin {
}

// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) })
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl = properties("pluginRepositoryUrl")
}

// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath = provider { file(".qodana").canonicalPath }
reportPath = provider { file("build/reports/inspections").canonicalPath }
saveReport = true
showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)
}

// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
koverReport {
defaults {
xml {
onCheck = true
}
}
}

tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
}

patchPluginXml {
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("pluginVersion")
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")

// Extract the <!-- Plugin description --> 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 = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

Expand All @@ -93,11 +76,8 @@ tasks {
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
}
}

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 ->
with(changelog) {
with(project.changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
Expand All @@ -108,28 +88,47 @@ 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", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")
verifyPlugin {
ides {
recommended()
}
}

signPlugin {
signing {
certificateChain = environment("CERTIFICATE_CHAIN")
privateKey = environment("PRIVATE_KEY")
password = environment("PRIVATE_KEY_PASSWORD")
}

publishPlugin {
dependsOn("patchChangelog")
publishing {
token = environment("JETBRAINS_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()) }
}
changelog {
groups.empty()
repositoryUrl = properties("pluginRepositoryUrl")
}
instrumentCode = true
}


// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath = provider { file(".qodana").canonicalPath }
reportPath = provider { file("build/reports/inspections").canonicalPath }
saveReport = true
showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)
}

// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
koverReport {
defaults {
xml {
onCheck = true
}
}
}

tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
}
}

Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,27 @@ pluginGroup = com.koxudaxi.ruff
pluginName = Ruff
pluginRepositoryUrl = https://github.com/koxudaxi/ruff-pycharm-plugin
# SemVer format -> https://semver.org
pluginVersion = 0.0.34
pluginVersion = 0.0.35

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 233.11799.241
pluginUntilBuild = 241.*
pluginSinceBuild = 242.20224.89
pluginUntilBuild = 242.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = PY
platformVersion = 2024.1
platformVersion = 242-EAP-SNAPSHOT

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = python
platformBundledPlugins = org.toml.lang,Pythonid

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.6

# 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.configuration-cache = true
org.gradle.unsafe.configuration-cache = false

# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching = true
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ kotlinxSerialization = "1.6.3"
# plugins
kotlin = "1.9.23"
changelog = "2.2.0"
gradleIntelliJPlugin = "1.17.3"
gradleIntelliJPlugin = "2.0.0-rc1"
qodana = "0.1.13"
kover = "0.7.6"

Expand All @@ -20,7 +20,7 @@ kotlinxSerialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serial

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
gradleIntelliJPlugin = { id = "org.jetbrains.intellij.platform", version.ref = "gradleIntelliJPlugin" }
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" }
Expand Down
1 change: 0 additions & 1 deletion src/com/koxudaxi/ruff/RuffExternalAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.util.PsiTreeUtil
import com.jetbrains.python.psi.PyFile
import com.jetbrains.python.psi.impl.PyFileImpl
Expand Down
40 changes: 26 additions & 14 deletions testSrc/com/jetbrains/python/PythonMockSdk.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.projectRoots.ProjectJdkTable
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.projectRoots.SdkAdditionalData
import com.intellij.openapi.projectRoots.SdkTypeId
import com.intellij.openapi.projectRoots.impl.MockSdk
import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.containers.ContainerUtil
import com.intellij.util.containers.MultiMap
import com.jetbrains.python.codeInsight.typing.PyTypeShed.findRootsForLanguageLevel
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil
import com.jetbrains.python.psi.LanguageLevel
import com.jetbrains.python.sdk.PythonSdkUtil
import org.jdom.Element
import org.jetbrains.annotations.NonNls
import java.io.File
import java.util.function.Consumer

import com.jetbrains.python.sdk.PythonSdkType.MOCK_PY_MARKER_KEY

/**
* @author yole
Expand Down Expand Up @@ -52,19 +55,28 @@ object PythonMockSdk {
vararg additionalRoots: VirtualFile
): Sdk {
val mockSdkPath = PythonTestUtil.testDataPath + "/" + pathSuffix
val roots = MultiMap.create<OrderRootType, VirtualFile>()
roots.putValues(OrderRootType.CLASSES, createRoots(mockSdkPath, level))
roots.putValues(OrderRootType.CLASSES, listOf(*additionalRoots))
val sdk = MockSdk(
name,
"$mockSdkPath/bin/python",
toVersionString(level),
roots,
sdkType
)
val sdk = ProjectJdkTable.getInstance().createSdk(name, sdkType)
val sdkModificator = sdk.sdkModificator
sdkModificator.homePath = "$mockSdkPath/bin/python"
sdkModificator.versionString = toVersionString(level)

createRoots(mockSdkPath, level).forEach(Consumer { vFile: VirtualFile? ->
sdkModificator.addRoot(vFile!!, OrderRootType.CLASSES)
})

// com.jetbrains.python.psi.resolve.PythonSdkPathCache.getInstance() corrupts SDK, so have to clone
return sdk.clone()
additionalRoots.forEach { vFile ->
sdkModificator.addRoot(vFile, OrderRootType.CLASSES)
}

val application = ApplicationManager.getApplication()
val runnable = Runnable { sdkModificator.commitChanges() }
if (application.isDispatchThread) {
application.runWriteAction(runnable)
} else {
application.invokeAndWait { application.runWriteAction(runnable) }
}
sdk.putUserData(MOCK_PY_MARKER_KEY, true);
return sdk
}

private fun createRoots(@NonNls mockSdkPath: String, level: LanguageLevel): List<VirtualFile> {
Expand Down

0 comments on commit df941b9

Please sign in to comment.