Skip to content

Commit c5a1926

Browse files
tamarinvs19Vassiliy.Kudryashov
andauthored
Pycharm plugin publishing (#2679)
Co-authored-by: Vassiliy.Kudryashov <[email protected]>
1 parent 9fd7984 commit c5a1926

File tree

11 files changed

+781
-18
lines changed

11 files changed

+781
-18
lines changed

.github/workflows/publish-plugin-from-branch.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ jobs:
4646
configuration:
4747
- plugin_type: IC
4848
extra_options: "-PideType=IC -PprojectType=Community"
49+
directory: utbot-intellij-main
4950
- plugin_type: IU
5051
extra_options: "-PideType=IU -PprojectType=Ultimate"
52+
directory: utbot-intellij-main
5153
- plugin_type: PY
5254
extra_options: "-PideType=PY -PprojectType=Ultimate"
55+
directory: utbot-intellij-python
5356
runs-on: ubuntu-20.04
5457
container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0
5558
steps:
@@ -81,13 +84,13 @@ jobs:
8184
- name: Build UTBot IntelliJ IDEA plugin
8285
run: |
8386
gradle clean buildPlugin --no-daemon --build-cache --no-parallel -PgithubActor=${{ github.actor }} -PgithubToken=${{ secrets.PACKAGES_RO_TOKEN }} ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -PsemVer=${{ env.VERSION }}
84-
cd utbot-intellij-main/build/distributions
85-
unzip utbot-intellij-main-${{ env.VERSION }}.zip
86-
rm utbot-intellij-main-${{ env.VERSION }}.zip
87+
cd ${{ matrix.configuration.directory }}/build/distributions
88+
unzip ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip
89+
rm ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip
8790
8891
- name: Archive UTBot IntelliJ IDEA plugin
8992
if: ${{ inputs.upload-artifact == 'true' }}
9093
uses: actions/upload-artifact@v3
9194
with:
9295
name: utbot-intellij-${{ matrix.configuration.plugin_type }}-${{ env.VERSION_ARCHIVE }}
93-
path: utbot-intellij-main/build/distributions/*
96+
path: ${{ matrix.configuration.directory }}/build/distributions/*

utbot-intellij-python/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
val intellijPluginVersion: String? by rootProject
1+
val semVer: String? by rootProject
22
val kotlinLoggingVersion: String? by rootProject
3-
val apacheCommonsTextVersion: String? by rootProject
4-
val jacksonVersion: String? by rootProject
53

64
// === IDE settings ===
75
val projectType: String by rootProject
@@ -54,8 +52,10 @@ tasks {
5452
targetCompatibility = JavaVersion.VERSION_17
5553
}
5654

57-
test {
58-
useJUnitPlatform()
55+
patchPluginXml {
56+
sinceBuild.set("223")
57+
untilBuild.set("232.*")
58+
version.set(semVer)
5959
}
6060
}
6161

utbot-intellij-python/src/main/kotlin/org/utbot/intellij/plugin/python/PythonDialogProcessor.kt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.utbot.python.TestFileInformation
3636
import org.utbot.python.framework.api.python.PythonClassId
3737
import org.utbot.python.framework.codegen.PythonCgLanguageAssistant
3838
import org.utbot.python.newtyping.mypy.dropInitFile
39+
import org.utbot.python.utils.PythonVersionChecker
3940
import java.util.concurrent.ScheduledFuture
4041
import java.util.concurrent.TimeUnit
4142
import kotlin.io.path.Path
@@ -124,16 +125,24 @@ object PythonDialogProcessor {
124125
title = "Python test generation error"
125126
)
126127
} else {
127-
val dialog = createDialog(
128-
project,
129-
elementsToShow,
130-
focusedElement,
131-
pythonPath,
132-
)
133-
if (!dialog.showAndGet()) {
134-
return
128+
if (!PythonVersionChecker.checkPythonVersion(pythonPath)) {
129+
showErrorDialogLater(
130+
project,
131+
message = "Please use Python 3.10 or newer",
132+
title = "Python test generation error"
133+
)
134+
} else {
135+
val dialog = createDialog(
136+
project,
137+
elementsToShow,
138+
focusedElement,
139+
pythonPath,
140+
)
141+
if (!dialog.showAndGet()) {
142+
return
143+
}
144+
createTests(project, dialog.model)
135145
}
136-
createTests(project, dialog.model)
137146
}
138147
}
139148

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.utbot.intellij.plugin.python.ui.actions
2+
3+
import com.intellij.openapi.actionSystem.ActionUpdateThread
4+
import com.intellij.openapi.actionSystem.AnAction
5+
import com.intellij.openapi.actionSystem.AnActionEvent
6+
import com.intellij.openapi.components.service
7+
import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant
8+
import org.utbot.intellij.plugin.settings.Settings
9+
10+
class GenerateTestsAction : AnAction() {
11+
override fun actionPerformed(e: AnActionEvent) {
12+
LanguageAssistant.get(e)?.actionPerformed(e)
13+
}
14+
15+
override fun update(e: AnActionEvent) {
16+
val languageAssistant = LanguageAssistant.get(e)
17+
if (languageAssistant == null) {
18+
e.presentation.isEnabled = false
19+
} else {
20+
languageAssistant.update(e)
21+
}
22+
}
23+
24+
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
25+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!--suppress HttpUrlsUsage -->
2+
<idea-plugin>
3+
4+
<id>org.utbot.python</id>
5+
<name>UnitTestBot for Python</name>
6+
<vendor>utbot.org</vendor>
7+
<depends>com.intellij.modules.platform</depends>
8+
9+
<depends config-file="withPython.xml">com.intellij.modules.python</depends>
10+
11+
<actions>
12+
<action id="org.utbot.intellij.plugin.python.ui.actions.GenerateTestsAction"
13+
class="org.utbot.intellij.plugin.python.ui.actions.GenerateTestsAction"
14+
text="Generate Tests with UnitTestBot..."
15+
description="Cover code with auto-generated tests">
16+
<add-to-group group-id="ProjectViewPopupMenu"/>
17+
<keyboard-shortcut keymap="$default" first-keystroke="alt shift U"/>
18+
<keyboard-shortcut keymap="$default" first-keystroke="alt U" second-keystroke="alt T"/>
19+
</action>
20+
</actions>
21+
22+
<extensions defaultExtensionNs="com.intellij">
23+
<projectConfigurable dynamic="true" parentId="tools" instance="org.utbot.intellij.plugin.settings.Configurable"
24+
id="org.utbot.intellij.plugin.settings.Configurable"
25+
displayName="UnitTestBot"/>
26+
<!--suppress PluginXmlValidity -->
27+
</extensions>
28+
29+
<!-- Minimum and maximum build of IDE compatible with the plugin -->
30+
<description>
31+
<![CDATA[
32+
UnitTestBot is the tool for automated unit test generation and precise code analysis.
33+
<br/><br/>
34+
Discover UnitTestBot key features in our latest release:
35+
<ul>
36+
<li>generating ready-to-use test cases — with valid inputs, method bodies, assertions, and comments</li>
37+
<li>maximizing <a href="https://en.wikipedia.org/wiki/Code_coverage">branch coverage</a> in <i>regression suite</i> while keeping the number of tests minimized</li>
38+
<li>finding deeply hidden code defects and expressing them as tests</li>
39+
<li>smart fuzzing platform</li>
40+
</ul>
41+
Try <a href="https://www.utbot.org/demo/?language=Python">UnitTestBot online demo</a> to see how it generates tests for your code in real time.
42+
<br/>
43+
Contribute to UnitTestBot via <a href="https://github.com/UnitTestBot/UTBotJava/blob/main/CONTRIBUTING.md">GitHub</a>.
44+
<br/>
45+
Found a bug? File an <a href="https://github.com/UnitTestBot/UTBotJava/issues">issue</a>.
46+
<br/>
47+
Have an idea? Start a <a href="https://github.com/UnitTestBot/UTBotJava/discussions">discussion</a>.
48+
]]>
49+
</description>
50+
</idea-plugin>
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!--Optional dependency on com.intellij.modules.python-->
2+
<extensions defaultExtensionNs="com.intellij">
3+
<depends>com.intellij.modules.python</depends>
4+
</extensions>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# suppress inspection "HttpUrlsUsage" for whole file
2+
backing.service.possibleEndpoints=http://utbot.org
3+
backing.service.urlPath=/utbot/errors
4+
backing.service.port=11000
5+
request.timeoutMillis=5000
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration>
3+
<Appenders>
4+
<!-- Idea catches plugin stdout log and wraps it in its own format, so in IDE only message is logged-->
5+
<Console name="IdeaAppender" target="SYSTEM_OUT">
6+
<PatternLayout pattern="| UtBot - %-25c{1} | %msg%n"/>
7+
</Console>
8+
<!-- When working as separate process - temporary log4j2.xml would be created, in which -->
9+
<!-- substring `ref="IdeaAppender"` will be replaced with `ref="EngineProcessAppender"` -->
10+
<!-- delete_this_comment_key identifies lines which will be deleted prior creating temp log4j2.xml -->
11+
<!-- You can set bufferIO=true and immediateFlush=false for better performance, -->
12+
<!-- but possibly lose some logs on process death - log4j2 service might die unflushed -->
13+
<!--delete_this_comment_key
14+
<RollingFile append="true" name="EngineProcessAppender" bufferedIO="false" immediateFlush="true" fileName="${env:UTBOT_LOG_DIR}utbot-engine-current.log" filePattern="${env:UTBOT_LOG_DIR}utbot-engine-%i.log" bufferSize="1048576">
15+
<PatternLayout pattern="%d{HH:mm:ss.SSS} | %-5level | %-25c{1} | %msg%n"/>
16+
<Policies>
17+
<SizeBasedTriggeringPolicy size="20 MB"/>
18+
</Policies>
19+
<DefaultRolloverStrategy max="10"/>
20+
</RollingFile>
21+
delete_this_comment_key-->
22+
</Appenders>
23+
<Loggers>
24+
<Logger name="org.utbot.intellij" level="info" additivity="false">
25+
<AppenderRef ref="IdeaAppender"/>
26+
</Logger>
27+
<Logger name="org.utbot" level="info" additivity="false">
28+
<AppenderRef ref="IdeaAppender"/>
29+
</Logger>
30+
<Root level="error">
31+
<AppenderRef ref="IdeaAppender"/>
32+
</Root>
33+
</Loggers>
34+
</Configuration>

0 commit comments

Comments
 (0)