-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[installer] Add upgrade test werft flag
- Loading branch information
1 parent
b1a3665
commit ed97560
Showing
12 changed files
with
341 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,81 @@ | ||
import * as fs from 'fs'; | ||
import { SpanStatusCode } from '@opentelemetry/api'; | ||
import { Werft } from './util/werft'; | ||
import { reportBuildFailureInSlack } from './util/slack'; | ||
import * as Tracing from './observability/tracing' | ||
import * as VM from './vm/vm' | ||
import { buildAndPublish } from './jobs/build/build-and-publish'; | ||
import { validateChanges } from './jobs/build/validate-changes'; | ||
import { prepare } from './jobs/build/prepare'; | ||
import { deployToPreviewEnvironment } from './jobs/build/deploy-to-preview-environment'; | ||
import { triggerIntegrationTests } from './jobs/build/trigger-integration-tests'; | ||
import { jobConfig } from './jobs/build/job-config'; | ||
import { typecheckWerftJobs } from './jobs/build/typecheck-werft-jobs'; | ||
import * as fs from "fs"; | ||
import { SpanStatusCode } from "@opentelemetry/api"; | ||
import { Werft } from "./util/werft"; | ||
import { reportBuildFailureInSlack } from "./util/slack"; | ||
import * as Tracing from "./observability/tracing"; | ||
import * as VM from "./vm/vm"; | ||
import { buildAndPublish } from "./jobs/build/build-and-publish"; | ||
import { validateChanges } from "./jobs/build/validate-changes"; | ||
import { prepare } from "./jobs/build/prepare"; | ||
import { deployToPreviewEnvironment } from "./jobs/build/deploy-to-preview-environment"; | ||
import { triggerIntegrationTests } from "./jobs/build/trigger-integration-tests"; | ||
import { triggerUpgradeTests } from "./jobs/build/self-hosted-upgrade-tests"; | ||
import { jobConfig } from "./jobs/build/job-config"; | ||
import { typecheckWerftJobs } from "./jobs/build/typecheck-werft-jobs"; | ||
|
||
// Will be set once tracing has been initialized | ||
let werft: Werft | ||
const context: any = JSON.parse(fs.readFileSync('context.json').toString()); | ||
let werft: Werft; | ||
const context: any = JSON.parse(fs.readFileSync("context.json").toString()); | ||
|
||
Tracing.initialize() | ||
.then(() => { | ||
werft = new Werft("build") | ||
werft = new Werft("build"); | ||
}) | ||
.then(() => run(context)) | ||
.catch((err) => { | ||
werft.rootSpan.setStatus({ | ||
code: SpanStatusCode.ERROR, | ||
message: err | ||
}) | ||
message: err, | ||
}); | ||
|
||
console.log('Error', err) | ||
console.log("Error", err); | ||
|
||
if (context.Repository.ref === "refs/heads/main") { | ||
reportBuildFailureInSlack(context, err).catch((error: Error) => { | ||
console.error("Failed to send message to Slack", error) | ||
console.error("Failed to send message to Slack", error); | ||
}); | ||
} | ||
|
||
// Explicitly not using process.exit as we need to flush tracing, see tracing.js | ||
process.exitCode = 1 | ||
process.exitCode = 1; | ||
}) | ||
.finally(() => { | ||
werft.phase("Stop kubectl port forwards", "Stopping kubectl port forwards") | ||
VM.stopKubectlPortForwards() | ||
werft.phase("Stop kubectl port forwards", "Stopping kubectl port forwards"); | ||
VM.stopKubectlPortForwards(); | ||
|
||
werft.phase("Flushing telemetry", "Flushing telemetry before stopping job") | ||
werft.endAllSpans() | ||
}) | ||
werft.phase("Flushing telemetry", "Flushing telemetry before stopping job"); | ||
werft.endAllSpans(); | ||
}); | ||
|
||
async function run(context: any) { | ||
const config = jobConfig(werft, context) | ||
const config = jobConfig(werft, context); | ||
|
||
await validateChanges(werft, config) | ||
await prepare(werft, config) | ||
await typecheckWerftJobs(werft) | ||
await buildAndPublish(werft, config) | ||
await validateChanges(werft, config); | ||
await prepare(werft, config); | ||
if (config.withUpgradeTests) { | ||
// this will trigger an upgrade test on a self-hosted gitpod instance on a new cluster. | ||
await triggerUpgradeTests(werft, config, context.Owner); | ||
return; | ||
} | ||
await typecheckWerftJobs(werft); | ||
await buildAndPublish(werft, config); | ||
|
||
if (config.noPreview) { | ||
werft.phase("deploy", "not deploying"); | ||
console.log("no-preview or publish-release is set"); | ||
return | ||
return; | ||
} | ||
|
||
try { | ||
await deployToPreviewEnvironment(werft, config) | ||
await deployToPreviewEnvironment(werft, config); | ||
} catch (e) { | ||
// We currently don't support concurrent deployments to the same preview environment. | ||
// Until we do we don't want errors to mark the main build as failed. | ||
if (config.mainBuild) { | ||
return | ||
return; | ||
} | ||
throw e | ||
throw e; | ||
} | ||
|
||
await triggerIntegrationTests(werft, config, context.Owner) | ||
await triggerIntegrationTests(werft, config, context.Owner); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.