Skip to content

Commit d7ce11e

Browse files
authored
Merge branch 'main' into jp/sync-profile
2 parents aadcd08 + 249a563 commit d7ce11e

File tree

155 files changed

+17970
-2319
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+17970
-2319
lines changed

.github/workflows/code-nightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- run: |
3232
gcloud auth configure-docker --quiet
3333
export LEEWAY_WORKSPACE_ROOT=$(pwd)
34-
headCommit=$(curl -H 'Accept: application/vnd.github.VERSION.sha' https://github.com/api/repos/gitpod-io/openvscode-server/commits/gp-code/release/1.71)
34+
headCommit=$(curl -H 'Accept: application/vnd.github.VERSION.sha' https://github.com/api/repos/gitpod-io/openvscode-server/commits/gp-code/main)
3535
cd components/ide/code
3636
leeway build -Dversion=nightly -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build -DcodeCommit=$headCommit -DcodeQuality=insider .:docker
3737
- name: Get previous job's status

.github/workflows/delete-kots-channel.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ jobs:
1616
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
1717
mv replicated /usr/local/bin/replicated
1818
19+
- name: Delete replicated license
20+
run: |
21+
CUSTOMER_ID=$(replicated customer ls | grep ${{ github.event.ref }} | awk '{print $1}')
22+
if [ "${CUSTOMER_ID}" = "" ]; then
23+
echo "No license found"
24+
exit 0
25+
fi
26+
curl --request POST \
27+
--url https://api.replicated.com/vendor/v3/customer/${CUSTOMER_ID}/archive \
28+
--header 'Authorization: ${{ env.REPLICATED_API_TOKEN }}'
29+
1930
- name: Delete Replicated channel
2031
run: |
2132
CHANNEL_ID=$(replicated channel inspect ${{ github.event.ref }} \

.gitpod.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ tasks:
5858
init: yarn --network-timeout 100000 && yarn build
5959
- name: Go
6060
before: pre-commit install --install-hooks
61-
init: leeway exec --filter-type go -v -- go mod verify
61+
init: |
62+
./components/gitpod-protocol/go/scripts/generate-config.sh
63+
leeway exec --filter-type go -v -- go mod verify
6264
openMode: split-right
6365
vscode:
6466
extensions:

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ repos:
4545

4646
- repo: local
4747
hooks:
48-
- id: generate-gitpod-config-types
49-
name: generate-gitpod-config-types
50-
entry: ./components/gitpod-protocol/hack/generate-config.sh
51-
language: script
52-
pass_filenames: false
5348
- id: license-header
5449
name: license-header
5550
entry: leeway run components:update-license-header

.werft/build.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { validateChanges } from "./jobs/build/validate-changes";
99
import { prepare } from "./jobs/build/prepare";
1010
import { deployToPreviewEnvironment } from "./jobs/build/deploy-to-preview-environment";
1111
import { triggerIntegrationTests } from "./jobs/build/trigger-integration-tests";
12-
import { triggerUpgradeTests } from "./jobs/build/self-hosted-upgrade-tests";
12+
import { triggerSelfHostedPreview, triggerUpgradeTests } from "./jobs/build/self-hosted-upgrade-tests";
1313
import { jobConfig } from "./jobs/build/job-config";
1414
import { typecheckWerftJobs } from "./jobs/build/typecheck-werft-jobs";
1515

@@ -60,6 +60,11 @@ async function run(context: any) {
6060
await typecheckWerftJobs(werft);
6161
await buildAndPublish(werft, config);
6262

63+
if (config.withSelfHostedPreview) {
64+
await triggerSelfHostedPreview(werft, config, context.Owner);
65+
return
66+
}
67+
6368
if (!config.withPreview || config.publishRelease) {
6469
werft.phase("deploy", "not deploying");
6570
console.log("running without preview environment or publish-release is set");

.werft/installer-tests.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as https from "https";
33
import { join } from "path";
44
import { exec } from "./util/shell";
55
import { Werft } from "./util/werft";
6+
import { deleteReplicatedLicense } from "./jobs/build/self-hosted-upgrade-tests";
67

78
const context: any = JSON.parse(fs.readFileSync("context.json").toString());
89

@@ -476,6 +477,8 @@ function cleanup() {
476477

477478
werft.done(phase.phase);
478479

480+
deleteReplicatedLicense(werft, process.env["TF_VAR_TEST_ID"]);
481+
479482
return ret;
480483
}
481484

.werft/jobs/build/deploy-to-preview-environment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ export async function deployToPreviewEnvironment(werft: Werft, jobConfig: JobCon
212212
previewName: previewNameFromBranchName(jobConfig.repository.branch),
213213
stackdriverServiceAccount: STACKDRIVER_SERVICEACCOUNT,
214214
werft: werft,
215-
installationMethod: jobConfig.observability.installationMethod,
216215
});
217216
const sliceID = "observability";
218217
monitoringSatelliteInstaller

.werft/jobs/build/installer/installer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ EOF`);
167167

168168
private configureIDE(slice: string) {
169169
exec(`yq w -i ${this.options.installerConfigPath} experimental.ide.resolveLatest false`, { slice });
170+
exec(`yq w -i ${this.options.installerConfigPath} experimental.ide.ideMetrics.enabledErrorReporting true`, { slice });
170171
}
171172

172173
private configureObservability(slice: string) {

.werft/jobs/build/job-config.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface JobConfig {
66
analytics: string;
77
buildConfig: any;
88
cleanSlateDeployment: boolean;
9+
cluster: string;
910
coverageOutput: string;
1011
dontTest: boolean;
1112
fromVersion: string;
@@ -24,6 +25,7 @@ export interface JobConfig {
2425
withContrib: boolean;
2526
withIntegrationTests: boolean;
2627
withUpgradeTests: boolean;
28+
withSelfHostedPreview: boolean;
2729
withObservability: boolean;
2830
withPayment: boolean;
2931
workspaceFeatureFlags: string[];
@@ -45,13 +47,9 @@ export interface Repository {
4547
branch: string;
4648
}
4749

48-
export type ObservabilityInstallationMethod = "jsonnet" | "observability-installer";
49-
5050
export interface Observability {
5151
// The branch of gitpod-io/observability to use
5252
branch: string;
53-
// What tool to use to install monitoring-satellite from gitpod-io/observability
54-
installationMethod: ObservabilityInstallationMethod;
5553
}
5654

5755
export function jobConfig(werft: Werft, context: any): JobConfig {
@@ -83,10 +81,12 @@ export function jobConfig(werft: Werft, context: any): JobConfig {
8381
const withIntegrationTests = "with-integration-tests" in buildConfig && !mainBuild;
8482
const withUpgradeTests = "with-upgrade-tests" in buildConfig && !mainBuild;
8583
const fromVersion = withUpgradeTests ? buildConfig["from-version"] : "";
86-
const replicatedChannel = withUpgradeTests ? buildConfig["channel"] : "";
84+
const replicatedChannel = buildConfig["channel"];
85+
const cluster = buildConfig["cluster"];
86+
const withSelfHostedPreview = "with-sh-preview" in buildConfig;
8787
const publishToNpm = "publish-to-npm" in buildConfig || mainBuild;
8888
const publishToJBMarketplace = "publish-to-jb-marketplace" in buildConfig || mainBuild;
89-
const publishToKots = "publish-to-kots" in buildConfig || mainBuild;
89+
const publishToKots = "publish-to-kots" in buildConfig || withSelfHostedPreview || mainBuild;
9090
const analytics = buildConfig["analytics"];
9191
const localAppVersion = mainBuild || "with-localapp-version" in buildConfig ? version : "unknown";
9292
const retag = "with-retag" in buildConfig ? "" : "--dont-retag";
@@ -115,13 +115,13 @@ export function jobConfig(werft: Werft, context: any): JobConfig {
115115

116116
const observability: Observability = {
117117
branch: context.Annotations.withObservabilityBranch || "main",
118-
installationMethod: context.Annotations.observabilityInstallationMethod || "jsonnet",
119118
};
120119

121120
const jobConfig = {
122121
analytics,
123122
buildConfig,
124123
cleanSlateDeployment,
124+
cluster,
125125
coverageOutput,
126126
dontTest,
127127
fromVersion,
@@ -145,6 +145,7 @@ export function jobConfig(werft: Werft, context: any): JobConfig {
145145
withObservability,
146146
withPayment,
147147
withUpgradeTests,
148+
withSelfHostedPreview,
148149
workspaceFeatureFlags,
149150
withLargeVM,
150151
};

.werft/jobs/build/self-hosted-upgrade-tests.ts

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ import { Werft } from "../../util/werft";
33
import { JobConfig } from "./job-config";
44

55
interface config {
6+
cloud: string,
67
phase: string;
78
description: string;
89
}
910

1011
const phases: { [name: string]: config } = {
1112
gke: {
13+
cloud: "gcp",
1214
phase: "trigger upgrade test in GKE",
1315
description: "Triggers upgrade test on supplied version from Beta channel on GKE cluster",
1416
},
1517
aks: {
18+
cloud: "azure",
1619
phase: "trigger upgrade test in AKS",
1720
description: "Triggers upgrade test on supplied version from Beta channel on AKS cluster",
1821
},
1922
k3s: {
23+
cloud: "k3s",
2024
phase: "trigger upgrade test in K3S",
2125
description: "Triggers upgrade test on supplied version from Beta channel on K3S cluster",
2226
},
2327
eks: {
28+
cloud: "aws",
2429
phase: "trigger upgrade test in EKS",
2530
description: "Triggers upgrade test on supplied version from Beta channel on EKS cluster",
2631
},
@@ -67,3 +72,110 @@ export async function triggerUpgradeTests(werft: Werft, config: JobConfig, usern
6772
}
6873
}
6974
}
75+
76+
export async function triggerSelfHostedPreview(werft: Werft, config: JobConfig, username: string) {
77+
const replicatedChannel = config.replicatedChannel || config.repository.branch;
78+
const cluster = config.cluster || "k3s";
79+
const formattedBranch = config.repository.branch.replace("/", "-").slice(0,10)
80+
const phase = phases[cluster]
81+
const subdomain = `${formattedBranch}x-${phase.cloud}`
82+
83+
const replicatedApp = process.env.REPLICATED_APP
84+
85+
var licenseFlag: string = ""
86+
var annotation: string = ""
87+
88+
89+
if(!["stable", "unstable", "beta"].includes(replicatedChannel.toLowerCase())){
90+
werft.phase("get-replicated-license", `Create and download replicated license for ${replicatedChannel}`);
91+
92+
const customerID = getCustomerID(subdomain)
93+
94+
if(customerID == "") {
95+
exec(`replicated customer create --app ${replicatedApp} --channel ${replicatedChannel} --name ${subdomain}`,
96+
{ slice: "get-replicated-license"})
97+
}
98+
99+
exec(`replicated customer download-license --app ${replicatedApp} --customer ${subdomain} > license.yaml`,
100+
{ slice: "get-replicated-license", dontCheckRc: true})
101+
102+
exec(`install -D license.yaml install/licenses/${replicatedChannel}.yaml`,
103+
{ slice: "get-replicated-license"},
104+
)
105+
werft.done("get-replicated-license");
106+
107+
licenseFlag = `-s install/licenses/${replicatedChannel}.yaml`
108+
}
109+
110+
exec(`git config --global user.name "${username}"`);
111+
112+
annotation = `${annotation} -a channel=${replicatedChannel} -a preview=true -a skipTests=true -a deps=external`;
113+
114+
werft.phase("self-hosted-preview", `Create self-hosted preview in ${cluster}`);
115+
116+
annotation = `${annotation} -a cluster=${cluster} -a updateGitHubStatus=gitpod-io/gitpod -a subdomain=${subdomain}`
117+
118+
const testFile: string = `.werft/${cluster}-installer-tests.yaml`;
119+
120+
try {
121+
exec(
122+
`werft run --remote-job-path ${testFile} ${annotation} github ${licenseFlag}`,
123+
{
124+
slice: "self-hosted-preview"
125+
},
126+
).trim();
127+
128+
werft.done("self-hosted-preview");
129+
} catch (err) {
130+
if (!config.mainBuild) {
131+
werft.fail("self-hosted-preview", err);
132+
}
133+
console.log("Deleting the created license ", subdomain)
134+
deleteReplicatedLicense(werft, subdomain)
135+
exec("exit 0");
136+
}
137+
}
138+
139+
export async function deleteReplicatedLicense(werft: Werft, licenseName: string) {
140+
var customerID: string
141+
142+
if(licenseName == "") {
143+
console.log("No customerID or license name found, skipping replicated license cleanup")
144+
return
145+
}
146+
147+
customerID = getCustomerID(licenseName)
148+
149+
if(customerID == "") {
150+
console.log("Could not find license, skipping replicated license cleanup")
151+
return
152+
}
153+
154+
console.log("trying to cleanup replicated license")
155+
werft.phase("delete-replicated-license", "Deletes the replicated license created")
156+
const ret = exec(`curl --request POST \
157+
--url https://api.replicated.com/vendor/v3/customer/${customerID}/archive \
158+
--header 'Authorization: ${ process.env.REPLICATED_API_TOKEN }'`,
159+
{slice: "delete-replicated-license", dontCheckRc: true})
160+
if(ret.code){
161+
werft.fail("delete-replicated-license", "Could not delete the replciated license")
162+
return
163+
}
164+
165+
werft.done("delete-replicated-license")
166+
}
167+
168+
function getCustomerID(licenseName: string): string {
169+
var customerID: string = ""
170+
const replicatedApp = process.env.REPLICATED_APP
171+
172+
const response = exec(`replicated customer ls --app ${replicatedApp} | grep ${licenseName} | awk '{print $1}'`,
173+
{ slice: "get-replicated-license", dontCheckRc: true})
174+
175+
const customerIDS = response.stdout.split("\n").filter(item => item);
176+
if(customerIDS.length > 0) {
177+
customerID = customerIDS[0].trim()
178+
}
179+
180+
return customerID
181+
}

0 commit comments

Comments
 (0)