Commit Graph

33511 Commits

Author SHA1 Message Date
Quinn Slack
07f29c98d6
use @typescript-eslint projectService for faster eslint (#57851)
See https://github.com/typescript-eslint/typescript-eslint/pull/6754.

Also removes needless `.eslintrc.js` files (now that we can use the root `tsconfig.all.json` for linting and it's still fast enough).

Some of our eslint rules were unintentionally made ineffective in `client/web`, and this commit also re-enables them and in some cases suppresses the eslint warning where a fix is not urgent.
2023-10-24 01:40:40 +00:00
Quinn Slack
131ad5019f
upgrade @sourcegraph/eslint-config and fix all auto-fixable issues (#57847)
Also configures to `warn` for some rules that require manual code fixes and that are not urgent.
2023-10-24 00:52:12 +00:00
Erik Seliger
642611bbfb
Skip more perforce tests that regularly time out (#57846)
Those add a lot of additional run time to CI, so disabling them temporarily.

cc @pjlast
2023-10-23 15:09:10 -07:00
Warren Gifford
3af3564504
grammer bazel/index.md (#57838) 2023-10-23 22:05:18 +00:00
Alex Isken
244f961446
Update dotcom footer links (#57810)
Update the dotcom footer links
2023-10-23 17:01:44 -05:00
Will Dollman
20d749b1b6
access tokens: Improve identification of dev instances (#57795)
* Improve testing for dev instances

S2 sets the `dev` tag, so checking UserCount helps confirm when a dev license is used

* Use current license public key to identify dev instances

* Add comment to publicKeyData

* Update comparison

* Tweak comment
2023-10-23 22:41:20 +01:00
Quinn Slack
f160c5c041
explicitly import @jest/globals and mocha (#57786)
Previously bindings like `expect`, `describe`, `afterAll`, etc., were imported implicitly by Jest or Mocha. We should import them explicitly to reduce magic. (Also this makes it easier to migrate to another test runner in the future if we want.)
2023-10-23 21:40:17 +00:00
Quinn Slack
59c82bcfb1
disable frontend code coverage tracking (#57820)
Our tracking of frontend (TypeScript) code coverage has decayed and was no longer being used. The Codecov report at https://app.codecov.io/gh/sourcegraph/sourcegraph significantly under-counts coverage, and what coverage tasks we did have were flaky in CI and relied on old libraries that have not been updated recently to keep with modern practices (such as `@storybook/addon-storyshots` only supporting Jest with `injectGlobals`).

From https://sourcegraph.slack.com/archives/C04MYFW01NV/p1698059032863009?thread_ts=1698054092.709309&cid=C04MYFW01NV, the proposal is to remove coverage tracking for now and prioritize getting tests to run really fast and smooth locally first, including upgrading our testing infra, and then reenable code coverage tracking.
2023-10-23 21:29:40 +00:00
Erik Seliger
d8da82f5c1
Fully disable sub repo perms test (#57836)
This still causes delays of up to 45s without adding any value, so let's skip it entirely until we fix it.
2023-10-23 14:20:08 -07:00
Quinn Slack
c0442a2e9f
disable slow eslint rules, remove unused disable directives (#57788)
* disable slow eslint rules, remove unused disable directives

Disabling these eslint rules makes saving significantly faster. These rules are not worthless, but they are usually ignored anyway, and I can't recall a specific instance when they would have caught a bug. I am proposing we disable them and then set a checkpoint in 14 days to rerun eslint with the rules enabled and see if they would have caught any bad practices. In the meantime, we will all benefit from instant saves (with eslint fixes) instead of waiting 3-5 seconds or more after each save in VS Code, which is destructive to productivity.

* upgrade eslint
2023-10-23 13:23:44 -07:00
Erik Seliger
ababbb9dcf
Add tests to cover GitTree resolver (#57671)
I wanted to look into this resolver because it seemed to cause a lot of load on S2 and dotcom.
Looking at it, I realize that there are zero tests so I didn't even know what's expected to be returned here.
This PR adds a baseline for what should be returned and fixed a bunch of bugs:

- Improper argument validation that could cause panics
- Improperly counted results for `first` argument
- Removed arguments from GraphQL schema that weren't actually respected
- Fix line ending handling in content pagination to return indication if file ended with no newline
- Fix TotalLines for files without a final newline
- Improves performance of line parsing
- Fix ancestors option creating too many results by recursively including all children into the set again (was able to get 90000 entries returned from S2 for a relatively small folder structure)
- Make behavior of recursiveSingleChild match what's documented in GraphQL. Before we would only recurse if the looked at entry is a single child (or first:1 was set)

Ultimately, the dir traversal we do in here should IMO happen in gitserver directly where we already have it in tree structure, but that will have to be for later.
For now, this mostly adds some confidence to these resolvers.
2023-10-23 21:44:25 +02:00
Erik Seliger
cb48b18c0e
gitserver: Reduce instances of EnsureRevision (#57732)
Attempting to understand when we schedule repo updates, I found a lot of places where we didn't explicitly say that we don't need to ensure the revision, but based on assumptions about data above we can safely do so.
2023-10-23 21:40:57 +02:00
Erik Seliger
112c8090b9
Fixup a few code comments (#57676)
Just super simple cleanup
2023-10-23 21:37:46 +02:00
Jean-Hadrien Chabran
5cc0ebefd7
sg: disable docsite from default start target (#57823) 2023-10-23 19:29:40 +00:00
Jason Hawk Harris
50bc4e8494
Code Navigation: remove extra column in gutter (#57816)
remove extra column in gutter
2023-10-23 14:06:05 -05:00
Quinn Slack
de613e92b6
use esbuild for client/web builds (#57365)
Use [esbuild](https://esbuild.github.io/) instead of Webpack for builds of `client/web`, for faster builds (dev and prod) and greater dev-prod parity. This PR completely removes all use of Webpack in this repository.

`client/web` is the last build target that still uses Webpack; all others have been recently migrated to esbuild. Most devs here have been using esbuild for local dev of `client/web` for the last 6-12 months anyway. The change here is that now our production builds will be built by esbuild.

All sg commands, integration/e2e tests, etc., continue to work as-is. The bundlesize report will take a while to stabilize because the new build products use different filenames.

## Benchmarks

Running `pnpm run generate && time pnpm -C client/web run task:gulp webBuild` and taking the `time` output from the last command:

- Webpack: 62.5s
- esbuild: 6.7s

Note: This understates esbuild's victory for 2 reasons: (1) because esbuild is building both the main and embed entrypoints, whereas Webpack only builds the main entrypoint in this benchmark) and (2) because a lot of it is in the fixed startup time of `gulp`; esbuild incremental rebuilds during local dev only take ~1s.

## Notes

We no longer use Babel to produce web builds (we use esbuild), so we don't need any Babel plugins that optimize the output or improve browser compatibility. Right now, Babel is only used by Jest (for tests) and by Bazel as an intermediate step.
2023-10-23 10:59:06 -07:00
William Bezuidenhout
7d4ba7f4c9
ci: let runtype.ManuallyTriggered execute the same build as PR (#57811) 2023-10-23 19:29:42 +02:00
Matt Leathes
49b60e2b2f
Updates to 'Installing Cody in VS Code' (#57036)
Update install-vscode.md

To:
- fix typo 'sugsgestions'
- add missing word 'extension' to 'set up the Cody within your VS Code environment'
- fix indentation

Co-authored-by: Justin Dorfman <justin.dorfman@sourcegraph.com>
2023-10-23 16:27:08 +00:00
Erik Seliger
ccb14e2039
Add changelog entries about removal of GitHub proxy (#57753)
Closes https://github.com/sourcegraph/sourcegraph/issues/55290
2023-10-23 16:15:39 +02:00
Jean-Hadrien Chabran
e8919ada26
bzl: rework how we populate the database schemas for migrator (#57591)
Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-10-23 15:40:09 +02:00
Quinn Slack
dc5fc43d22
fix storybook inferred default export types (#57785)
Fixes `tsc --build` errors of the form:

```
error TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@storybook+types@7.4.6/node_modules/@storybook/types'. This is likely not portable. A type annotation is necessary.
```
2023-10-23 05:12:16 +00:00
Quinn Slack
0452361969
fix storybook types (#57784)
Use StoryFn instead of Story (which is deprecated and unresolvable, causing a type error).
2023-10-22 21:59:45 -07:00
sourcegraph-bot-devx
9a787d9e35
chore: update third-party licenses (#57783)
Co-authored-by: bobheadxi <bobheadxi@users.noreply.github.com>
2023-10-23 06:59:30 +02:00
Varun Gandhi
a599dec3fa
client: Link to glob syntax for tags/branches/repos (#57356) 2023-10-23 01:59:52 +00:00
Quinn Slack
a2e9b12cc9
disable eslint rule etc/no-deprecated for massive file save speedup (#57782)
With this rule enabled, saving a file in VS Code often takes 2-5 seconds or longer. With it disabled, saving a file is usually instant.

This rule is identified as the biggest culprit in slow eslint analysis by running `TIMING=1 pnpm exec eslint --fix client/web/dev/server/development.server.ts`.
2023-10-21 12:37:49 -10:00
Quinn Slack
10d0224bbc
fix passing multiple args to jest --testPathIgnorePatterns (#57780)
To pass multiple ignore patterns to Jest, you need to use `--testPathIgnorePatterns pattern1 --testPathIgnorePatterns pattern2 ...`. Otherwise, `--testPathIgnorePatterns pattern1 pattern2` treats `pattern2` as a test pattern to run, not to ignore.

The consequence of this is that some npm scripts and CI steps were running tests that they didn't need to run.
2023-10-21 21:40:10 +00:00
Quinn Slack
746dd5e863
un-hardcode $DISPLAY for e2e tests to support non-headless local e2e test running (#57781)
This makes it possible to run e2e tests locally on Linux and use the current $DISPLAY for the non-headless browser.
2023-10-21 11:29:35 -10:00
Quinn Slack
4aa1a1df47
add sg test bazel-web-integration (#57779) 2023-10-21 11:29:09 -10:00
Quinn Slack
d83b9eee38
rename “experimental query input” to v2 and remove beta flag (#57590)
The “v1” query input remains the default. But now the code and settings refer to the new (formerly “experimental”) query input as “v2”. If `experimentalFeatures.searchQueryInput` is set to `experimental`, it will behave as though it is set to `v2`.
2023-10-20 20:56:21 -10:00
Vova Kulikov
c8a1011e80
[Repository Pages]: Fix Cody chat sidebar layout (#57772)
* Fix Cody chat sidebar layout

* Fix eslint problems
2023-10-20 15:38:02 -07:00
Keegan Carruthers-Smith
298ec6008c
release: 5.2.2 config and CHANGELOG for 5.2.1 (#57716) 2023-10-20 17:42:47 -04:00
Aditya Kalia
329d3b1fc9
update url redaction logic for cloud vs dotcom (#57384)
* remove redaction from cookie urls

removes redaction from url cookies as we no longer host private code on sourcegraph.com

* Update eventLogger.ts

* Update eventLogger.ts

* Update eventLogger.ts

* Update eventLogger.ts

* expand the logic to all marketing fields

* add additional subdomain regex filtering since isSourcegraphDotComMode is flagged on customer instance's too

* if the site_id is anything other than sourcegraphWeb, have all urls go through redaction

* update tests to test logic between cloud instances and dotcom

* add list of approved hosts where we do not redact from

* sg lint

* update redaction to only happen in one place, send redacted urls to BQ for extra measure and add tests

* sg lint

* add more test cases + re-add URL redaction on cookie side

* bazel fix

* revert referrer logic since referrer is not captured on events_usage

* updated logic to handle referrers on cloud instances + redact session_first_url as a safe measure

* add redaction to sesion_referrer and to originial_referrer to future-proof against ELE

* Migrate URL redaction to backend

refactor: Remove frontend URL redaction
Removed the frontend URL redaction logic in eventLogger.ts for firstSourceURL, lastSourceURL, originalReferrer, sessionReferrer, and sessionFirstURL. This redaction will now be handled in the backend.

Removed calls to redactSensitiveInfoFromAppURL and related cookie logic in eventLogger.ts. URL redaction is now consolidated in the backend.

* Update event_handlers_test.go

Update redaction test for referrer logic. Should only apply to managed instances since we have this clause in the function:

```
	if envvar.SourcegraphDotComMode() {
		return rawURL, nil
	}

* fix ineffectual assignment to err

* remove `redactSensitiveInfoFromAppURL` + update dotComModeVariable

since migrating redaction to backend, can remove this function + update ref to dotComVariable

* the `redactSensitiveInfoFromCloudURL` now only takes the first part of the path and redacts all query parameters except UTM

* undo redaction for referrer values + add comment on redaction

* Apply suggestions from code review

Co-authored-by: Dan Adler <dadlerj@users.noreply.github.com>

* update url path redaction logic and associated tests

* read cookie value only when its confirmed to be dotcom mode (optimization)

---------

Co-authored-by: Dan Adler <dadlerj@users.noreply.github.com>
2023-10-20 12:36:34 -04:00
Erik Seliger
819e8c6fc1
Bump p4-fusion to latest version in gitserver (#57754)
---------

Co-authored-by: ggilmore <geoffrey@sourcegraph.com>
2023-10-20 18:14:42 +02:00
Dan Adler
de3f1cd2ec
Add service type to auth event logs (#57646)
* Add service type tracking to auth related events to identify gaps
2023-10-20 08:42:27 -07:00
Erik Seliger
c4557864e5
Revert "Make sub-repo permissions integration test functional (#57764)" (#57771)
This reverts commit 7f3e4755bd.

It seems to time out.
2023-10-20 14:39:02 +00:00
Erik Seliger
fd13638706
Remove repoRefresh endpoint (#57730)
In an attempt to simplify the set of ways a repo might be scheduled for an update, I found this endpoint and believe it isn't used and that it shouldn't be needed. We have all this in the UI as well, no need to expose a separate HTTP endpoint that doesn't even seem to have admin restrictions.
2023-10-20 16:07:32 +02:00
Erik Seliger
7d8cfe09ef
Remove dead code path that triggered EnqueueRepoUpdate (#57733)
Found that we always pass true here, so no need to keep this code and this perceived dependency on repo-updater.
2023-10-20 16:07:21 +02:00
Erik Seliger
b843deab41
gopackages: Don't keep zip file in memory (#57736)
This aligns what we do for Go with what we do for python, writing a zip file to disk.
This should prevent big memory spikes when large go modules are downloaded.
2023-10-20 16:07:11 +02:00
Erik Seliger
d311834a8f
p4fusion: Use better default values (#57737)
These numbers have proven much more performant in local testing, so I propose that we modify the defaults here.
2023-10-20 16:06:56 +02:00
Petri-Johan Last
7f3e4755bd
Make sub-repo permissions integration test functional (#57764) 2023-10-20 13:27:17 +00:00
Will Dollman
0d1cbc9626
Fork p4-fusion package and update in server + gitserver (#57762)
Combine #57751 and #57756 to fork p4-fusion into a separate package, and update relevant images.

We've forked the tool and are now ready to try some of the fixes out in a more production enviroment, so bundling this temporarily from a specific commit from the fork repo.

Next up, I'll open a PR to use the newly generated base image in bazel and add the new --noBaseCommit flag to the perforce syncer.

---------

Co-authored-by: Erik Seliger <erikseliger@me.com>
2023-10-20 15:23:51 +02:00
Will Dollman
c14cfdfe9f
docs: Document Sourcegraph Secret Formats (#57722)
Document sourcegraph secret formats
2023-10-20 14:05:28 +02:00
Felix Kling
a4ff8b0040
web: Consolidate server and client side feature flag overrides (#57663)
It turned out that we have two different ways of overriding feature
flags:
- `?feat=foo` overrides the feature flag on the server for this request
- `?feature-flag-key=foo&feature-flag-value=true` overrides the feature
  flag on the client side only and persists the setting in local storage

This commit does three things:

1. It consolidates the two systems. `feature-flag-{key,value}` have been
   removed in favor of `feat`. The client side logic will now use the
   same parameter. An additional prefix has been added, `~` to indicate
   the client to remove the override.
2. The header logic for GraphQL queries has been reworked to include
   headers for overridden feature flags. This ensures that the server
   uses the same overrides as the client.
3. The developer settings dialog and navbar entry now feature a reload
   button which appends `flag` to the current URL for overridden feature
   flags and reloads the page. Additionally the keyboard shortcut for
   reloading the page (`Mod-r`) is hijacked to perform the same action.
   NOTE: Unlike the first two, this functionality is only available in
   development builds.
2023-10-20 12:34:19 +02:00
Will Dollman
6d604319bc
security: Update access token format (#56772)
Implement RFC 837 https://docs.google.com/document/d/1aC4gHB8Q5lurwVhc8SCxznR0blNJMKo7yIkpP7WShno/edit.

This change will update our access token format to `sgp_<instance_identifier>_<40_char_access_token>`, allowing access tokens to be securely tied back to instances

This will initially be disabled behind a feature flag until Cody extension updates have been rolled out to users.
2023-10-20 11:29:07 +01:00
Will Dollman
69bb847bd9
sg: fix sg wolfi image builds (#57760)
Pass workdir to docker apko image

This previously defaulted to /work, but seems to have changed in a recent image update
2023-10-20 09:02:08 +00:00
Jean-Hadrien Chabran
1f60607c16
local: exclude generated files from pre-commit (#57761) 2023-10-20 08:19:40 +00:00
Anton Sviridov
39a12bcd7b
Java queries for local navigation (#57620) 2023-10-20 08:07:33 +01:00
Varun Gandhi
7258c7779c
chore: Delete cmd/sitemap (unused code) (#57361)
In the future, if we want to generate and upload these automatically,
we can restore the code from git history.
2023-10-20 14:16:43 +08:00
Quinn Slack
d1ae5ab487
fix extra args handling in sg (#57758)
When running `sg test <target> extra-arg1 extra-arg2 ...`, the extra args are generally appended to the `<target>` command on a new line, which means the extra args are interpreted by the shell as their own command. The user's intent is for them to be appended to the last command in the `<target>` command string, which this commit achieves by trimming trailing whitespace.
2023-10-19 21:11:59 -07:00
Erik Seliger
7fd4554d91
Remove github-proxy docker build (#56650)
We're not distributing this any longer as it's unused, so let's remove it!
2023-10-20 05:07:20 +02:00