Commit Graph

31 Commits

Author SHA1 Message Date
Dan Adler
8275054987
v2t: add v2 telemetry to the client/shared folder (#62586) 2024-06-03 16:34:28 -07:00
Noah S-C
9b6ba7741e
bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
Camden Cheek
1ead945267
Docs: update links to point to new site (#60381)
We have a number of docs links in the product that point to the old doc site. 

Method:
- Search the repo for `docs.sourcegraph.com`
- Exclude the `doc/` dir, all test fixtures, and `CHANGELOG.md`
- For each, replace `docs.sourcegraph.com` with `sourcegraph.com/docs`
- Navigate to the resulting URL ensuring it's not a dead link, updating the URL if necessary

Many of the URLs updated are just comments, but since I'm doing a manual audit of each URL anyways, I felt it was worth it to update these while I was at it.
2024-02-13 00:23:47 +00:00
Quinn Slack
4002774429
reapply "switch from jest to vitest for faster, simpler tests (#57886)" (#58145)
* reapply "switch from jest to vitest for faster, simpler tests (https://github.com/sourcegraph/sourcegraph/pull/57886)"

This was reverted in https://github.com/sourcegraph/sourcegraph/pull/58116 due to an issue with the browser tests.

* include fetch-mock

* fix flakiness

* rm mock that did not work in experimentalVmThreads

* fix

* timeout

* fixup

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-11-07 12:00:18 +02:00
William Bezuidenhout
7f4bebe29d
Revert: bazel+vitest - when running vitests concurrently the target //client/browser:test fails (#58116)
When running vitests concurrently the target //client/browser:test fails

Revert "switch from jest to vitest for faster, simpler tests (#57886)"

This reverts commit ae5325e432.
2023-11-06 14:02:35 +02:00
Quinn Slack
ae5325e432
switch from jest to vitest for faster, simpler tests (#57886)
Replaces our usage of jest with vitest. Also removes the babel transpiler. This simplifies our test configuration by a lot, makes tests run 10% faster, and makes further modernizations to our build/test stuff possible (such as using vite for frontend builds).

This removes some of the junit exporting for Buildkite, and the vitest bazel defs don't really cleanly implement bazel testing guidelines (like sharding). But vitest is only used for unit tests (all integration/e2e/regression tests have always run in mocha), so none of them are very slow anyway.

## Codemods for vitest imports

fastmod -e js,ts,tsx @jest/globals vitest client/ dev/release/
fastmod -e js,ts,tsx 'jest\.(\w+)\(' 'vi.$1(' client/ dev/release/
fastmod -e js,ts,tsx 'jest,' 'vi,' client/ dev/release/
fastmod -e js,ts,tsx 'jest }' 'vi }' client/ dev/release/
git diff --diff-filter=M --name-only | xargs pnpm exec prettier --write
2023-11-05 21:57:04 -10:00
Quinn Slack
6bdcd5e59c
simplify tsconfig.json files (#57913) 2023-10-26 03:03:11 -07:00
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
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
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
Felix Kling
7363557f41
Eslint fix type imports (#54920)
This PR adds the eslint rules @typescript-eslint/consistent-type-imports and @typescript-eslint/no-import-type-side-effects. Having type imports be explicitly declared as such makes it easier for modern bundlers to strip those imports which is useful if e.g. a module is sent directly to the browser.

I added both rules as a warning because @typescript-eslint/consistent-type-exports is also a warning.
2023-08-10 21:12:31 +02:00
Greg Magolan
09d898704a
build: update to Aspect CLI 5.5.2 (#53692)
Required adding a few import ignore directives in
`client/web/BUILD.bazel`. @jbedard is working on a fix for those. Has to
do with tsconfig paths. Fix will land in a future release.

## Test plan

5.4.11 output:

```
$ bazel configure
Updating BUILD files for protobuf, go, javascript
WARN[0000] Failed to load base tsconfig file @sourcegraph/tsconfig: open /Users/greg/aspect/sourcegraph/sourcegraph/@sourcegraph/tsconfig: no such file or directory 
client/app-shell/src/app-shell.tsx parse error(s):
50: Top-level await is currently not supported with the "iife" output format
Failed to parse tsconfig file client/completions-review-tool/tsconfig.json: ERR: position:298 object key must be string pos:298 : 
933 BUILD files visited
0 BUILD files updated
```

5.5.2 output has some new spam as well:

```
$ bazel configure
Updating BUILD files for protobuf, go, javascript
WARN[0000] Failed to load base tsconfig file @sourcegraph/tsconfig: open /Users/greg/aspect/sourcegraph/sourcegraph/@sourcegraph/tsconfig: no such file or directory 
Failed to parse tsconfig file client/completions-review-tool/tsconfig.json: ERR: position:298 object key must be string pos:298 : 
client/web/src/globals.d.ts:
	     17: }
         ^

client/web/src/storm/backend/route-loader.ts:
	     41:     usePreloadedQueryData: () => ReturnType<typeof useSuspenseQuery<D, V>>
                                                    ^
	     41:     usePreloadedQueryData: () => ReturnType<typeof useSuspenseQuery<D, V>>
                                                     ^

934 BUILD files visited
0 BUILD files updated
```
2023-06-22 18:33:15 +02:00
Greg Magolan
b398952eca
Revert "revert "bazel: improve ESLint rule" (#52853)" (#52878)
- Revert "revert "bazel: improve ESLint rule" (#52853)"
- bazel: fix eslint custom rule so js_binary runfiles are included as
tool inputs to ctx.actions.run_shell

## Test plan

Tested locally that fix commit resolves the
```
FATAL: aspect_rules_js[js_test]: RUNFILES environment variable is not set
```
flaky issue that prompted the revert
2023-06-04 19:06:39 -07:00
Valery Bugakov
e4b4c631cf
revert "bazel: improve ESLint rule" (#52853)
This reverts commit ff3ce9fe93 because of
the flaky errors on `main`. See [this Slack
thread](https://sourcegraph.slack.com/archives/C02FLQDD3TQ/p1685697360822839?thread_ts=1685696480.396849&cid=C02FLQDD3TQ).
2023-06-02 13:29:06 +00:00
Valery Bugakov
ff3ce9fe93
bazel: improve ESLint rule and disable ESLint outside of Bazel (#52667)
- Custom ESLint Bazel rule now relies on `sh_test`. The build part of
the rule produces the output file with ESLint errors, and the `sh_test`
target verifies that it's empty. If it's not empty, the ESLint test
fails, and the report content is printed to stdout.
- Added additional ESLint targets to `*.js` files in the root of each
client package.
- Added additional ESLint targets for `*.story.tsx` files for client
packages with stories. It's temporary until we start building Storybook
story modules with `ts_project`.
- Disabled ESLint outside of Bazel: **10-12m job is gone!** 🎉

## Test plan

bazel test `bazel query 'attr("name", ".*_eslint$", //client/...)'`
2023-06-02 08:37:40 +00:00
Valery Bugakov
760db946dd
bazel: implement custom ESLint Bazel rule (#52062)
- Upgraded `aspect_bazel_lib`, `aspect_rules_js` and `aspect_rules_ts`
to the latest versions.
- Ran [bazel run
//.aspect/bazelrc:update_aspect_bazelrc_presets](40a7422385)
- Added `eslint_config` macro for client package eslint configuration
`js_library` targets.
- Implemented the custom ESLint rule, which copies `srcs` with
dependencies and **declarations** to the Bazel to lint them. This way,
we maintain the ability to do type-aware linting in Bazel.
- Added a custom ESLint formatter used in Bazel to print out relative
paths in ESLint reports.

In the follow-up PR, I will look into improvements suggested by
@alexeagle that should allow us to convert ESLint build targets into
test targets and gracefully manage linting failures.

## Test plan

1. CI
2. `bazel build $(bazel query 'kind("_eslint_test_with_types",
//client/...)')`
2023-05-22 04:05:45 -07:00
Ólafur Páll Geirsson
9cbd8312f4
Go to definition: push current location into browser history (#50349)
Previously, the behavior was different whether you clicked on the "Go to
definition" link in the popover or used cmd-click. When using the link,
the current location didn't get pushed into the browser history making
"Go back" jump to a surprising location. When using cmd-click to
navigate to a definition, we pushed the current location into the
browser history to replicate the experience of navigating code in the
editor where you can easily go up/down the "jump stack", which is the
list of locations you navigate from/to with "Go to definition".

Importantly, this PR preserves the HTML link in the popover so that
users can still right-click "Open link in new tab".

## Test plan

Manually tested with 
```
❯ SOURCEGRAPHDOTCOM_MODE=true SOURCEGRAPH_API_URL=https://sourcegraph.com sg start web-standalone
```

- Open URL
https://sourcegraph.test:3443/github.com/sourcegraph/sourcegraph/-/blob/cmd/gitserver/server/server.go?L1080
- Load popover for `serverContext` on line 1093
- Click "Go to definition"
- "Go back" in the browser history and verify that you go back to line
1093 (not 1080!)
- Load the popover again for `serverContext`
- Use cmd-click (or ctrl-click on Linux/Windows) on the "Go to
definition" *link* and verify that it opens the definition in a new
browser tab. Do the same for shift-click to open the link in a new
window.
- Load the popover again for `serverContext`
- Verify that you can right-click on the "Go to definition" *link* and
use "Open Link in New Tab" to open the definition location in a new
browser tab


Going back in history 
![CleanShot 2023-04-04 at 17 57
06](https://user-images.githubusercontent.com/1408093/229850120-1dc562c1-1a65-4b40-80ac-69fe75352a97.gif)



<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

## App preview:

- [Web](https://sg-web-olafurpg-definition-recover.onrender.com/search)

Check out the [client app preview
documentation](https://docs.sourcegraph.com/dev/how-to/client_pr_previews)
to learn more.

---------

Co-authored-by: Taras Yemets <yemets.taras@gmail.com>
2023-04-11 15:27:41 +00:00
Vova Kulikov
5fca5ae3b0
Remove views api from extension api (#50451)
This PR removes old views extension logic that was used primary for the
first prototype version of code insights and it's no longer used
anywhere in our application at the moment.

## Test plan
- Make sure that CI is green and there is no regression in still used
extension logic
2023-04-06 16:59:30 -03:00
Tom Ross
d2cb50405d
Better import ordering with prettier (#48188) 2023-03-13 08:37:23 +00:00
Quinn Slack
ae338b9797
remove code host native tooltip toggle, hover alerts, command palette, notifs (#48688)
- Remove support for toggling native tooltips from the browser
extension. This let users choose to keep the browser extension installed
and partially active on GitHub but not show Sourcegraph's hovers. This
functionality is less important now that GitHub's new code nav no longer
uses hovers. For old GitHub Enterprise server instances (and GitHub.com
users who have not enabled the new code view), users can disable the
browser extension if they want to disable Sourcegraph's hover
functionality.
- Remove hover alerts, which were used to warn users that the results
are imprecise. We still show this in a hover badge, which is a much
nicer UI for this than a dismissible warning (which felt more "CYA").
- Remove command palette because it was inextricable from notifications
and it was only used by the Sourcegraph extension API (which is
deprecated and will be removed).
- Remove the old notifications UI, which showed notification messages in
Sourcegraph and code host UIs. This is no longer necessary with the
removal of the command palette, because it is no longer possible to
invoke long-running actions whose errors must be shown in a separate,
global UI.

## Test plan

Existing tests suffice to test the existing code intelligence
functionality. This PR just removes functionality.
2023-03-06 20:36:18 -08:00
Jason Bedard
10aefc4bb7
bazel: add bazel build,tests for client/* (#46193)
Webpack bundles compile but need further testing. Jest + mocha tests
compile but are marked as `manual` until further work is done to get them
passing. The four jest tests are green and enabled now, though.

## Test plan

`bazel build //client/...` and `bazel test //client/...`
2023-02-28 20:46:03 -08:00
Valery Bugakov
ce38bbc724
web: fix pnpm-lock issue (#47478)
Fixes the issue caused by the presence of the `sourcegraph: ''` entry in the `pnpm-lock.yaml`. If we install any new dependency, the `pnpm install` command fails on CI. [Failure example](https://github.com/sourcegraph/sourcegraph/actions/runs/4121774771/jobs/7117792725).
2023-02-09 22:04:31 -08:00
Valery Bugakov
3512fb9aa2
web: sync TS project refenreces (#46407) 2023-01-16 18:55:10 -08:00
Valery Bugakov
304acdb5da
web: migrate from yarn to pnpm (#46143)
Bazel's rules_js rely on the pnpm package manager. To simplify the integration, we're migrating to pnpm from our current package manager — yarn. Another reason to migrate is that pnpm is cool and fast. 😉
2023-01-11 19:50:09 -08:00
Valery Bugakov
47459ea10c
web: eliminate client-api & shared circle (#45948) 2022-12-25 18:10:39 -08:00
Quinn Slack
80024726b7
remove extension registry UI and related GraphQL API (#45891)
Removes the extension registry UI and the GraphQL API that is necessary for the registry extension UI.

Any extensions that already exist locally or remotely can still be used with the enableLegacyExtensions site config flag and by enabling the extensions in your user settings.

This change is an intermediate step toward removing the extension registry (except the endpoint that's needed to support pre-4.0 Sourcegraph instances).

I think this PR has a 99% chance of going into the 4.4 release (2023-01-20) and not needing to be reverted. Subsequent PRs that actually make it impossible to use local or custom legacy extensions are still pending customer communication and confirmation. I hope we can merge other future PRs there as well, but there is a greater chance we'd need to revert them before 4.4. By making this PR first, it means less of a revert and more progress regardless of what we learn from customers.
2022-12-22 00:10:56 -08:00
Ólafur Páll Geirsson
fac4477cd2
Rethink code navigation with CodeMirror token selection (#44698)
* Implement token cursor using CodeMirror selections

Previously, the token cursor feature flag used HTML href links for go to
definition. This commit changes the behavior of the feature flag to use
CodeMirror selections instead along with several other big changes:

* Cmd+Click for Go to definition
* Enter for Go to definition
* Space for Show popover
* Right-click menu for Go to definition and Find references
* Up/Down/Right/Left arrow to move the selection to the next token

Demo https://www.loom.com/share/a0fa53badd4d419081dcfd1a2fbc7e4e

Please give it a try and let us know what you think.

* Fix failing integration tests

* Hide popover when moving the selection

* Close hover tooltip on escape

* Replace dom manipulation with idiomatic CodeMirror extension

* Revert ARIA role='main'

* Address review feedback

* s/occurence/occurrence
2022-12-05 07:11:41 +00:00
GitStart-SourceGraph
b283d24198
[SG-39284] Upgrade yarn to the latest version (#39728) 2022-08-31 20:39:53 -07:00
GitStart-SourceGraph
44082f5b73
[SG-33302] Upgrade all client packages to use the latest version of the JSX transform (#34287)
Co-authored-by: gitstart-sourcegraph <gitstart@users.noreply.github.com>
2022-04-22 12:25:38 +01:00
Valery Bugakov
868472f43e
ci: run client linters on changed files (#33701) 2022-04-14 00:37:25 -07:00
GitStart-SourceGraph
6cb8f5016a
Create a client-api package (#31151) 2022-03-17 01:17:26 -07:00