Skip to content

Commit c13efc8

Browse files
Andrea Falzettifelladrinakosyakov
committed
feat: change jetbrains ides dir layout
Co-authored-by: Victor Nogueira <[email protected]> Co-authored-by: Anton Kosyakov <[email protected]>
1 parent d1072e1 commit c13efc8

25 files changed

+359
-123
lines changed

.github/workflows/jetbrains-auto-update-template.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,25 @@ jobs:
4141
uses: google-github-actions/setup-gcloud@v0
4242
with:
4343
project_id: ${{ secrets.projectId }}
44-
- name: Get Platform Version from JetBrains EAP Backend Plugin
45-
id: platform-version
46-
run: |
47-
PLATFORM_VERSION=$(cat ./components/ide/jetbrains/backend-plugin/gradle-latest.properties | grep platformVersion= | sed 's/platformVersion=//' | sed 's/-EAP-CANDIDATE-SNAPSHOT//')
48-
echo "::set-output name=result::$PLATFORM_VERSION"
49-
echo $PLATFORM_VERSION
5044
- name: Find IDE version to download
5145
id: ide-version
5246
run: |
53-
curl -sL "https://data.services.jetbrains.com/products/releases?code=${{ inputs.productCode }}&type=eap,rc,release&platform=linux" > releases.json
54-
IDE_VERSION=$(cat releases.json | jq -r -c 'first(.${{ inputs.productCode }}[] | select(.build | contains("${{ steps.platform-version.outputs.result }}")) | .build)')
55-
IDE_BACKEND_VERSION=$(cat releases.json | jq -r '.${{ inputs.productCode }}[0].version')
56-
rm releases.json
57-
echo "::set-output name=result::$IDE_VERSION"
58-
echo "::set-output name=ideBackendVersion::$IDE_BACKEND_VERSION"
59-
echo $IDE_VERSION
60-
echo $IDE_BACKEND_VERSION
47+
IDE_VERSIONS_JSON=$(bash ./components/ide/jetbrains/image/resolve-latest-ide-version.sh ${{ inputs.productCode }})
48+
IDE_BUILD_VERSION=$(echo "$IDE_VERSIONS_JSON" | jq -r .IDE_BUILD_VERSION)
49+
IDE_VERSION=$(echo "$IDE_VERSIONS_JSON" | jq -r .IDE_VERSION)
50+
echo "IDE_BUILD_VERSION: $IDE_BUILD_VERSION"
51+
echo "IDE_VERSION: $IDE_VERSION"
52+
echo "::set-output name=ideBuildVersion::$IDE_BUILD_VERSION"
53+
echo "::set-output name=ideVersion::$IDE_VERSION"
6154
- name: Leeway build
62-
if: ${{ steps.ide-version.outputs.result }}
55+
if: ${{ steps.ide-version.outputs.ideBuildVersion }}
6356
env:
6457
LEEWAY_MAX_PROVENANCE_BUNDLE_SIZE: "8388608"
6558
run: |
6659
gcloud auth configure-docker --quiet
6760
export LEEWAY_WORKSPACE_ROOT=$(pwd)
6861
cd components/ide/jetbrains/image
69-
leeway build -Dversion=latest -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build -DbuildNumber=${{ steps.ide-version.outputs.result }} .:${{ inputs.productId }}-latest -DjbBackendVersion=${{ steps.ide-version.outputs.ideBackendVersion }}
62+
leeway build -Dversion=latest -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build -DbuildNumber=${{ steps.ide-version.outputs.ideBuildVersion }} .:${{ inputs.productId }}-latest -DjbBackendVersion=${{ steps.ide-version.outputs.ideVersion }}
7063
- name: Get previous job's status
7164
id: lastrun
7265
uses: filiptronicek/get-last-job-status@main

components/ide/jetbrains/backend-plugin/leeway.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ FROM scratch
1111
ARG JETBRAINS_BACKEND_QUALIFIER
1212
# ensures right permissions for /ide-desktop-plugins
1313
COPY --from=base_builder --chown=33333:33333 /ide-desktop-plugins/ /ide-desktop-plugins/
14+
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin-${JETBRAINS_BACKEND_QUALIFIER}/build/gitpod-remote /ide-desktop-plugins/gitpod-remote-${JETBRAINS_BACKEND_QUALIFIER}/
15+
16+
# added for backwards compatibility, can be removed in the future
1417
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin-${JETBRAINS_BACKEND_QUALIFIER}/build/gitpod-remote /ide-desktop-plugins/gitpod-remote/

components/ide/jetbrains/cli/cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func Execute() {
2727

2828
func getCliApiUrl() *url.URL {
2929
var backendPort = 63342
30+
// TODO look up under alias + qualifier, i.e. intellij or intellij-latest
3031
if _, fileStatError := os.Stat("/ide-desktop/bin/idea-cli-dev"); !errors.Is(fileStatError, os.ErrNotExist) {
3132
backendPort = backendPort + 1
3233
}

components/ide/jetbrains/image/BUILD.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const generateIDEBuildPackage = function (ideConfig, qualifier) {
5454
let pkg = {
5555
name,
5656
type: "docker",
57-
srcs: ["startup.sh", `supervisor-ide-config_${ideConfig.name}.json`],
57+
srcs: ["startup.sh", `supervisor-ide-config_${name}.json`],
5858
deps: ["components/ide/jetbrains/image/status:app", `:download-${name}`, "components/ide/jetbrains/cli:app"],
5959
config: {
6060
dockerfile: "leeway.Dockerfile",
@@ -63,7 +63,7 @@ const generateIDEBuildPackage = function (ideConfig, qualifier) {
6363
},
6464
buildArgs: {
6565
JETBRAINS_DOWNLOAD_QUALIFIER: name,
66-
SUPERVISOR_IDE_CONFIG: `supervisor-ide-config_${ideConfig.name}.json`,
66+
SUPERVISOR_IDE_CONFIG: `supervisor-ide-config_${name}.json`,
6767
JETBRAINS_BACKEND_QUALIFIER: qualifier,
6868
JETBRAINS_BACKEND_VERSION: getIDEVersion(qualifier, args[`${ideConfig.name}DownloadUrl`]),
6969
},
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License-AGPL.txt in the project root for license information.
4+
5+
// @ts-check
6+
const fs = require("fs");
7+
8+
const ideConfigs = [
9+
{
10+
name: "intellij",
11+
displayName: "IntelliJ IDEA",
12+
},
13+
{
14+
name: "goland",
15+
displayName: "GoLand",
16+
},
17+
{
18+
name: "pycharm",
19+
displayName: "PyCharm",
20+
},
21+
{
22+
name: "phpstorm",
23+
displayName: "PhpStorm",
24+
},
25+
{
26+
name: "rubymine",
27+
displayName: "RubyMine",
28+
},
29+
{
30+
name: "webstorm",
31+
displayName: "WebStorm",
32+
},
33+
{
34+
name: "rider",
35+
displayName: "Rider",
36+
},
37+
{
38+
name: "clion",
39+
displayName: "CLion",
40+
},
41+
];
42+
43+
["stable", "latest"].forEach((qualifier) => {
44+
ideConfigs.forEach((ideConfig) => {
45+
const name = ideConfig.name + (qualifier === "stable" ? "" : "-" + qualifier);
46+
const template = {
47+
entrypoint: `/ide-desktop/${name}/status`,
48+
entrypointArgs: ["{DESKTOPIDEPORT}", ideConfig.name, `Open in ${ideConfig.displayName}`],
49+
readinessProbe: {
50+
type: "http",
51+
http: {
52+
path: "/status",
53+
},
54+
},
55+
};
56+
fs.writeFileSync(`supervisor-ide-config_${name}.json`, JSON.stringify(template, null, 2), "utf-8");
57+
});
58+
});

components/ide/jetbrains/image/hot-deploy.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ echo "Product: $product"
1919
qualifier=${2:-latest}
2020
echo "Qualifier: $qualifier"
2121

22+
product_code=${3}
23+
echo "Product Code: $product_code"
24+
2225
if [ "$qualifier" == "stable" ]; then
2326
component=$product
2427
else
@@ -31,7 +34,10 @@ echo "Image Version: $version"
3134
bldfn="/tmp/build-$version.tar.gz"
3235

3336
docker ps &> /dev/null || (echo "You need a working Docker daemon. Maybe set DOCKER_HOST?"; exit 1)
34-
leeway build -Dversion="$version" -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build ".:$component" --save "$bldfn"
37+
IDE_VERSIONS_JSON=$(bash "$ROOT_DIR/components/ide/jetbrains/image/resolve-latest-ide-version.sh" "$product_code")
38+
IDE_BUILD_VERSION=$(echo "$IDE_VERSIONS_JSON" | jq -r .IDE_BUILD_VERSION)
39+
IDE_VERSION=$(echo "$IDE_VERSIONS_JSON" | jq -r .IDE_VERSION)
40+
leeway build -Dversion="$version" -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build -DbuildNumber="$IDE_BUILD_VERSION" -DjbBackendVersion="$IDE_VERSION" ".:$component" --save "$bldfn"
3541
dev_image="$(tar xfO "$bldfn" ./imgnames.txt | head -n1)"
3642
echo "Dev Image: $dev_image"
3743

components/ide/jetbrains/image/leeway.Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ ARG SUPERVISOR_IDE_CONFIG
1515
# ensures right permissions for /ide-desktop
1616
COPY --from=base_builder --chown=33333:33333 /ide-desktop/ /ide-desktop/
1717
COPY --chown=33333:33333 ${SUPERVISOR_IDE_CONFIG} /ide-desktop/supervisor-ide-config.json
18-
COPY --chown=33333:33333 components-ide-jetbrains-image--download-${JETBRAINS_DOWNLOAD_QUALIFIER}/backend /ide-desktop/backend
19-
COPY --chown=33333:33333 components-ide-jetbrains-image-status--app/status /ide-desktop
18+
COPY --chown=33333:33333 components-ide-jetbrains-image--download-${JETBRAINS_DOWNLOAD_QUALIFIER}/backend /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/backend
19+
COPY --chown=33333:33333 components-ide-jetbrains-image-status--app/status /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}
2020

2121
ARG JETBRAINS_BACKEND_QUALIFIER
2222
ENV GITPOD_ENV_SET_JETBRAINS_BACKEND_QUALIFIER ${JETBRAINS_BACKEND_QUALIFIER}
2323

24-
COPY --chown=33333:33333 components-ide-jetbrains-cli--app/cli /ide-desktop/bin/idea-cli
25-
ENV GITPOD_ENV_APPEND_PATH /ide-desktop/bin:
24+
COPY --chown=33333:33333 components-ide-jetbrains-cli--app/cli /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli
25+
ENV GITPOD_ENV_APPEND_PATH /ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin:
2626

2727
# editor config
28-
ENV GITPOD_ENV_SET_EDITOR "/ide-desktop/bin/idea-cli open"
28+
ENV GITPOD_ENV_SET_EDITOR "/ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli open"
2929
ENV GITPOD_ENV_SET_VISUAL "$GITPOD_ENV_SET_EDITOR"
3030
ENV GITPOD_ENV_SET_GP_OPEN_EDITOR "$GITPOD_ENV_SET_EDITOR"
3131
ENV GITPOD_ENV_SET_GIT_EDITOR "$GITPOD_ENV_SET_EDITOR --wait"
32-
ENV GITPOD_ENV_SET_GP_PREVIEW_BROWSER "/ide-desktop/bin/idea-cli preview"
33-
ENV GITPOD_ENV_SET_GP_EXTERNAL_BROWSER "/ide-desktop/bin/idea-cli preview"
32+
ENV GITPOD_ENV_SET_GP_PREVIEW_BROWSER "/ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli preview"
33+
ENV GITPOD_ENV_SET_GP_EXTERNAL_BROWSER "/ide-desktop/${JETBRAINS_DOWNLOAD_QUALIFIER}/bin/idea-cli preview"
3434

3535
LABEL "io.gitpod.ide.version"=$JETBRAINS_BACKEND_VERSION
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
# Licensed under the GNU Affero General Public License (AGPL).
4+
# See License-AGPL.txt in the project root for license information.
5+
6+
set -Eeuo pipefail
7+
8+
ROOT_DIR="$(dirname "$0")/../../../.."
9+
PRODUCT_CODE=${1}
10+
TEMP_FILENAME=$(mktemp)
11+
PLUGIN_PLATFORM_VERSION=$(grep platformVersion= "$ROOT_DIR/components/ide/jetbrains/backend-plugin/gradle-latest.properties" | sed 's/platformVersion=//' | sed 's/-EAP-CANDIDATE-SNAPSHOT//') # Example: PLUGIN_PLATFORM_VERSION: 223.7571
12+
13+
curl -sL "https://data.services.jetbrains.com/products/releases?code=$PRODUCT_CODE&type=eap,rc,release&platform=linux" > "$TEMP_FILENAME"
14+
IDE_BUILD_VERSION=$(jq -r -c "first(.${PRODUCT_CODE}[] | select(.build | contains(\"$PLUGIN_PLATFORM_VERSION\")) | .build)" < "$TEMP_FILENAME") # Example: IDE_BUILD_VERSION: 223.7571.176
15+
IDE_VERSION=$(jq -r ".${PRODUCT_CODE}[0].version" < "$TEMP_FILENAME") # Example: IDE_VERSION: 2022.3
16+
rm "$TEMP_FILENAME"
17+
18+
echo "{\"IDE_BUILD_VERSION\": \"$IDE_BUILD_VERSION\", \"IDE_VERSION\": \"$IDE_VERSION\"}"

components/ide/jetbrains/image/status/main.go

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ var (
4747
Version = ""
4848
)
4949

50-
const BackendPath = "/ide-desktop/backend"
51-
const ProductInfoPath = BackendPath + "/product-info.json"
52-
5350
type LaunchContext struct {
5451
startTime time.Time
5552

5653
port string
5754
alias string
5855
label string
5956

57+
qualifier string
58+
productDir string
59+
backendDir string
6060
info *ProductInfo
6161
backendVersion *version.Version
6262
wsInfo *supervisor.WorkspaceInfoResponse
@@ -99,7 +99,16 @@ func main() {
9999
label = os.Args[3]
100100
}
101101

102-
info, err := resolveProductInfo()
102+
qualifier := os.Getenv("JETBRAINS_BACKEND_QUALIFIER")
103+
if qualifier == "stable" {
104+
qualifier = ""
105+
} else {
106+
qualifier = "-" + qualifier
107+
}
108+
productDir := "/ide-desktop/" + alias + qualifier
109+
backendDir := productDir + "/backend"
110+
111+
info, err := resolveProductInfo(backendDir)
103112
if err != nil {
104113
log.WithError(err).Error("failed to resolve product info")
105114
return
@@ -124,6 +133,9 @@ func main() {
124133
alias: alias,
125134
label: label,
126135

136+
qualifier: qualifier,
137+
productDir: productDir,
138+
backendDir: backendDir,
127139
info: info,
128140
backendVersion: backendVersion,
129141
wsInfo: wsInfo,
@@ -359,19 +371,12 @@ func launch(launchCtx *LaunchContext) {
359371
idePrefix = "idea"
360372
}
361373
// [idea64|goland64|pycharm64|phpstorm64].vmoptions
362-
launchCtx.vmOptionsFile = fmt.Sprintf("/ide-desktop/backend/bin/%s64.vmoptions", idePrefix)
374+
launchCtx.vmOptionsFile = fmt.Sprintf(launchCtx.backendDir+"/bin/%s64.vmoptions", idePrefix)
363375
err = configureVMOptions(gitpodConfig, launchCtx.alias, launchCtx.vmOptionsFile)
364376
if err != nil {
365377
log.WithError(err).Error("failed to configure vmoptions")
366378
}
367379

368-
qualifier := os.Getenv("JETBRAINS_BACKEND_QUALIFIER")
369-
if qualifier == "stable" {
370-
qualifier = ""
371-
} else {
372-
qualifier = "-" + qualifier
373-
}
374-
375380
var riderSolutionFile string
376381
if launchCtx.alias == "rider" {
377382
riderSolutionFile, err = findRiderSolutionFile(projectDir)
@@ -380,10 +385,10 @@ func launch(launchCtx *LaunchContext) {
380385
}
381386
}
382387

383-
configDir := fmt.Sprintf("/workspace/.config/JetBrains%s", qualifier)
388+
configDir := fmt.Sprintf("/workspace/.config/JetBrains%s", launchCtx.qualifier)
384389
launchCtx.projectDir = projectDir
385390
launchCtx.configDir = configDir
386-
launchCtx.systemDir = fmt.Sprintf("/workspace/.cache/JetBrains%s", qualifier)
391+
launchCtx.systemDir = fmt.Sprintf("/workspace/.cache/JetBrains%s", launchCtx.qualifier)
387392
launchCtx.riderSolutionFile = riderSolutionFile
388393
launchCtx.projectContextDir = resolveProjectContextDir(launchCtx)
389394
launchCtx.projectConfigDir = fmt.Sprintf("%s/RemoteDev-%s/%s", configDir, launchCtx.info.ProductCode, strings.ReplaceAll(launchCtx.projectContextDir, "/", "_"))
@@ -407,7 +412,7 @@ func launch(launchCtx *LaunchContext) {
407412
}
408413

409414
// install gitpod plugin
410-
err = linkRemotePlugin()
415+
err = linkRemotePlugin(launchCtx)
411416
if err != nil {
412417
log.WithError(err).Error("failed to install gitpod-remote plugin")
413418
}
@@ -445,7 +450,7 @@ func run(launchCtx *LaunchContext) {
445450
}
446451

447452
// resolveUserEnvs emulats the interactive login shell to ensure that all user defined shell scripts are loaded
448-
func resolveUserEnvs() (userEnvs []string, err error) {
453+
func resolveUserEnvs(launchCtx *LaunchContext) (userEnvs []string, err error) {
449454
shell := os.Getenv("SHELL")
450455
if shell == "" {
451456
shell = "/bin/bash"
@@ -454,7 +459,7 @@ func resolveUserEnvs() (userEnvs []string, err error) {
454459
if err != nil {
455460
return
456461
}
457-
envCmd := exec.Command(shell, []string{"-ilc", "/ide-desktop/status env " + mark.String()}...)
462+
envCmd := exec.Command(shell, []string{"-ilc", launchCtx.productDir + "/status env " + mark.String()}...)
458463
envCmd.Stderr = os.Stderr
459464
output, err := envCmd.Output()
460465
if err != nil {
@@ -469,7 +474,7 @@ func resolveUserEnvs() (userEnvs []string, err error) {
469474

470475
func remoteDevServerCmd(args []string, launchCtx *LaunchContext) *exec.Cmd {
471476
if launchCtx.env == nil {
472-
userEnvs, err := resolveUserEnvs()
477+
userEnvs, err := resolveUserEnvs(launchCtx)
473478
if err == nil {
474479
launchCtx.env = append(launchCtx.env, userEnvs...)
475480
} else {
@@ -484,15 +489,15 @@ func remoteDevServerCmd(args []string, launchCtx *LaunchContext) *exec.Cmd {
484489
fmt.Sprintf("IJ_HOST_SYSTEM_BASE_DIR=%s", launchCtx.systemDir),
485490
)
486491

487-
// instead put them into /ide-desktop/backend/bin/idea64.vmoptions
492+
// instead put them into /ide-desktop/${alias}${qualifier}/backend/bin/idea64.vmoptions
488493
// otherwise JB will complain to a user on each startup
489-
// by default remote dev already set -Xmx2048m, see /ide-desktop/backend/plugins/remote-dev-server/bin/launcher.sh
494+
// by default remote dev already set -Xmx2048m, see /ide-desktop/${alias}${qualifier}/backend/plugins/remote-dev-server/bin/launcher.sh
490495
launchCtx.env = append(launchCtx.env, "JAVA_TOOL_OPTIONS=")
491496

492497
log.WithField("env", launchCtx.env).Debug("resolved launch env")
493498
}
494499

495-
cmd := exec.Command(BackendPath+"/bin/remote-dev-server.sh", args...)
500+
cmd := exec.Command(launchCtx.backendDir+"/bin/remote-dev-server.sh", args...)
496501
cmd.Env = launchCtx.env
497502
cmd.Stderr = os.Stderr
498503
cmd.Stdout = os.Stdout
@@ -619,8 +624,8 @@ type ProductInfo struct {
619624
ProductCode string `json:"productCode"`
620625
}
621626

622-
func resolveProductInfo() (*ProductInfo, error) {
623-
f, err := os.Open(ProductInfoPath)
627+
func resolveProductInfo(backendDir string) (*ProductInfo, error) {
628+
f, err := os.Open(backendDir + "/product-info.json")
624629
if err != nil {
625630
return nil, err
626631
}
@@ -764,12 +769,20 @@ func getProductConfig(config *gitpod.GitpodConfig, alias string) *gitpod.Jetbrai
764769
return productConfig
765770
}
766771

767-
func linkRemotePlugin() error {
768-
remotePluginDir := BackendPath + "/plugins/gitpod-remote"
772+
func linkRemotePlugin(launchCtx *LaunchContext) error {
773+
remotePluginDir := launchCtx.backendDir + "/plugins/gitpod-remote"
769774
_, err := os.Stat(remotePluginDir)
770775
if err == nil || !errors.Is(err, os.ErrNotExist) {
771776
return nil
772777
}
778+
779+
// added for backwards compatibility, can be removed in the future
780+
sourceDir := "/ide-desktop-plugins/gitpod-remote-" + os.Getenv("JETBRAINS_BACKEND_QUALIFIER")
781+
_, err = os.Stat(sourceDir)
782+
if err == nil {
783+
return os.Symlink(sourceDir, remotePluginDir)
784+
}
785+
773786
return os.Symlink("/ide-desktop-plugins/gitpod-remote", remotePluginDir)
774787
}
775788

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"entrypoint": "/ide-desktop/clion-latest/status",
3+
"entrypointArgs": [
4+
"{DESKTOPIDEPORT}",
5+
"clion",
6+
"Open in CLion"
7+
],
8+
"readinessProbe": {
9+
"type": "http",
10+
"http": {
11+
"path": "/status"
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)