diff --git a/client/web/dev/utils/environment-config.ts b/client/web/dev/utils/environment-config.ts index 97cc8b325e3..9bfdc797665 100644 --- a/client/web/dev/utils/environment-config.ts +++ b/client/web/dev/utils/environment-config.ts @@ -38,8 +38,8 @@ export const ENVIRONMENT_CONFIG = { // The commit SHA the client bundle was built with. COMMIT_SHA: process.env.COMMIT_SHA, - // New release candidate version. - RELEASE_CANDIDATE_VERSION: process.env.RELEASE_CANDIDATE_VERSION, + // The current Docker image version, use to associate builds with Sentry's source maps. + VERSION: process.env.VERSION, // Should sourcemaps be uploaded to Sentry. SENTRY_UPLOAD_SOURCE_MAPS: getEnvironmentBoolean('SENTRY_UPLOAD_SOURCE_MAPS'), // Sentry's Dotcom project's authentication token diff --git a/client/web/src/initBuildInfo.ts b/client/web/src/initBuildInfo.ts index 3e75e5ddf24..ee576a6643a 100644 --- a/client/web/src/initBuildInfo.ts +++ b/client/web/src/initBuildInfo.ts @@ -3,5 +3,5 @@ */ window.buildInfo = { commitSHA: process.env.COMMIT_SHA, - version: process.env.RELEASE_CANDIDATE_VERSION, + version: process.env.VERSION, } diff --git a/client/web/webpack.config.js b/client/web/webpack.config.js index 306e53c8788..63b4b13cb3c 100644 --- a/client/web/webpack.config.js +++ b/client/web/webpack.config.js @@ -45,7 +45,7 @@ const { WEBPACK_USE_NAMED_CHUNKS, SENTRY_UPLOAD_SOURCE_MAPS, COMMIT_SHA, - RELEASE_CANDIDATE_VERSION, + VERSION, SENTRY_DOT_COM_AUTH_TOKEN, SENTRY_ORGANIZATION, SENTRY_PROJECT, @@ -60,7 +60,6 @@ const RUNTIME_ENV_VARIABLES = { ENABLE_OPEN_TELEMETRY, INTEGRATION_TESTS, COMMIT_SHA, - RELEASE_CANDIDATE_VERSION, ...(WEBPACK_SERVE_INDEX && { SOURCEGRAPH_API_URL }), } @@ -188,13 +187,13 @@ const config = { */ threshold: 10240, }), - RELEASE_CANDIDATE_VERSION && + VERSION && SENTRY_UPLOAD_SOURCE_MAPS && new SentryWebpackPlugin({ org: SENTRY_ORGANIZATION, project: SENTRY_PROJECT, authToken: SENTRY_DOT_COM_AUTH_TOKEN, - release: `frontend@${RELEASE_CANDIDATE_VERSION}`, + release: `frontend@${VERSION}`, include: path.join(STATIC_ASSETS_PATH, 'scripts'), }), ].filter(Boolean), diff --git a/doc/dev/background-information/ci/reference.md b/doc/dev/background-information/ci/reference.md index d34d563db03..50b0a388b7e 100644 --- a/doc/dev/background-information/ci/reference.md +++ b/doc/dev/background-information/ci/reference.md @@ -142,7 +142,6 @@ Base pipeline (more steps might be included based on branch changes): - **CI script tests**: test-trace-command.sh - **Integration tests**: Backend integration tests, Code Intel QA - **End-to-end tests**: Sourcegraph E2E, Sourcegraph QA, Sourcegraph Cluster (deploy-sourcegraph) QA, Sourcegraph Upgrade -- Build and upload sourcemaps to Sentry - **Publish images**: alpine-3.14, cadvisor, codeinsights-db, codeintel-db, frontend, github-proxy, gitserver, grafana, indexed-searcher, jaeger-agent, jaeger-all-in-one, minio, postgres-12-alpine, postgres_exporter, precise-code-intel-worker, prometheus, redis-cache, redis-store, redis_exporter, repo-updater, search-indexer, searcher, symbols, syntax-highlighter, worker, migrator, executor, opentelemetry-collector, server, sg, Publish executor image, Publish docker registry mirror image - Upload build trace diff --git a/enterprise/dev/ci/internal/ci/operations.go b/enterprise/dev/ci/internal/ci/operations.go index ba9cbc53a65..a9468946d4c 100644 --- a/enterprise/dev/ci/internal/ci/operations.go +++ b/enterprise/dev/ci/internal/ci/operations.go @@ -216,25 +216,6 @@ func addWebApp(pipeline *bk.Pipeline) { bk.Cmd("dev/ci/codecov.sh -c -F typescript -F unit")) } -// Adds steps for building webapp with the Sentry Webpack plugin enabled to upload sourcemaps -// Only builds webapp without ENTERPRISE=1, no tests are performed. Should only run on release branches. -func buildWebAppWithSentrySourcemaps(version string) operations.Operation { - return func(pipeline *bk.Pipeline) { - // Webapp build with Sentry's webpack plugin enabled - pipeline.AddStep(":webpack::globe_with_meridians: Build and upload sourcemaps to Sentry", - withYarnCache(), - bk.SoftFail(), - bk.Cmd("dev/ci/yarn-build.sh client/web"), - bk.Env("NODE_ENV", "production"), - bk.Env("ENTERPRISE", ""), - bk.Env("SENTRY_UPLOAD_SOURCE_MAPS", "1"), - bk.Env("SENTRY_ORGANIZATION", "sourcegraph"), - bk.Env("SENTRY_PROJECT", "sourcegraph-dot-com"), - bk.Env("RELEASE_CANDIDATE_VERSION", version), - ) - } -} - var browsers = []string{"chrome"} func getParallelTestCount(webParallelTestCount int) int { @@ -684,7 +665,7 @@ func candidateImageStepKey(app string) string { // tags once the e2e tests pass. // // Version is the actual version of the code, and -func buildCandidateDockerImage(app, version, tag string) operations.Operation { +func buildCandidateDockerImage(app, version, tag string, uploadSourcemaps bool) operations.Operation { return func(pipeline *bk.Pipeline) { image := strings.ReplaceAll(app, "/", "-") localImage := "sourcegraph/" + image + ":" + version @@ -697,6 +678,16 @@ func buildCandidateDockerImage(app, version, tag string) operations.Operation { bk.Env("VERSION", version), } + // Add Sentry environment variables if we are building off main branch + // to enable building the webapp with source maps enabled + if uploadSourcemaps { + cmds = append(cmds, + bk.Env("SENTRY_UPLOAD_SOURCE_MAPS", "1"), + bk.Env("SENTRY_ORGANIZATION", "sourcegraph"), + bk.Env("SENTRY_PROJECT", "sourcegraph-dot-com"), + ) + } + // Allow all build scripts to emit info annotations buildAnnotationOptions := bk.AnnotatedCmdOpts{ Annotations: &bk.AnnotationOpts{ diff --git a/enterprise/dev/ci/internal/ci/pipeline.go b/enterprise/dev/ci/internal/ci/pipeline.go index 5cafdd6a3c8..e9aaecb849f 100644 --- a/enterprise/dev/ci/internal/ci/pipeline.go +++ b/enterprise/dev/ci/internal/ci/pipeline.go @@ -120,7 +120,7 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { testBuilds := operations.NewNamedSet("Test builds") scanBuilds := operations.NewNamedSet("Scan test builds") for _, image := range images.SourcegraphDockerImages { - testBuilds.Append(buildCandidateDockerImage(image, c.Version, c.candidateImageTag())) + testBuilds.Append(buildCandidateDockerImage(image, c.Version, c.candidateImageTag(), false)) scanBuilds.Append(trivyScanCandidateImage(image, c.candidateImageTag())) } ops.Merge(testBuilds) @@ -132,7 +132,7 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { case runtype.BackendIntegrationTests: ops.Append( - buildCandidateDockerImage("server", c.Version, c.candidateImageTag()), + buildCandidateDockerImage("server", c.Version, c.candidateImageTag(), false), backendIntegrationTests(c.candidateImageTag())) // always include very backend-oriented changes in this set of tests @@ -190,7 +190,7 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { } ops = operations.NewSet( - buildCandidateDockerImage(patchImage, c.Version, c.candidateImageTag()), + buildCandidateDockerImage(patchImage, c.Version, c.candidateImageTag(), false), trivyScanCandidateImage(patchImage, c.candidateImageTag())) // Test images ops.Merge(CoreTestOperations(changed.All, CoreTestOperationsOptions{ @@ -211,14 +211,14 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { panic(fmt.Sprintf("no image %q found", patchImage)) } ops = operations.NewSet( - buildCandidateDockerImage(patchImage, c.Version, c.candidateImageTag()), + buildCandidateDockerImage(patchImage, c.Version, c.candidateImageTag(), false), wait, publishFinalDockerImage(c, patchImage)) case runtype.CandidatesNoTest: for _, dockerImage := range images.SourcegraphDockerImages { ops.Append( - buildCandidateDockerImage(dockerImage, c.Version, c.candidateImageTag())) + buildCandidateDockerImage(dockerImage, c.Version, c.candidateImageTag(), false)) } case runtype.ExecutorPatchNoTest: @@ -237,7 +237,12 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { // Slow image builds imageBuildOps := operations.NewNamedSet("Image builds") for _, dockerImage := range images.SourcegraphDockerImages { - imageBuildOps.Append(buildCandidateDockerImage(dockerImage, c.Version, c.candidateImageTag())) + // Only upload sourcemaps for the "frontend" image, on the Main branch build + uploadSourcemaps := false + if c.RunType.Is(runtype.MainBranch) && dockerImage == "frontend" { + uploadSourcemaps = true + } + imageBuildOps.Append(buildCandidateDockerImage(dockerImage, c.Version, c.candidateImageTag(), uploadSourcemaps)) } // Executor VM image skipHashCompare := c.MessageFlags.SkipHashCompare || c.RunType.Is(runtype.ReleaseBranch) @@ -290,9 +295,6 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { if c.RunType.Is(runtype.ReleaseBranch) || c.Diff.Has(changed.ExecutorDockerRegistryMirror) { publishOps.Append(publishExecutorDockerMirror(c.Version)) } - if c.RunType.Is(runtype.ReleaseBranch) { - ops.Append(buildWebAppWithSentrySourcemaps(c.Version)) - } } ops.Merge(publishOps) }