Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows ITs WIP #1265

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
166 changes: 27 additions & 139 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
slack_notification_script: |
source slack-failure-notification

validate_task:

Check warning on line 116 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L116

task "validate" depends on task "build", but their only_if conditions are different

Check warning on line 116 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L116

task "validate" depends on task "build", but their only_if conditions are different
# name: "Run UTs and trigger SonarQube analysis"
depends_on:
- build
Expand All @@ -139,7 +139,7 @@
slack_notification_script: |
source slack-failure-notification

validate_windows_task:

Check warning on line 142 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L142

task "validate_windows" depends on task "build", but their only_if conditions are different

Check warning on line 142 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L142

task "validate_windows" depends on task "build", but their only_if conditions are different
# name: "Run unit tests on Windows"
depends_on:
- build
Expand All @@ -157,7 +157,7 @@
build_script: |
source cirrus-env QA
source .cirrus/use-gradle-wrapper.sh
./gradlew :check
gradle :check
<<: *CLEANUP_GRADLE_CACHE_SCRIPT
on_failure:
reports_artifacts:
Expand Down Expand Up @@ -200,7 +200,7 @@
source .cirrus/use-gradle-wrapper.sh
VERSIONS=$(curl -s -L https://jb.gg/intellij-platform-builds-list | jq '.[] | "\(.code) \(.releases[].version)"' | grep -Ew "${ALLOWED_IDE}" | grep "${IDEA_VERSION}" | tr -d '"' | awk '{k=$1} $2>a[k]{a[k]=$2} END{for (i in a) print i, a[i]}' | sort -u | sed 's/ /-/' | paste -s -d',')
echo ${VERSIONS}
./gradlew :runPluginVerifier -PverifierVersions=${VERSIONS}
gradle :runPluginVerifier -PverifierVersions=${VERSIONS}
<<: *CLEANUP_GRADLE_CACHE_SCRIPT
on_failure:
reports_artifacts:
Expand All @@ -208,181 +208,69 @@
slack_notification_script: |
source slack-failure-notification

qa_task:

Check warning on line 211 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L211

task "qa" depends on task "build", but their only_if conditions are different

Check warning on line 211 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L211

task "qa" depends on task "build", but their only_if conditions are different
# name: "Run ITs"
depends_on:
- build
<<: *ONLY_PR_AND_MAINTAINED_BRANCHES
<<: *ORCHESTRATOR_MONTHLY_CACHE_TEMPLATE
eks_container:
<<: *BUILDER_CONTAINER_DEFINITION
cpu: 6
memory: 16G
ec2_instance:
<<: *WINVM_DEFINITION
env:
CLION_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.clion]
GOLAND_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.goland]
DATAGRIP_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.datagrip]
IDEA_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.idea]
PHPSTORM_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.phpstorm]
PYCHARM_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.pycharm]
RIDER_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.rider]
RUBYMINE_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.rubymine]
WEBSTORM_KEY: VAULT[development/team/sonarlint/kv/data/ide.keys data.webstorm]
ARTIFACTORY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
GITHUB_TOKEN: VAULT[development/github/token/licenses-ro token]
DISPLAY: :10
JDK_VERSION: "17"
SONARCLOUD_IT_PASSWORD: VAULT[development/team/sonarlint/kv/data/sonarcloud-it data.password]
clionKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/clion.key.b64
variable_name: CLION_KEY
golandKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/goland.key.b64
variable_name: GOLAND_KEY
datagripKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/datagrip.key.b64
variable_name: DATAGRIP_KEY
ideaKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/idea.key.b64
variable_name: IDEA_KEY
phpstormKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/phpstorm.key.b64
variable_name: PHPSTORM_KEY
pycharmKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/pycharm.key.b64
variable_name: PYCHARM_KEY
riderKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/rider.key.b64
variable_name: RIDER_KEY
rubymineKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/rubymine.key.b64
variable_name: RUBYMINE_KEY
webstormKey_file:
path: ${CIRRUS_WORKING_DIR}/its/build/idea-sandbox/config-uiTest/webstorm.key.b64
variable_name: WEBSTORM_KEY
IDEA_HOME: "/C/Program Files/intellij"
RIDER_HOME: "/C/Program Files/rider"
RESHARPER_HOME: "/C/Program Files/resharper"
CLION_HOME: "/C/Program Files/clion"
matrix:
- env:
IDEA_VERSION: 'IC-2022.3.1'
QA_CATEGORY: 'Idea2022'
TEST_SUITE: 'OpenInIdeTests'
- env:
IDEA_VERSION: 'IC-2022.3.1'
QA_CATEGORY: 'Idea2022'
TEST_SUITE: 'ConnectedAnalysisTests'
- env:
IDEA_VERSION: 'IC-2022.3.1'
QA_CATEGORY: 'Idea2022'
TEST_SUITE: 'ConfigurationTests'
- env:
IDEA_VERSION: 'IC-2022.3.1'
QA_CATEGORY: 'Idea2022'
TEST_SUITE: 'Standalone'
- env:
IDEA_VERSION: 'IC-2024.1.4'
QA_CATEGORY: 'Idea2024'
TEST_SUITE: 'OpenInIdeTests'
- env:
IDEA_VERSION: 'IC-2024.1.4'
QA_CATEGORY: 'Idea2024'
TEST_SUITE: 'ConnectedAnalysisTests'
- env:
IDEA_VERSION: 'IC-2024.1.4'
QA_CATEGORY: 'Idea2024'
TEST_SUITE: 'ConfigurationTests'
- env:
IDEA_VERSION: 'IC-2024.1.4'
QA_CATEGORY: 'Idea2024'
TEST_SUITE: 'Standalone'
- env:
IDEA_VERSION: 'IU-2022.3.1'
QA_CATEGORY: 'IdeaUltimate2022'
- env:
IDEA_VERSION: 'IU-2024.1.4'
QA_CATEGORY: 'IdeaUltimate2024'
- env:
IDEA_VERSION: 'PY-2022.3.1'
QA_CATEGORY: 'PyCharmProfessional2022'
- env:
IDEA_VERSION: 'PY-2024.1.4'
QA_CATEGORY: 'PyCharmProfessional2024'
- env:
IDEA_VERSION: 'PC-2022.3.1'
QA_CATEGORY: 'PyCharmCommunity2022'
- env:
IDEA_VERSION: 'PC-2024.1.4'
QA_CATEGORY: 'PyCharmCommunity2024'
- env:
IDEA_VERSION: 'RD-2022.3.1'
QA_CATEGORY: 'Rider2022'
- env:
IDEA_VERSION: 'RD-2024.1.4'
QA_CATEGORY: 'Rider2024'
- env:
IDEA_VERSION: 'PS-2022.3.1'
QA_CATEGORY: 'PhpStorm2022'
- env:
IDEA_VERSION: 'PS-2024.1.4'
QA_CATEGORY: 'PhpStorm2024'
- env:
IDEA_VERSION: 'GO-2022.3.1'
QA_CATEGORY: 'GoLand2022'
- env:
IDEA_VERSION: 'GO-2024.1.4'
QA_CATEGORY: 'GoLand2024'
- env:
IDEA_VERSION: 'CL-2022.3.1'
QA_CATEGORY: 'CLion2022'
- env:
IDEA_VERSION: 'CL-2024.1.4'
QA_CATEGORY: 'CLion2024'
<<: *SETUP_GRADLE_CACHE
xvfb_background_script: |
/etc/init.d/xvfb start
prepare_background_script: |
set -euo pipefail
echo "Prepare env and start IDE ${IDEA_VERSION}"
source cirrus-env QA
source .cirrus/use-gradle-wrapper.sh
echo "Prepare env and start IDE ${IDEA_VERSION}"
echo "Prepare env and start IDE ${IDEA_VERSION}"
source set_gradle_build_version
#echo "Prepare env and start IDE ${IDEA_VERSION}"
#echo gradle --version
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:unpack -B -Dartifact=org.sonarsource.sonarlint.intellij:sonarlint-intellij:${PROJECT_VERSION}:zip "-DoutputDirectory=${CIRRUS_WORKING_DIR}/staged-plugin"
# echo ${CIRRUS_WORKING_DIR}
# echo ls ${CIRRUS_WORKING_DIR}/staged-plugin
mkdir -p its/build/idea-sandbox/config-uiTest/
base64 --decode its/build/idea-sandbox/config-uiTest/clion.key.b64 > its/build/idea-sandbox/config-uiTest/clion.key
base64 --decode its/build/idea-sandbox/config-uiTest/goland.key.b64 > its/build/idea-sandbox/config-uiTest/goland.key
base64 --decode its/build/idea-sandbox/config-uiTest/datagrip.key.b64 > its/build/idea-sandbox/config-uiTest/datagrip.key
base64 --decode its/build/idea-sandbox/config-uiTest/idea.key.b64 > its/build/idea-sandbox/config-uiTest/idea.key
base64 --decode its/build/idea-sandbox/config-uiTest/phpstorm.key.b64 > its/build/idea-sandbox/config-uiTest/phpstorm.key
base64 --decode its/build/idea-sandbox/config-uiTest/pycharm.key.b64 > its/build/idea-sandbox/config-uiTest/pycharm.key
base64 --decode its/build/idea-sandbox/config-uiTest/rider.key.b64 > its/build/idea-sandbox/config-uiTest/rider.key
base64 --decode its/build/idea-sandbox/config-uiTest/rubymine.key.b64 > its/build/idea-sandbox/config-uiTest/rubymine.key
base64 --decode its/build/idea-sandbox/config-uiTest/webstorm.key.b64 > its/build/idea-sandbox/config-uiTest/webstorm.key
metacity --sm-disable --replace &
sleep 10 # give metacity some time to start
gradle :its:runIdeForUiTests --stacktrace -i -PijVersion=${IDEA_VERSION} -PslPluginDirectory=${CIRRUS_WORKING_DIR}/staged-plugin > ${CIRRUS_WORKING_DIR}/runIdeGradle.log &
wait_ide_script: |
echo "Wait for IDE to start"
.cirrus/wait-for-endpoint.sh http://127.0.0.1:8082 -t 500
recording_background_script: |
echo 'Recording tests on video'
ffmpeg -loglevel warning -f x11grab -video_size 1280x960 -i ${DISPLAY} -codec:v libx264 -r 12 ${CIRRUS_WORKING_DIR}/recording_${IDEA_VERSION}.mp4
sleep 400s
curl --connect-timeout 1 --insecure -s -o /dev/null http://127.0.0.1:8082
# TODO write windows version of wait-for-endpoint.sh
# .cirrus/wait-for-endpoint.sh http://127.0.0.1:8082 -t 10
run_its_script: |
echo "Run ITs on ${IDEA_VERSION}"
source .cirrus/use-gradle-wrapper.sh
# powershell -ExecutionPolicy Bypass -File ".cirrus/foreground.ps1"
gradle :its:check --stacktrace -i -PijVersion=${IDEA_VERSION} -PslPluginDirectory=${CIRRUS_WORKING_DIR}/staged-plugin
<<: *CLEANUP_GRADLE_CACHE_SCRIPT
always:
stop_recording_script: |
pkill -SIGINT -f ffmpeg
while pgrep ffmpeg >/dev/null; do sleep 1; done
/etc/init.d/xvfb stop
display_log_script:
- cat ${CIRRUS_WORKING_DIR}/runIdeGradle.log
test_recording_artifacts:
path: "${CIRRUS_WORKING_DIR}/recording_${IDEA_VERSION}.mp4"
log_artifacts:
path: "its/build/idea-sandbox/system/log"
image1_artifacts:
path: "${CIRRUS_WORKING_DIR}/image1_${IDEA_VERSION}.jpg"
image2_artifacts:
path: "${CIRRUS_WORKING_DIR}/image2_${IDEA_VERSION}.jpg"
image3_artifacts:
path: "${CIRRUS_WORKING_DIR}/image3_${IDEA_VERSION}.jpg"
image4_artifacts:
path: "${CIRRUS_WORKING_DIR}/image4_${IDEA_VERSION}.jpg"
on_failure:
xvfb_log_artifacts:
path: "${CIRRUS_WORKING_DIR}/Xvfb.out"
reports_artifacts:
path: "**/reports/**/*"
junit_artifacts:
Expand All @@ -391,7 +279,7 @@
slack_notification_script: |
source slack-failure-notification

inspect_orchestrator_cache_task:

Check warning on line 282 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L282

task "inspect_orchestrator_cache" depends on task "build", but their only_if conditions are different

Check warning on line 282 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L282

task "inspect_orchestrator_cache" depends on task "build", but their only_if conditions are different
<<: *ONLY_PR_AND_MAINTAINED_BRANCHES
depends_on: build
eks_container:
Expand Down Expand Up @@ -435,7 +323,7 @@
slack_notification_script: |
source slack-failure-notification

promote_task:

Check warning on line 326 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L326

task "promote" depends on task "mend_scan", but their only_if conditions are different

Check warning on line 326 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L326

task "promote" depends on task "build", but their only_if conditions are different

Check warning on line 326 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L326

task "promote" depends on task "mend_scan", but their only_if conditions are different

Check warning on line 326 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L326

task "promote" depends on task "build", but their only_if conditions are different
depends_on:
- build
- validate
Expand Down
67 changes: 67 additions & 0 deletions .cirrus/foreground.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Add-Type @"
using System;
using System.Runtime.InteropServices;

public class CustomUser32 {
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll", SetLastError = true)]
public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder lpString, int nMaxCount);

public static string GetActiveWindowTitle() {
IntPtr handle = GetForegroundWindow();
System.Text.StringBuilder sb = new System.Text.StringBuilder(256);
if (GetWindowText(handle, sb, sb.Capacity) > 0) {
return sb.ToString();
}
return null;
}
}
"@

function Print-AllProcessesWithMainWindowTitle {
$processes = Get-Process | Select-Object Id, ProcessName, MainWindowTitle

# Write the output to the console
$processes | ForEach-Object { Write-Output "Id: $_.Id, ProcessName: $_.ProcessName, MainWindowTitle: $_.MainWindowTitle" }
}

function Bring-WindowToForegroundByTitle {
param (
[string]$windowTitle,
[int]$maxRetries = 15,
[int]$retryDelay = 1000
)

Write-Output "Starting to try bring window to foreground"

for ($i = 0; $i -lt $maxRetries; $i++) {
$process = Get-Process | Where-Object { $_.MainWindowTitle -eq $windowTitle } | Select-Object -First 1

if ($null -ne $process) {
if ([CustomUser32]::SetForegroundWindow($process.MainWindowHandle)) {
Write-Output "Brought window with title '$windowTitle' to the foreground."
return
} else {
Start-Sleep -Milliseconds $retryDelay
}
} else {
Write-Output "No window with the title '$windowTitle' found."
return
}
}

Write-Output "Failed to bring window with title '$windowTitle' to the foreground after $maxRetries attempts."
}

Write-Output "Starting to print process"

# Print all processes with main window titles
Print-AllProcessesWithMainWindowTitle

# Example call to bring the window with title "Welcome to IntelliJ IDEA" to the foreground
Bring-WindowToForegroundByTitle -windowTitle "Welcome to IntelliJ IDEA"
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
*/
package org.sonarlint.intellij.its.tests

import java.io.BufferedReader
import java.io.File
import java.io.InputStreamReader
import java.nio.file.Paths
import javax.imageio.ImageIO
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.condition.EnabledIf
Expand All @@ -38,6 +43,12 @@ class StandaloneIdeaTests : BaseUiTest() {

@Test
fun should_exclude_rule_and_focus_on_new_code() = uiTest {
remoteRobot.getScreenshot()
val screenshot = remoteRobot.getScreenshot()
val cirrusWorkingDir = System.getenv("CIRRUS_WORKING_DIR")
val ideaVersion = System.getenv("IDEA_VERSION")
val outputFile = File("$cirrusWorkingDir/image1_$ideaVersion.jpg")
ImageIO.write(screenshot, "png", outputFile)
openExistingProject("sample-java-issues")
openFile("src/main/java/foo/Foo.java", "Foo.java")
toggleRule("java:S2094", "Classes should not be empty")
Expand All @@ -59,6 +70,12 @@ class StandaloneIdeaTests : BaseUiTest() {

@Test
fun should_exclude_file_and_analyze_file_and_no_issues_found() = uiTest {
remoteRobot.getScreenshot()
val screenshot = remoteRobot.getScreenshot()
val cirrusWorkingDir = System.getenv("CIRRUS_WORKING_DIR")
val ideaVersion = System.getenv("IDEA_VERSION")
val outputFile = File("$cirrusWorkingDir/image2_$ideaVersion.jpg")
ImageIO.write(screenshot, "png", outputFile)
openExistingProject("sample-java-issues")
excludeFile("src/main/java/foo/Foo.java")
openFile("src/main/java/foo/Foo.java", "Foo.java")
Expand All @@ -68,8 +85,42 @@ class StandaloneIdeaTests : BaseUiTest() {

@Test
fun chart() = uiTest {
remoteRobot.getScreenshot()
val screenshot = remoteRobot.getScreenshot()
val cirrusWorkingDir = System.getenv("CIRRUS_WORKING_DIR")
val ideaVersion = System.getenv("IDEA_VERSION")
val outputFile = File("$cirrusWorkingDir/image3_$ideaVersion.jpg")
ImageIO.write(screenshot, "png", outputFile)
openExistingProject("DuplicatedEnvsChart")
openFile("templates/memory_limit_pod2.yml", "memory_limit_pod2.yml")
verifyCurrentFileTabContainsMessages("Bind this resource's automounted service account to RBAC or disable automounting.")
}

fun executePS() {
try {
// Specify the PowerShell script to execute, located in the same directory as this Java file
val scriptPath = Paths.get(System.getProperty("user.dir"), "src", "test", "kotlin", "org", "sonarlint", "intellij", "its", "tests", "foreground.ps1").toString()
//val scriptPath = Paths.get(System.getProperty("user.dir"), "foreground.ps1").toString()

// Create a ProcessBuilder to execute the PowerShell script
val processBuilder = ProcessBuilder("powershell.exe", "-File", scriptPath)
processBuilder.redirectErrorStream(true)

// Start the process
val process = processBuilder.start()

// Read the output from the PowerShell script
val reader = BufferedReader(InputStreamReader(process.inputStream))
var line: String?
while ((reader.readLine().also { line = it }) != null) {
println(line)
}

// Wait for the process to complete and get the exit value
val exitCode = process.waitFor()
println("Exited with code: $exitCode")
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Loading
Loading