mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:51:57 +00:00
refactor: Move Sentry source maps upload to Docker build step (#39381)
This commit is contained in:
parent
b5d0fe5078
commit
47eea306c9
@ -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
|
||||
|
||||
@ -3,5 +3,5 @@
|
||||
*/
|
||||
window.buildInfo = {
|
||||
commitSHA: process.env.COMMIT_SHA,
|
||||
version: process.env.RELEASE_CANDIDATE_VERSION,
|
||||
version: process.env.VERSION,
|
||||
}
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user