diff --git a/.werft/ide-integration-tests-startup-jetbrains.yaml b/.werft/ide-integration-tests-startup-jetbrains.yaml new file mode 100644 index 00000000000000..48302dc5abb6a8 --- /dev/null +++ b/.werft/ide-integration-tests-startup-jetbrains.yaml @@ -0,0 +1,111 @@ +pod: + serviceAccount: werft + nodeSelector: + dev/workload: builds + imagePullSecrets: + - name: eu-gcr-io-pull-secret + volumes: + - name: gcp-sa + secret: + secretName: gcp-sa-gitpod-dev-deployer + - name: config + emptyDir: {} + containers: + - name: gcloud + image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:clu-yq4.1 + workingDir: /workspace + imagePullPolicy: Always + env: + - name: NODENAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: ROBOQUAT_TOKEN + valueFrom: + secretKeyRef: + name: github-roboquat-automatic-changelog + key: token + volumeMounts: + - name: gcp-sa + mountPath: /mnt/secrets/gcp-sa + readOnly: true + - name: config + mountPath: /config + readOnly: false + command: + - bash + - -c + - | + set -euo pipefail + + BRANCH="inte-test/"$(date +%Y%m%d%H%M%S) + + function cleanup () + { + git push origin :$BRANCH + } + + source ./dev/preview/util/preview-name-from-branch.sh + + echo "preparing config." | werft log slice prepare + sudo chown -R gitpod:gitpod /workspace + gcloud auth activate-service-account --key-file /mnt/secrets/gcp-sa/service-account.json + export GOOGLE_APPLICATION_CREDENTIALS="/home/gitpod/.config/gcloud/legacy_credentials/cd-gitpod-deployer@gitpod-core-dev.iam.gserviceaccount.com/adc.json" + + git config --global user.name roboquat + git config --global user.email roboquat@gitpod.io + git remote set-url origin https://oauth2:$ROBOQUAT_TOKEN@github.com/gitpod-io/gitpod.git + + echo "copied config..." | werft log slice prepare + go install github.com/csweichel/oci-tool@latest 2>&1 | werft log slice prepare + werft log slice prepare --done + + werft log phase "build preview environment" "build preview environment" + echo integration test >> README.md + git checkout -B $BRANCH + git add README.md + git commit -m "integration test" + git push --set-upstream origin $BRANCH + trap cleanup SIGINT SIGTERM EXIT + + BUILD_ID=$(werft job list repo.ref==refs/heads/${BRANCH} -o yaml | yq r - "result[0].name") + until [ "$BUILD_ID" != "" ] + do + sleep 1 + BUILD_ID=$(werft job list repo.ref==refs/heads/${BRANCH} -o yaml | yq r - "result[0].name") + done + echo "start build preview environment, job name: ${BUILD_ID}, this will take long time" | werft log slice "build test environment" + werft log result -d "build job" url "https://werft.gitpod-dev.com/job/${BUILD_ID}" + + if ! werft job logs ${BUILD_ID} | werft log slice "build test environment"; + then + echo "build failed" | werft log slice "build test environment" + exit 1 + fi + echo "build success" | werft log slice "build test environment" + werft log slice "build test environment" --done + + werft log phase "integration test" "integration test" + + oci-tool fetch file eu.gcr.io/gitpod-core-dev/build/versions:${BUILD_ID:13} versions.yaml + INTEGRATION_VERSION=$(cat versions.yaml | yq r - 'components.integrationTest.version') + + echo "using integration-test image: ${INTEGRATION_VERSION}" | werft log slice "test" + + NAMESPACE="$(preview-name-from-branch)" + + JETBRAINS_IDE_LIST=(goland intellij phpstorm pycharm) + BUILD_ID_LIST=() + + for IDE in "${JETBRAINS_IDE_LIST[@]}" + do + TEST_BUILD_ID=$(werft run github -a version=${INTEGRATION_VERSION} -a namespace=staging-${NAMESPACE} --remote-job-path .werft/ide-run-integration-tests.yaml -a testPattern=jetbrains.test -a jetbrains-ide=${IDE}) + echo "running integration for ${IDE}, job name: ${TEST_BUILD_ID}" | werft log slice "test-${IDE}" + werft log result -d "integration test for ${IDE} job" url "https://werft.gitpod-dev.com/job/${TEST_BUILD_ID}" + werft job logs ${TEST_BUILD_ID} | werft log slice "test-${IDE}" & + BUILD_ID_LIST[${#BUILD_ID_LIST[@]}]=$TEST_BUILD_ID + sleep 2 + done + wait +plugins: + cron: "0 2 * * *" diff --git a/.werft/ide-integration-tests-startup.yaml b/.werft/ide-integration-tests-startup-vscode.yaml similarity index 100% rename from .werft/ide-integration-tests-startup.yaml rename to .werft/ide-integration-tests-startup-vscode.yaml diff --git a/dev/jetbrains-test/src/main/kotlin/io/gitpod/jetbrains/launcher/IdeDownloader.kt b/dev/jetbrains-test/src/main/kotlin/io/gitpod/jetbrains/launcher/IdeDownloader.kt index a0f8a42cb0e458..f32ced17696805 100644 --- a/dev/jetbrains-test/src/main/kotlin/io/gitpod/jetbrains/launcher/IdeDownloader.kt +++ b/dev/jetbrains-test/src/main/kotlin/io/gitpod/jetbrains/launcher/IdeDownloader.kt @@ -66,6 +66,7 @@ class IdeDownloader @JvmOverloads constructor(private val httpClient: OkHttpClie "https://data.services.jetbrains.com/products/releases".toHttpUrl() .newBuilder() .addQueryParameter("code", ide.feedsCode) + .addQueryParameter("type", "eap,rc,release") .addQueryParameter("platform", getFeedsOsPropertyName()) .build() ).build() diff --git a/test/tests/ide/jetbrains/gateway_test.go b/test/tests/ide/jetbrains/gateway_test.go index 3117506eb3f872..e20b7deeee31e1 100644 --- a/test/tests/ide/jetbrains/gateway_test.go +++ b/test/tests/ide/jetbrains/gateway_test.go @@ -24,6 +24,8 @@ import ( "github.com/google/go-github/v42/github" ) +var ideProjectMap map[string]string + type GatewayHostStatus struct { AppPid int64 `json:"appPid"` AppVersion string `json:"appVersion"` @@ -43,6 +45,14 @@ type GatewayHostStatus struct { UnattendedMode bool `json:"unattendedMode"` } +func init() { + ideProjectMap = make(map[string]string) + ideProjectMap["goland"] = "https://github.com/gitpod-io/template-golang-cli" + ideProjectMap["intellij"] = "https://github.com/gitpod-io/spring-petclinic" + ideProjectMap["phpstorm"] = "https://github.com/gitpod-io/template-php-laravel-mysql" + ideProjectMap["pycharm"] = "https://github.com/gitpod-io/template-python-django" +} + func GetHttpContent(url string) ([]byte, error) { resp, err := http.Get(url) if err != nil { @@ -57,7 +67,10 @@ func TestJetBrainsGatewayWorkspace(t *testing.T) { userToken, _ := os.LookupEnv("USER_TOKEN") ideName, ok := annotations["jetbrains-ide"] if !ok { - t.Skip("not provide a special IDE") + t.Skip("not provide a special IDE name") + } + if _, ok = ideProjectMap[ideName]; !ok { + t.Skip("not support " + ideName + " now") } roboquatToken, ok := os.LookupEnv("ROBOQUAT_TOKEN") if !ok { @@ -96,7 +109,7 @@ func TestJetBrainsGatewayWorkspace(t *testing.T) { t.Logf("connected to server") t.Logf("starting workspace") - nfo, stopWs, err := integration.LaunchWorkspaceFromContextURL(ctx, "referrer:jetbrains-gateway:"+ideName+"/https://github.com/gitpod-io/spring-petclinic", username, api) + nfo, stopWs, err := integration.LaunchWorkspaceFromContextURL(ctx, "referrer:jetbrains-gateway:"+ideName+"/"+ideProjectMap[ideName], username, api) if err != nil { t.Fatal(err) }