Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"permissions": {
"allow": [
"Bash(tail:*)",
"Bash(grep:*)",
"Bash(grep)",
"Bash(chmod +x)",
"Bash(lsof)",
"Bash(grep*)",
"Bash(jar tf:*)",
"Bash(head:*)",
"Bash(./gradlew*)"
]
}
}
115 changes: 115 additions & 0 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: UI Tests

on:
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
ui-test:
strategy:
# Keep running the other platforms even if one fails so we get full signal
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Pre-download IDE and build plugin so the background launch is fast and doesn't fail silently.
- name: Build plugin and prepare sandbox
run: ./gradlew prepareSandbox_runIdeForUiTests

# Linux runners have no display server; start a virtual one before launching the IDE.
- name: Start virtual display (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install -y xvfb
Xvfb :99 -screen 0 1920x1080x24 &
sleep 2
echo "DISPLAY=:99" >> "$GITHUB_ENV"

- name: Clean up test module (pre-test)
run: rm -rf src/uiTest/testProject/repository
shell: bash

# Run IDE + tests in a single step so the backgrounded IDE process stays alive.
- name: Start IDE, wait for robot server, and run UI tests
shell: bash
env:
DISPLAY: ${{ env.DISPLAY }}
run: |
echo "Starting IDE with robot server..."
./gradlew runIdeForUiTests > ide-output.log 2>&1 &
IDE_PID=$!
echo "IDE PID: $IDE_PID"

# Poll until the robot server responds to HTTP requests.
echo "Waiting for robot server on port 8082..."
MAX_WAIT=90
ATTEMPT=0
until curl -sf --connect-timeout 2 http://127.0.0.1:8082/api/about > /dev/null 2>&1; do
ATTEMPT=$((ATTEMPT + 1))
if [ "$ATTEMPT" -ge "$MAX_WAIT" ]; then
echo "ERROR: robot server did not start after $((MAX_WAIT * 5)) seconds"
echo "=== IDE output (last 100 lines) ==="
tail -100 ide-output.log 2>/dev/null || true
exit 1
fi
echo " attempt $ATTEMPT/$MAX_WAIT — not ready yet, retrying in 5s..."
sleep 5
done
echo "Robot server is ready!"

# Run the UI tests
./gradlew uiTest || TEST_EXIT=$?

echo "=== IDE output (last 50 lines) ==="
tail -50 ide-output.log 2>/dev/null || true

exit ${TEST_EXIT:-0}

- name: Clean up test module (post-test)
if: always()
run: |
rm -rf src/uiTest/testProject/repository
git checkout -- src/uiTest/testProject/settings.gradle.kts
shell: bash

- name: Upload IDE output log
if: always()
uses: actions/upload-artifact@v4
with:
name: ide-output-${{ matrix.os }}
path: ide-output.log
if-no-files-found: ignore

- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: ui-test-results-${{ matrix.os }}
path: build/reports/tests/uiTest/
if-no-files-found: ignore

# Upload IDE logs to help diagnose failures
- name: Upload IDE logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: ide-logs-${{ matrix.os }}
path: build/idea-sandbox/system/log/
if-no-files-found: ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ google-services.json
.DS_Store

.intellijPlatform

.kotlin
.claude
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Module Maker Changelog

## [1.1.2]
## [1.2.0]
- Fix startup issue on Windows
- Change to standard IntelliJ theming

## [1.1.1]
- Platform updates
Expand Down
76 changes: 56 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ fun environment(key: String) = providers.environmentVariable(key)
plugins {
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
alias(libs.plugins.gradleIntelliJPlugin) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
kotlin("plugin.serialization") version libs.versions.kotlin.get()
id("org.jetbrains.compose")
alias(libs.plugins.compose) // Gradle Compose Compiler Plugin
alias(libs.plugins.spotless)
alias(libs.plugins.compose)
kotlin("plugin.serialization") version libs.versions.kotlin.get()
}

group = properties("pluginGroup").get()
Expand All @@ -38,36 +37,36 @@ repositories {
intellijPlatform {
defaultRepositories()
}
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
}

apply(
from = "gradle/spotless.gradle"
)

sourceSets {
create("uiTest") {
kotlin.srcDir("src/uiTest/kotlin")
}
}

dependencies {
implementation(libs.freemarker)
implementation(libs.serialization)
implementation(compose.desktop.currentOs)
implementation(compose.materialIconsExtended)
implementation(libs.segment)

// I usually do
// ./gradlew dependencies | grep "skiko"
// to get the skiko version that compose depends on
val version = "0.9.37.4"
val macTarget = "macos-arm64"
val windowsTarget = "windows-x64"
val linuxTarget = "linux-x64"

implementation("org.jetbrains.skiko:skiko-awt-runtime-$macTarget:$version")
implementation("org.jetbrains.skiko:skiko-awt-runtime-$windowsTarget:$version")
implementation("org.jetbrains.skiko:skiko-awt-runtime-$linuxTarget:$version")

testImplementation(libs.junit)

"uiTestImplementation"(kotlin("stdlib"))
"uiTestImplementation"(libs.remoteRobot)
"uiTestImplementation"(libs.remoteRobotFixtures)
"uiTestImplementation"(libs.junit)
"uiTestImplementation"("com.squareup.okhttp3:okhttp:4.12.0")
// The Compose compiler plugin applies to all source sets; uiTest needs the runtime on its classpath
"uiTestImplementation"("org.jetbrains.compose.runtime:runtime-desktop:1.7.3")

// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
intellijPlatform {
javaCompiler("243.26053.29") // https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1894
create(properties("platformType").get(), properties("platformVersion").get())

// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
Expand All @@ -76,6 +75,10 @@ dependencies {
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(properties("platformPlugins").map { it.split(',') })

// Compose support dependencies
@Suppress("UnstableApiUsage")
composeUI()

// instrumentationTools()
pluginVerifier()
zipSigner()
Expand Down Expand Up @@ -136,6 +139,24 @@ tasks {
}
}

tasks.register<Test>("uiTest") {
description = "Runs UI tests against a running IDE instance"
group = "verification"
testClassesDirs = sourceSets["uiTest"].output.classesDirs
classpath = sourceSets["uiTest"].runtimeClasspath
systemProperty("robot-server.port", System.getProperty("robot-server.port", "8082"))
doNotTrackState("UI tests are not cacheable")
// Gson (used by the remote-robot client) reflectively accesses private fields such as
// Throwable.detailMessage when deserializing error responses from the robot server.
// JDK 17+ JPMS blocks this by default; --add-opens restores access.
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
// Echo test stdout/stderr directly to the Gradle console so diagnostic println calls
// (accessibility tree dumps, screenshots, component class lists) are visible live.
testLogging {
showStandardStreams = true
}
}

intellijPlatformTesting {
runIde {
register("runIdeForUiTests") {
Expand All @@ -145,9 +166,24 @@ intellijPlatformTesting {
"-Drobot-server.port=8082",
"-Dide.mac.message.dialogs.as.sheets=false",
"-Djb.privacy.policy.text=<!--999.999-->",
"-Djb.consents.confirmation.enabled=false"
"-Djb.consents.confirmation.enabled=false",
// Skip the "Trust Project?" dialog that blocks the IDE frame from appearing
"-Didea.trust.all.projects=true",
"-Didea.initially.ask.config=never",
// Suppress Tip of the Day, What's New, and other first-run dialogs
"-Dide.show.tips.on.startup.default.value=false",
"-Didea.is.internal=false",
"-Dide.no.platform.update=true",
// Skip import settings dialog
"-Didea.config.imported.in.current.session=true",
// Force the Swing menu bar so remote-robot can find menu items.
// Without this, macOS uses the native system menu bar which is
// invisible to the Swing component hierarchy that remote-robot inspects.
"-Dapple.laf.useScreenMenuBar=false"
)
}
// Open the test project so settings.gradle.kts is available for module creation
args(layout.projectDirectory.dir("src/uiTest/testProject").asFile.absolutePath)
}

plugins {
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.joetr.modulemaker
pluginName = ModuleMaker
pluginRepositoryUrl = https://github.com/j-roskopf/ModuleMakerPlugin
# SemVer format -> https://semver.org
pluginVersion = 1.1.2
pluginVersion = 1.2.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 222
Expand Down Expand Up @@ -39,4 +39,3 @@ 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

compose.version=1.10.1
7 changes: 5 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
freemarker = "2.3.30"
serialization = "1.5.1"
jdk = "17"
kotlin = "2.3.0"
kotlin = "2.1.20"
changelog = "2.0.0"
gradleIntelliJPlugin = "2.11.0"
gradleIntelliJPlugin = "2.10.5"
spotless = "6.8.0"
segment = "1.13.2"
junit = "4.13.2"
remoteRobot = "0.11.23"

[libraries]
freemarker = { group = "org.freemarker", name = "freemarker", version.ref = "freemarker" }
serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" }
segment = { group = "com.segment.analytics.kotlin", name = "core", version.ref = "segment" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
remoteRobot = { group = "com.intellij.remoterobot", name = "remote-robot", version.ref = "remoteRobot" }
remoteRobotFixtures = { group = "com.intellij.remoterobot", name = "remote-fixtures", version.ref = "remoteRobot" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
Expand Down
45 changes: 45 additions & 0 deletions run-ui-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail

# Start the IDE with the robot server in the background.
# runIdeForUiTests never exits on its own, so we launch it as a background process
# and kill it when the tests finish.
echo "Starting IDE with robot server..."
./gradlew runIdeForUiTests &
IDE_PID=$!

cleanup() {
echo "Stopping IDE (pid $IDE_PID)..."
kill "$IDE_PID" 2>/dev/null || true
}
trap cleanup EXIT

# Wait for the robot server TCP port to accept connections (up to 5 minutes).
# The server has no GET health endpoint; nc is the reliable way to probe the port.
echo "Waiting for robot server on port 8082..."
MAX_ATTEMPTS=60
ATTEMPT=0
until nc -z localhost 8082 2>/dev/null; do
ATTEMPT=$((ATTEMPT + 1))
if [ "$ATTEMPT" -ge "$MAX_ATTEMPTS" ]; then
echo "ERROR: robot server did not start after $((MAX_ATTEMPTS * 5)) seconds."
exit 1
fi
echo " attempt $ATTEMPT/$MAX_ATTEMPTS — not ready yet, retrying in 5s..."
sleep 5
done
echo "IDE is ready!"

# Clean up any previously created test module before running.
TEST_MODULE_DIR="src/uiTest/testProject/repository"
rm -rf "$TEST_MODULE_DIR"

# Run the tests. The EXIT trap above will kill the IDE when this exits.
./gradlew uiTest
TEST_EXIT=$?

# Clean up the created test module and restore settings.gradle.kts after running.
rm -rf "$TEST_MODULE_DIR"
git checkout -- src/uiTest/testProject/settings.gradle.kts

exit $TEST_EXIT
6 changes: 0 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
rootProject.name = "Module Maker"

pluginManagement {
plugins {
id("org.jetbrains.compose").version(extra["compose.version"] as String)
}
}
Loading
Loading