Skip to content

Commit

Permalink
Pycharm plugin publishing (#2679)
Browse files Browse the repository at this point in the history
Co-authored-by: Vassiliy.Kudryashov <[email protected]>
  • Loading branch information
tamarinvs19 and Vassiliy.Kudryashov authored Dec 11, 2023
1 parent 9fd7984 commit c5a1926
Show file tree
Hide file tree
Showing 11 changed files with 781 additions and 18 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/publish-plugin-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ jobs:
configuration:
- plugin_type: IC
extra_options: "-PideType=IC -PprojectType=Community"
directory: utbot-intellij-main
- plugin_type: IU
extra_options: "-PideType=IU -PprojectType=Ultimate"
directory: utbot-intellij-main
- plugin_type: PY
extra_options: "-PideType=PY -PprojectType=Ultimate"
directory: utbot-intellij-python
runs-on: ubuntu-20.04
container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0
steps:
Expand Down Expand Up @@ -81,13 +84,13 @@ jobs:
- name: Build UTBot IntelliJ IDEA plugin
run: |
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 }}
cd utbot-intellij-main/build/distributions
unzip utbot-intellij-main-${{ env.VERSION }}.zip
rm utbot-intellij-main-${{ env.VERSION }}.zip
cd ${{ matrix.configuration.directory }}/build/distributions
unzip ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip
rm ${{ matrix.configuration.directory }}-${{ env.VERSION }}.zip
- name: Archive UTBot IntelliJ IDEA plugin
if: ${{ inputs.upload-artifact == 'true' }}
uses: actions/upload-artifact@v3
with:
name: utbot-intellij-${{ matrix.configuration.plugin_type }}-${{ env.VERSION_ARCHIVE }}
path: utbot-intellij-main/build/distributions/*
path: ${{ matrix.configuration.directory }}/build/distributions/*
10 changes: 5 additions & 5 deletions utbot-intellij-python/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
val intellijPluginVersion: String? by rootProject
val semVer: String? by rootProject
val kotlinLoggingVersion: String? by rootProject
val apacheCommonsTextVersion: String? by rootProject
val jacksonVersion: String? by rootProject

// === IDE settings ===
val projectType: String by rootProject
Expand Down Expand Up @@ -54,8 +52,10 @@ tasks {
targetCompatibility = JavaVersion.VERSION_17
}

test {
useJUnitPlatform()
patchPluginXml {
sinceBuild.set("223")
untilBuild.set("232.*")
version.set(semVer)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.utbot.python.TestFileInformation
import org.utbot.python.framework.api.python.PythonClassId
import org.utbot.python.framework.codegen.PythonCgLanguageAssistant
import org.utbot.python.newtyping.mypy.dropInitFile
import org.utbot.python.utils.PythonVersionChecker
import java.util.concurrent.ScheduledFuture
import java.util.concurrent.TimeUnit
import kotlin.io.path.Path
Expand Down Expand Up @@ -124,16 +125,24 @@ object PythonDialogProcessor {
title = "Python test generation error"
)
} else {
val dialog = createDialog(
project,
elementsToShow,
focusedElement,
pythonPath,
)
if (!dialog.showAndGet()) {
return
if (!PythonVersionChecker.checkPythonVersion(pythonPath)) {
showErrorDialogLater(
project,
message = "Please use Python 3.10 or newer",
title = "Python test generation error"
)
} else {
val dialog = createDialog(
project,
elementsToShow,
focusedElement,
pythonPath,
)
if (!dialog.showAndGet()) {
return
}
createTests(project, dialog.model)
}
createTests(project, dialog.model)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.utbot.intellij.plugin.python.ui.actions

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.components.service
import org.utbot.intellij.plugin.language.agnostic.LanguageAssistant
import org.utbot.intellij.plugin.settings.Settings

class GenerateTestsAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
LanguageAssistant.get(e)?.actionPerformed(e)
}

override fun update(e: AnActionEvent) {
val languageAssistant = LanguageAssistant.get(e)
if (languageAssistant == null) {
e.presentation.isEnabled = false
} else {
languageAssistant.update(e)
}
}

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
}
50 changes: 50 additions & 0 deletions utbot-intellij-python/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--suppress HttpUrlsUsage -->
<idea-plugin>

<id>org.utbot.python</id>
<name>UnitTestBot for Python</name>
<vendor>utbot.org</vendor>
<depends>com.intellij.modules.platform</depends>

<depends config-file="withPython.xml">com.intellij.modules.python</depends>

<actions>
<action id="org.utbot.intellij.plugin.python.ui.actions.GenerateTestsAction"
class="org.utbot.intellij.plugin.python.ui.actions.GenerateTestsAction"
text="Generate Tests with UnitTestBot..."
description="Cover code with auto-generated tests">
<add-to-group group-id="ProjectViewPopupMenu"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt shift U"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt U" second-keystroke="alt T"/>
</action>
</actions>

<extensions defaultExtensionNs="com.intellij">
<projectConfigurable dynamic="true" parentId="tools" instance="org.utbot.intellij.plugin.settings.Configurable"
id="org.utbot.intellij.plugin.settings.Configurable"
displayName="UnitTestBot"/>
<!--suppress PluginXmlValidity -->
</extensions>

<!-- Minimum and maximum build of IDE compatible with the plugin -->
<description>
<![CDATA[
UnitTestBot is the tool for automated unit test generation and precise code analysis.
<br/><br/>
Discover UnitTestBot key features in our latest release:
<ul>
<li>generating ready-to-use test cases — with valid inputs, method bodies, assertions, and comments</li>
<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>
<li>finding deeply hidden code defects and expressing them as tests</li>
<li>smart fuzzing platform</li>
</ul>
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.
<br/>
Contribute to UnitTestBot via <a href="https://github.com/UnitTestBot/UTBotJava/blob/main/CONTRIBUTING.md">GitHub</a>.
<br/>
Found a bug? File an <a href="https://github.com/UnitTestBot/UTBotJava/issues">issue</a>.
<br/>
Have an idea? Start a <a href="https://github.com/UnitTestBot/UTBotJava/discussions">discussion</a>.
]]>
</description>
</idea-plugin>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!--Optional dependency on com.intellij.modules.python-->
<extensions defaultExtensionNs="com.intellij">
<depends>com.intellij.modules.python</depends>
</extensions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# suppress inspection "HttpUrlsUsage" for whole file
backing.service.possibleEndpoints=http://utbot.org
backing.service.urlPath=/utbot/errors
backing.service.port=11000
request.timeoutMillis=5000
34 changes: 34 additions & 0 deletions utbot-intellij-python/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<!-- Idea catches plugin stdout log and wraps it in its own format, so in IDE only message is logged-->
<Console name="IdeaAppender" target="SYSTEM_OUT">
<PatternLayout pattern="| UtBot - %-25c{1} | %msg%n"/>
</Console>
<!-- When working as separate process - temporary log4j2.xml would be created, in which -->
<!-- substring `ref="IdeaAppender"` will be replaced with `ref="EngineProcessAppender"` -->
<!-- delete_this_comment_key identifies lines which will be deleted prior creating temp log4j2.xml -->
<!-- You can set bufferIO=true and immediateFlush=false for better performance, -->
<!-- but possibly lose some logs on process death - log4j2 service might die unflushed -->
<!--delete_this_comment_key
<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">
<PatternLayout pattern="%d{HH:mm:ss.SSS} | %-5level | %-25c{1} | %msg%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="20 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
delete_this_comment_key-->
</Appenders>
<Loggers>
<Logger name="org.utbot.intellij" level="info" additivity="false">
<AppenderRef ref="IdeaAppender"/>
</Logger>
<Logger name="org.utbot" level="info" additivity="false">
<AppenderRef ref="IdeaAppender"/>
</Logger>
<Root level="error">
<AppenderRef ref="IdeaAppender"/>
</Root>
</Loggers>
</Configuration>
Loading

0 comments on commit c5a1926

Please sign in to comment.