Skip to content

Commit 8819c5c

Browse files
committed
cherry-pick jeanp413's add test user
test mask
1 parent 854c81c commit 8819c5c

File tree

18 files changed

+827
-75
lines changed

18 files changed

+827
-75
lines changed
+48-41
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
1-
name: JB Nightly
1+
name: JetBrains Test
22
on:
33
workflow_dispatch:
4-
schedule:
5-
# At 11:00 on every day.
6-
- cron: "0 11 * * *"
7-
4+
inputs:
5+
gateway-link:
6+
type: string
7+
description: GatewayLink
8+
required: true
9+
owner-token:
10+
type: string
11+
description: OwnerToken
12+
required: true
813
jobs:
9-
intellij:
10-
uses: ./.github/workflows/jetbrains-auto-update-template.yml
11-
with:
12-
productId: intellij
13-
productCode: IIU
14-
secrets:
15-
projectId: ${{ secrets.GCP_PROJECT_ID }}
16-
serviceAccountKey: ${{ secrets.GCP_SA_KEY }}
17-
slackWebhook: ${{ secrets.IDE_SLACK_WEBHOOK }}
18-
goland:
19-
uses: ./.github/workflows/jetbrains-auto-update-template.yml
20-
with:
21-
productId: goland
22-
productCode: GO
23-
secrets:
24-
projectId: ${{ secrets.GCP_PROJECT_ID }}
25-
serviceAccountKey: ${{ secrets.GCP_SA_KEY }}
26-
slackWebhook: ${{ secrets.IDE_SLACK_WEBHOOK }}
27-
pycharm:
28-
uses: ./.github/workflows/jetbrains-auto-update-template.yml
29-
with:
30-
productId: pycharm
31-
productCode: PCP
32-
secrets:
33-
projectId: ${{ secrets.GCP_PROJECT_ID }}
34-
serviceAccountKey: ${{ secrets.GCP_SA_KEY }}
35-
slackWebhook: ${{ secrets.IDE_SLACK_WEBHOOK }}
36-
phpstorm:
37-
uses: ./.github/workflows/jetbrains-auto-update-template.yml
38-
with:
39-
productId: phpstorm
40-
productCode: PS
41-
secrets:
42-
projectId: ${{ secrets.GCP_PROJECT_ID }}
43-
serviceAccountKey: ${{ secrets.GCP_SA_KEY }}
44-
slackWebhook: ${{ secrets.IDE_SLACK_WEBHOOK }}
14+
jetbrains-smoke-test-mac:
15+
runs-on: macos-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Setup Java
19+
uses: actions/setup-java@v2
20+
with:
21+
distribution: zulu
22+
java-version: 11
23+
- name: Setup FFmpeg
24+
uses: FedericoCarboni/setup-ffmpeg@v1
25+
with:
26+
# Not strictly necessary, but it may prevent rate limit
27+
# errors especially on GitHub-hosted macos machines.
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
# - name: Build Gateway Plugin
30+
# working-directory: ./components/ide/jetbrains/gateway-plugin
31+
# run: |
32+
# ./gradlew -PpluginVersion=test buildPlugin
33+
- name: Smoke Test
34+
working-directory: ./dev/jetbrains-test
35+
env:
36+
GATEWAY_LINK: ::add-mask::${{ github.event.inputs.gateway-link }}
37+
GATEWAY_PLUGIN_PATH: ../../components/ide/jetbrains/gateway-plugin/build/distributions/gitpod-gateway-test.zip
38+
run: |
39+
gradle :test
40+
cp -r ./video/ ./build/reports
41+
- name: Move video
42+
if: always()
43+
run: |
44+
cp -r dev/jetbrains-test/video dev/jetbrains-test/build/reports
45+
- name: Save report
46+
if: always()
47+
uses: actions/upload-artifact@v2
48+
with:
49+
name: video
50+
path: |
51+
dev/jetbrains-test/build/reports

dev/jetbrains-test/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gradle
2+
.idea
3+
build
4+
bin

dev/jetbrains-test/build.gradle

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
plugins {
2+
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
3+
}
4+
5+
group 'org.example'
6+
version '1.0-SNAPSHOT'
7+
8+
repositories {
9+
mavenCentral()
10+
maven { url = "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies" }
11+
}
12+
13+
test {
14+
systemProperty 'gateway_link', System.getenv('GATEWAY_LINK')
15+
systemProperty 'gateway_plugin_path', System.getenv('GATEWAY_PLUGIN_PATH')
16+
useJUnitPlatform()
17+
}
18+
19+
dependencies {
20+
implementation "org.jetbrains.kotlin:kotlin-stdlib"
21+
22+
implementation("com.google.code.gson:gson:2.8.9")
23+
implementation("com.squareup.okhttp3:okhttp:4.9.3")
24+
implementation("com.intellij.remoterobot:remote-robot:0.11.12")
25+
implementation("com.intellij.remoterobot:remote-fixtures:0.11.12")
26+
27+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
28+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
29+
30+
// Logging Network Calls
31+
testImplementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'
32+
33+
// Video Recording
34+
implementation 'com.automation-remarks:video-recorder-junit5:2.0'
35+
}

dev/jetbrains-test/gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kotlin.code.style=official
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

dev/jetbrains-test/gradlew.bat

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
17+
@if "%DEBUG%" == "" @echo off
18+
@rem ##########################################################################
19+
@rem
20+
@rem Gradle startup script for Windows
21+
@rem
22+
@rem ##########################################################################
23+
24+
@rem Set local scope for the variables with windows NT shell
25+
if "%OS%"=="Windows_NT" setlocal
26+
27+
set DIRNAME=%~dp0
28+
if "%DIRNAME%" == "" set DIRNAME=.
29+
set APP_BASE_NAME=%~n0
30+
set APP_HOME=%DIRNAME%
31+
32+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34+
35+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37+
38+
@rem Find java.exe
39+
if defined JAVA_HOME goto findJavaFromJavaHome
40+
41+
set JAVA_EXE=java.exe
42+
%JAVA_EXE% -version >NUL 2>&1
43+
if "%ERRORLEVEL%" == "0" goto execute
44+
45+
echo.
46+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47+
echo.
48+
echo Please set the JAVA_HOME variable in your environment to match the
49+
echo location of your Java installation.
50+
51+
goto fail
52+
53+
:findJavaFromJavaHome
54+
set JAVA_HOME=%JAVA_HOME:"=%
55+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56+
57+
if exist "%JAVA_EXE%" goto execute
58+
59+
echo.
60+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61+
echo.
62+
echo Please set the JAVA_HOME variable in your environment to match the
63+
echo location of your Java installation.
64+
65+
goto fail
66+
67+
:execute
68+
@rem Setup the command line
69+
70+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71+
72+
73+
@rem Execute Gradle
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75+
76+
:end
77+
@rem End local scope for the variables with windows NT shell
78+
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
80+
:fail
81+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82+
rem the _cmd.exe /c_ return code!
83+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84+
exit /b 1
85+
86+
:mainEnd
87+
if "%OS%"=="Windows_NT" endlocal
88+
89+
:omega

dev/jetbrains-test/settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = 'jetbrains-test'
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package io.gitpod.jetbrains.launcher
2+
3+
enum class Ide(val code: String, val feedsCode: String) {
4+
IDEA_COMMUNITY("IC", "IIC"),
5+
IDEA_ULTIMATE("IU", "IIU"),
6+
CLION("CL", "CL"),
7+
WEBSTORM("WS", "WS"),
8+
RUBY_MINE("RM", "RM"),
9+
PYCHARM("PY", "PCP"),
10+
GATEWAY("GW", "GW");
11+
12+
fun getIdePropertiesEnvVarName() = when (this) {
13+
IDEA_COMMUNITY, IDEA_ULTIMATE -> "IDEA_PROPERTIES"
14+
CLION -> "CLION_PROPERTIES"
15+
WEBSTORM -> if (Os.hostOS() == Os.MAC) "WEBSTORM_PROPERTIES" else "WEBIDE_PROPERTIES"
16+
RUBY_MINE -> "RUBYMINE_PROPERTIES"
17+
PYCHARM -> "PYCHARM_PROPERTIES"
18+
GATEWAY -> "GATEWAY_PROPERTIES"
19+
}
20+
21+
fun getVmOptionsEnvVarName() = when (this) {
22+
IDEA_COMMUNITY, IDEA_ULTIMATE -> "IDEA_VM_OPTIONS"
23+
CLION -> "CLION_VM_OPTIONS"
24+
WEBSTORM -> if (Os.hostOS() == Os.MAC) "WEBSTORM_VM_OPTIONS" else "WEBIDE_VM_OPTIONS"
25+
RUBY_MINE -> "RUBYMINE_VM_OPTIONS"
26+
PYCHARM -> "PYCHARM_VM_OPTIONS"
27+
GATEWAY -> "GATEWAY_VM_OPTIONS"
28+
}.let {
29+
if (Os.hostOS() == Os.WINDOWS) {
30+
val productPrefix = it.substringBefore("_")
31+
"${productPrefix}64${it.removePrefix(productPrefix)}"
32+
} else {
33+
it
34+
}
35+
}
36+
37+
companion object {
38+
fun withCode(code: String) = values().single { it.code == code }
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package io.gitpod.jetbrains.launcher
2+
3+
import com.google.gson.JsonParser
4+
import okhttp3.HttpUrl.Companion.toHttpUrl
5+
import okhttp3.OkHttpClient
6+
import okhttp3.Request
7+
import java.nio.file.Files
8+
import java.nio.file.Path
9+
import java.nio.file.StandardOpenOption
10+
11+
class IdeDownloader @JvmOverloads constructor(private val httpClient: OkHttpClient = OkHttpClient()) {
12+
13+
private companion object {
14+
const val ROBOT_PLUGIN_VERSION_DEFAULT = "0.11.9"
15+
16+
fun getRobotServerPluginDownloadUrl(version: String): String =
17+
"https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/com/intellij/remoterobot/robot-server-plugin/$version/robot-server-plugin-$version.zip"
18+
19+
fun getFeedsOsPropertyName() = when (Os.hostOS()) {
20+
Os.WINDOWS -> "windowsZip"
21+
Os.LINUX -> "linux"
22+
Os.MAC -> "mac"
23+
}
24+
}
25+
26+
fun downloadAndExtractLatestEap(ide: Ide, toDir: Path): Path {
27+
val idePackage = downloadIde(ide, toDir)
28+
return extractIde(idePackage, toDir)
29+
}
30+
31+
@JvmOverloads
32+
fun downloadRobotPlugin(toDir: Path, version: String = ROBOT_PLUGIN_VERSION_DEFAULT): Path {
33+
return downloadFile(getRobotServerPluginDownloadUrl(version), toDir.resolve("robot-server-plugin-$version"))
34+
}
35+
36+
private fun extractIde(idePackage: Path, toDir: Path): Path = when (Os.hostOS()) {
37+
Os.LINUX -> extractTar(idePackage, toDir).single()
38+
Os.MAC -> extractDmgApp(idePackage, toDir)
39+
Os.WINDOWS -> {
40+
val appDir = Files.createDirectory(toDir.resolve(idePackage.fileName.toString().substringBefore(".win.zip")))
41+
extractZip(idePackage, appDir)
42+
appDir
43+
}
44+
}
45+
46+
private fun downloadIde(ide: Ide, toDir: Path): Path {
47+
val ideDownloadLink = getIdeDownloadUrl(ide, httpClient)
48+
val idePackageName = ideDownloadLink.substringAfterLast("/").removeSuffix("/")
49+
val targetFile = toDir.resolve(idePackageName)
50+
return downloadFile(ideDownloadLink, targetFile)
51+
}
52+
53+
private fun downloadFile(url: String, toFile: Path): Path {
54+
return httpClient.newCall(Request.Builder().url(url).build()).execute().use { response ->
55+
check(response.isSuccessful) { "failed to download file from $url" }
56+
Files.newOutputStream(toFile, StandardOpenOption.CREATE_NEW).use {
57+
response.body!!.byteStream().buffered().copyTo(it)
58+
}
59+
toFile
60+
}
61+
}
62+
63+
private fun getIdeDownloadUrl(ide: Ide, httpClient: OkHttpClient): String {
64+
return httpClient.newCall(
65+
Request.Builder().url(
66+
"https://data.services.jetbrains.com/products/releases".toHttpUrl()
67+
.newBuilder()
68+
.addQueryParameter("code", ide.feedsCode)
69+
.addQueryParameter("platform", getFeedsOsPropertyName())
70+
.build()
71+
).build()
72+
).execute().use { response ->
73+
check(response.isSuccessful) { "failed to get $ide feeds" }
74+
JsonParser.parseReader(response.body!!.charStream())
75+
.asJsonObject[ide.feedsCode]
76+
.asJsonArray
77+
.firstOrNull {
78+
it.asJsonObject["downloads"]?.asJsonObject?.keySet()?.isNotEmpty() ?: false
79+
}
80+
?.asJsonObject?.get("downloads")
81+
?.asJsonObject?.get(getFeedsOsPropertyName())
82+
?.asJsonObject?.get("link")
83+
?.asString ?: error("no suitable ide found")
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)