Code AI platform with Code Search & Cody
Go to file
Jean-Hadrien Chabran 2dfeb486d5
fix(local): fix race in sg_start_test.go (#63642)
Fixes DINF-82; This was very much a rabbithole. A few things: 

- The race that @bobheadxi mentioned here
https://github.com/sourcegraph/sourcegraph/pull/63405#discussion_r1648180713
wasn't from `*output.Output` being unsafe, but `outputtest.Buffer` as it
happened again (see
[DINF-82](https://linear.app/sourcegraph/issue/DINF-82/devsgsg-test-failed-with-a-detected-race-condition))
- There something messed up with `cmds.start()`, which sometimes ends up
printing the command output _after_ the exit message instead of before.
- The crude `sort.Strings(want|have)` that was there already fixes that.
- And without the sleep, it's possible to read the output from the
`outputtest.Buffer` before the command outputs get written to it.
- The `time.Sleep(300 * time.Milliseconds)` _mitigates/hides_ that
problem.

At least, this shouldn't blow up in CI and buys us time to fix the whole
thing. We're tracking this in DINF-104. And out of 200 runs, I also
stumbled on a race in `progress_tty`, tracked in DINF-105 (that packages
is originally meant to be used by `src-cli` and was re-used for `sg` 3
years ago).

I'm pretty unhappy about the solution, but a bandage is better than
nothing. While ideally, we should really reconsider dropping
`std.Output` entirely in `sg` and use the good stuff from
github.com/charmbracelet instead because we don't want to spend too much
time on arcane terminal things ourselves, I'm much more about concerned
the concurrency issues mentioned above.

## Test plan

CI + `sg bazel test //dev/sg:sg_test --runs_per_test=100`
2024-07-04 19:11:10 +02:00
.apko Build images end-to-end using Bazel v2 (#61845) 2024-04-12 16:18:43 +01:00
.aspect update config for workflows 5.10 (#63554) 2024-07-01 14:35:41 +02:00
.buildkite chore(ci): remove Percy visual tests (#63515) 2024-06-27 16:20:06 +02:00
.github fix(actions): update pinned SHA for pnpm/action-setup action (#63632) 2024-07-04 01:49:10 -05:00
.vscode Implement UI for Github Apps <> Batch Changes integration (#63597) 2024-07-02 08:56:17 -05:00
client fix(batches): display failure alert depending on github app kind (#63633) 2024-07-04 04:15:26 -05:00
cmd Fix the scheduling interval for syntactic indexing (#63634) 2024-07-04 10:42:00 +01:00
dev fix(local): fix race in sg_start_test.go (#63642) 2024-07-04 19:11:10 +02:00
doc chore(ci): remove Percy visual tests (#63515) 2024-06-27 16:20:06 +02:00
docker-images scip-syntax: implements parallel processing for workspace and tar commands (#63536) 2024-07-01 11:48:55 +02:00
internal release/appliance: resource def grafana (#63535) 2024-07-04 09:46:05 -07:00
lib fix(local): fix race in sg_start_test.go (#63642) 2024-07-04 19:11:10 +02:00
migrations insights: persist patternType in db (#63579) 2024-07-03 09:51:48 +02:00
monitoring dotcom: Remove on-demand cloning of repositories (#63321) 2024-06-26 14:53:14 -07:00
schema Add a better Cody client server-sent configuration mechanism (#63591) 2024-07-03 22:57:31 +00:00
testing feat/bazel: //cmd/{frontend,server} targets that don't include client bundle for backend integration tests (#62877) 2024-05-28 14:32:48 +01:00
third_party enterprise-portal: implement basic MSP IAM and RPCs (#63173) 2024-06-19 21:46:48 -04:00
third-party-licenses chore(ci): remove Percy visual tests (#63515) 2024-06-27 16:20:06 +02:00
tools Chore(release): Calendar Updates (#63583) 2024-07-02 10:42:12 -04:00
ui/assets feat/bazel: //cmd/{frontend,server} targets that don't include client bundle for backend integration tests (#62877) 2024-05-28 14:32:48 +01:00
wolfi-images security: Auto-update package lockfiles for Sourcegraph base images (#63145) 2024-07-02 17:07:34 +01:00
wolfi-packages s3proxy: Fix permissions on s3proxy package binary (#62907) 2024-05-24 15:55:00 +00:00
.bazel_fix_commands.json SG Start Bazel Improvements Take 2 (#60687) 2024-03-05 01:44:21 -08:00
.bazelignore chore(bazel): add client/backstage-frontend to bazelignore (#63471) 2024-06-25 14:36:03 +00:00
.bazeliskrc chore: upgrade to Aspect CLI 5.8.19 (#59203) 2024-01-02 15:13:24 +01:00
.bazelrc feat(ci): Adds playwright tests for sveltekit to bazel (#62560) 2024-06-06 12:45:05 -06:00
.bazelversion chore(bazel): bump to 7.2.0 (#63226) 2024-06-12 13:25:18 +00:00
.dockerignore use esbuild for client/web builds (#57365) 2023-10-23 10:59:06 -07:00
.editorconfig proto: Add editorconfig to ident using two spaces (#57281) 2023-10-03 00:39:42 +00:00
.eslintrc.js looser eslint rules (#63511) 2024-06-27 08:42:51 +00:00
.gitattributes dev/linearhooks: add POC (#62367) 2024-05-07 00:14:05 -07:00
.gitignore chore(ci): emit compact executon log in CI (#63420) 2024-06-21 19:50:35 +01:00
.graphqlrc.yml
.hadolint.yaml bump comby version to 1.7.1 (#35830) 2022-05-20 20:12:01 -07:00
.mailmap mailmap: add entries for Eric and Renovate (#50966) 2023-04-25 09:42:22 +02:00
.mocharc.js reapply "switch from jest to vitest for faster, simpler tests (#57886)" (#58145) 2023-11-07 12:00:18 +02:00
.npmrc pnpm: remove update notifier message (#51630) 2023-05-10 08:53:39 +02:00
.pre-commit-config.yaml chore(local): add FORBIDCOMMIT pragma to prevent accidental commits (#63581) 2024-07-01 18:27:26 +00:00
.prettierignore feat/release: appliance setup workflow and ui (#63291) 2024-06-19 16:21:13 +01:00
.stylelintignore rework plugin structure and implement frontside blogpost (#46883) 2023-02-15 11:49:51 +02:00
.stylelintrc.json web: drop bootstrap depenedency (#41401) 2022-09-07 03:11:26 -07:00
.swcrc use swc instead of babel for faster bazel typescript transpilation (#57912) 2023-11-02 22:49:03 -07:00
.tool-versions chore(tooling): bump Go version to 1.22.4 (#63124) 2024-06-06 15:19:03 +00:00
.trivyignore
BUILD.bazel feat/bazel: //cmd/{frontend,server} targets that don't include client bundle for backend integration tests (#62877) 2024-05-28 14:32:48 +01:00
CHANGELOG.md search: remove "lucky" from default pattern types (#63486) 2024-06-27 16:27:17 +02:00
CODENOTIFY nix: update pnpm hash (#51512) 2023-05-05 12:51:59 +00:00
CONTRIBUTING.md fix: update links for dev docs (#62758) 2024-05-17 13:47:34 +02:00
deps.bzl feat(appliance): admin password gates most pages (#63523) 2024-07-01 21:56:23 +00:00
doc.go
eslint-relative-formatter.js bazel: implement custom ESLint Bazel rule (#52062) 2023-05-22 04:05:45 -07:00
flake.lock nix: bump to bazel 7.1 (#61326) 2024-03-22 16:57:50 +00:00
flake.nix nix: use go1.22.4 (#63372) 2024-06-20 11:12:17 +02:00
gen.go chore: fixup go-mockgen run statement (#61028) 2024-03-12 13:06:36 +00:00
go.mod feat(appliance): admin password gates most pages (#63523) 2024-07-01 21:56:23 +00:00
go.sum feat(appliance): admin password gates most pages (#63523) 2024-07-01 21:56:23 +00:00
graphql-schema-linter.config.js
LICENSE relicense all paths other than MIT licensed code, client/cody*, jetbrains, VS code, and browser extension to enterprise (#53345) (#53345) 2023-06-13 10:28:11 -07:00
LICENSE.enterprise Update Enterprise license copyright notice (#62467) 2024-05-06 17:35:32 +00:00
linter_deps.bzl chore: Remove redundant loop captures (#62264) 2024-04-30 07:57:21 -06:00
mockgen.temp.yaml dotcom: Remove on-demand cloning of repositories (#63321) 2024-06-26 14:53:14 -07:00
mockgen.test.yaml dotcom: Remove on-demand cloning of repositories (#63321) 2024-06-26 14:53:14 -07:00
mockgen.yaml bazel: native go-mockgen in Bazel (#60386) 2024-02-16 13:26:48 +00:00
nogo_config.json chore: Remove redundant loop captures (#62264) 2024-04-30 07:57:21 -06:00
package.json Bump cody-web-experimental package version (#63525) 2024-06-27 14:56:46 -03:00
pnpm-lock.yaml Add v2 telemetry infrastructure to browser extensions and native inte… (#63458) 2024-07-03 16:47:37 -07:00
pnpm-workspace.yaml Create a shared Cody Ignore dataset (#61968) 2024-05-09 13:18:35 +00:00
postcss.config.js
prettier.config.js clean up Cody CSS to increase shareability and improve display in web app (#50279) 2023-04-03 12:29:05 -07:00
README.md chore: remove broken link in README (#63256) 2024-06-13 22:22:56 +00:00
release.yaml feat(ci): Trigger security scanner from release pipeline (#63280) 2024-06-19 19:16:36 +00:00
renovate.json chore(ci): disable renovate (#63313) 2024-06-19 13:17:15 +02:00
SECURITY.md
service-catalog.yaml lib/servicecatalog: init to distribute catalog (#46999) 2023-01-26 17:22:27 -08:00
sg.config.yaml fix/enterpriseportal: forcibly run gorm-incompatible migration in local dev (#63549) 2024-06-28 10:10:39 -07:00
shell.nix bazel: use pgutil binaries from GCS instead of from the host (#61741) 2024-04-11 18:00:21 +01:00
stamp_tags.bzl Switch to OCI/Wolfi based image (#52693) 2023-06-02 12:12:52 +02:00
tsconfig.base.json web: fix pnpm-lock issue (#47478) 2023-02-09 22:04:31 -08:00
tsconfig.json release: drop legacy release tooling (#61220) 2024-04-09 14:29:35 -05:00
vitest.shared.ts remove Cody "upsells"—and all Cody links if Cody is disabled (#63430) 2024-06-27 05:29:54 +00:00
vitest.workspace.ts vitest: Fix workspace config wrt client/web/ (#58397) 2023-11-17 08:22:46 +00:00
WORKSPACE chore(bazel): bump rules_js to address permissions denied warning (#63419) 2024-06-21 19:31:53 +02:00

DocsContributingTwitterDiscord

Build status Scorecard Latest release Discord Contributors


Sourcegraph makes it easy to read, write, and fix code—even in big, complex codebases.

  • Code search: Search all of your repositories across all branches and all code hosts.
  • Code intelligence: Navigate code, find references, see code owners, trace history, and more.
  • Fix and refactor: Roll out large-scale changes to many repositories at once and track big migrations.

Getting started



Development

Refer to the Developing Sourcegraph guide to get started.

Documentation

The doc directory has additional documentation for developing and understanding Sourcegraph:

License

This repository contains primarily non-OSS-licensed files. See LICENSE.

Copyright (c) 2018-present Sourcegraph Inc.