Commit Graph

28373 Commits

Author SHA1 Message Date
William Bezuidenhout
1487312165
bazel: add nogo and define bodyclose linter locally (#48568)
This adds nogo to lint our code from within bazel.
## Test plan
`bazel build //cmd/frontend`

need to do a full build still
<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

---------

Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr>
2023-03-03 17:40:57 +02:00
Jean-Hadrien Chabran
17eb04f9fe
bzl: update buildfiles (#48626)
Update the buildfiles manually. 

## Test plan

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

Locally tested.
2023-03-03 15:36:18 +00:00
Eric Fritz
bb048b3368
upgrade: Fix insiders version string parsing (#48623) 2023-03-03 09:32:34 -06:00
coury-clark
93c73da2c6
release-tool: automate src-cli release in sourcegraph major and minor releases (#48511)
Closes
https://github.com/orgs/sourcegraph/projects/240?pane=issue&itemId=18474973

This PR does a few things:
1. Automates the significant versions (major / minor) src-cli release 
2. Automates the src-cli changelog
3. Provides a command to validate all distribution channels have the
updated version

There is some sequencing trouble in how src-cli is released that is
worth explaining here. So when we perform a release of sourcegraph we
also bake in a minimum src-cli version constant, as well as the
documentation for that version of src-cli. This documentation is
actually generated from the src-cli tool itself, and naively requires
the latest version is available on github.

That's something I don't want to interrupt the release process, so in
this PR we do something slightly different. First, we assume that the
head of main is the release commit, which is reasonable since we are the
ones performing the release. Second, we checkout src-cli and use the
local checkout to bake the documentation into the sourcegraph release.
Third, we perform the src-cli release by tagging the build and pushing
the tag.

To do that this PR also adds a new optional flag into the go program
that installs the software to pass a local path instead of downloading
the latest release.

For some quality of life we autodetect the latest src-cli version from
the src-cli repo instead of assuming it's always the same as the
Sourcegraph version. This is just to hedge against any future
divergence.

Here is an example
[PR](https://github.com/sourcegraph/sourcegraph/pull/48573) after
running the update command (the diff won't necessarily reflect a real
diff)

Using the validate command we can check that github, brew, and npm all
have the latest release that matches the expected version.

## Test plan

To test this I had to do a few janky things:

1. replace the clone path with a constant src-cli path (I just cloned it
once, then grabbed the directory)
2. replace the actual ./release.sh script with something that won't
release. I just edited the script to echo and return early after all the
validations in the same repo above

Here is the output showing the diff and the release script

<img width="1112" alt="image"
src="https://user-images.githubusercontent.com/5090588/222289405-bc1a0632-6af0-4e72-b883-a1cf786f0aec.png">


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

To test verify-src-cli simply run the command:
<img width="953" alt="CleanShot 2023-03-02 at 11 35 35@2x"
src="https://user-images.githubusercontent.com/5090588/222552782-72ae3e9f-03dd-4433-9a2b-7356df33849c.png">

And finally a minified example of the full flow
<img width="944" alt="CleanShot 2023-03-02 at 13 55 11@2x"
src="https://user-images.githubusercontent.com/5090588/222552934-7b49aa80-a2ad-4f54-9f27-ab8bf3d1408a.png">
2023-03-03 08:29:38 -07:00
Noah S-C
ca5fa2d1db
sg: bump github.com/moby/buildkit (#48625)
[The following PR](https://buildkite.com/sourcegraph/sourcegraph/builds/203366#0186a7e9-03e6-45ca-9ebe-217090d905b1)
is failing because `sg lint dockerfiles` doesnt understand HEREDOCS in
Dockerfiles due to outdated github.com/moby/buildkit

## Test plan

Built and ran `./sg lint dockerfiles` locally
2023-03-03 15:20:19 +00:00
Alex Ostrikov
4f52f3876e
permissions-center: fix search prompt for users. (#48624)
Test plan:
Local sg run and test.
2023-03-03 15:55:14 +01:00
David Veszelovszki
8273c33a14
SCIM: MockDB fixes: add comment, remove function, fix next ID (#48615)
- Fixes stuff based on @kopancek's comments on
https://github.com/sourcegraph/sourcegraph/pull/48577
2023-03-03 15:33:31 +01:00
Ólafur Páll Geirsson
a475f6c597
Highlighting: improve quailty for Go (#48618)
Previously, the Go tree-sitter highlighting was missing several
important language features, and it was using confusing colors in some
cases. This commit fixes most of those issues and makes Go highlighting
look much better overall.

![CleanShot 2023-03-03 at 14 25
51@2x](https://user-images.githubusercontent.com/1408093/222731707-f4569523-51f8-41c2-a7af-55318ce2716e.png)


## Test plan

See updated snapshots.

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-03-03 14:31:28 +00:00
David Veszelovszki
5f37fba121
SCIM: Add all meta fields everywhere (#48617)
- Fixes https://github.com/sourcegraph/sourcegraph/issues/48432

We didn't correctly set metadata in all cases.

- POST: It was okay
- GET: Creation and last modification date were missing
- PATCH: Creation and last modification date were missing, also had to
update returned value
- PUT: Creation and last modification date were missing
- DELETE: Not needed

## Test plan

- Was a very quick change, I hope CI passes
- End-to-end: tested the whole CRUD with Postman, and it worked nicely!
2023-03-03 15:30:14 +01:00
Keegan Carruthers-Smith
8ead93db58
servegit: Walk has logic for using the root (#48603)
Now that we don't have the tricky post processing we can move all the
important logic of discovering repos into the Walk function. I imagine
in the future we will have external callers to Walk so making this
correct will help.

Test Plan: go test
2023-03-03 14:08:27 +00:00
Petri-Johan Last
d5cefc1aed
Fix not counting the number of retries on GitHub rate limit requests (#48621) 2023-03-03 14:08:04 +00:00
Jean-Hadrien Chabran
92e7ca6f73
sg: bazel command sets block until bazel build is complete before anything else. (#48620)
Early feedback we got was that when using the bazel commandsets, if the
user never ran bazel build before, the logs would spam errors because
normal services would come up way earlier and complained about not being
able to reach other services.

While is never happens if you have only a few things to build, the
initial build command on a cold environment is really long. This fixes
this. In essence, it behaves like the old install method for those
services.

## Test plan

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

Tested locally.
2023-03-03 13:58:50 +00:00
Keegan Carruthers-Smith
a96e88aac5
servegit: simplify Walk behaviour around root is repo (#48602)
If the root is a repository then we just return that as a repository. We
had some complicated logic here which handled the case when we used to
recurse further into repositories looking for more. But now it can be
simplified so that we don't need to post-process the names.

Test Plan: a test case was added for repository is root. Tested that it
broke in the state where I removed the older post filtering code but not
the new is repo root check.
2023-03-03 15:44:48 +02:00
Ólafur Páll Geirsson
19499a6c3e
Highlighting: use more variety of colors in Scala (#48613)
Previously, we used `SyntaxKind.Identifier` in too many places making
everything look blue. In this commit, we use different colors for
functions and capitalized identifiers (which are normally used for
    constants). These small changes greatly improve the quality of the
highlighting.
2023-03-03 08:41:20 -05:00
Indradhanush Gupta
a13b5e3af1
azuredevops: Support allowOrgs in azure auth provider (#48612) 2023-03-03 19:10:49 +05:30
Alex Ostrikov
a8ffc51b9e
permissions-center: add search form for permissions sync jobs. (#48607)
Test plan:
Local sg run and tests.
2023-03-03 13:58:27 +01:00
Eric Fritz
3001b7b9cb
sentinel: Vulnerability database syncer routine (#48579) 2023-03-03 04:57:34 -08:00
Petri-Johan Last
7696b8ca94
Add configurable option to wait for GitHub external rate limiter (#48423) 2023-03-03 14:15:23 +02:00
Erik Seliger
f1abd76ca9
teams: Allow creator to manage team (#48597)
Currently, a user can create a new team but then cannot further modify
or delete it, as they're not a member of it. This PR changes the access
to "creator can always manage", so that they can modify it further, add members and such.
2023-03-03 12:42:47 +01:00
Philipp Spiess
639d5ffd58
Run VSCode build on main CI again (#48560) 2023-03-03 11:57:05 +01:00
Indradhanush Gupta
7d2d2a0094
azuredevops: Add client method ListAuthorizedUserOrganizations (#48572) 2023-03-03 09:39:43 +00:00
Alex Ostrikov
4549d045cb
permissions-center: fix counting jobs with search predicates. (#48604)
Test plan:
Unit tests updated.
Local sg run and GraphQL API test.
2023-03-03 10:16:04 +01:00
Milan Freml
9364224a90
[feat] Read only from unified perms table if feature flag is set (#48558)
Also added a go benchmark with some results

## Benchmark results

```
// BenchmarkAuthzQuery_ListMinimalRepos_1000repos_1000users_50reposPerUser/list_repos,_using_unified_user_repo_permissions_table-10                   23928            495697 ns/op
// BenchmarkAuthzQuery_ListMinimalRepos_1000repos_1000users_50reposPerUser/list_repos,_using_legacy_user_permissions_table-10                         24399            486467 ns/op

// BenchmarkAuthzQuery_ListMinimalRepos_10krepos_10kusers_150reposPerUser/list_repos,_using_unified_user_repo_permissions_table-10                     3180           4023709 ns/op
// BenchmarkAuthzQuery_ListMinimalRepos_10krepos_10kusers_150reposPerUser/list_repos,_using_legacy_user_permissions_table-10                           2911           4020591 ns/op

// BenchmarkAuthzQuery_ListMinimalRepos_10krepos_10kusers_500reposPerUser/list_repos,_using_unified_user_repo_permissions_table-10                     3201           4101237 ns/op
// BenchmarkAuthzQuery_ListMinimalRepos_10krepos_10kusers_500reposPerUser/list_repos,_using_legacy_user_permissions_table-10                           2944           4144971 ns/op

// BenchmarkAuthzQuery_ListMinimalRepos_500krepos_40kusers_500reposPerUser/list_repos,_using_unified_user_repo_permissions_table-10                      63         186395579 ns/op
// BenchmarkAuthzQuery_ListMinimalRepos_500krepos_40kusers_500reposPerUser/list_repos,_using_legacy_user_permissions_table-10                            62         190570966 ns/op
```

The performance of both old and new authzQuery is really similar, the
new query is marginally faster on datasets with lots of repositories per
user. The old query is marginally faster on smaller datasets with not as
many repositories per user.

## Test plan

Unit tests modified, tested locally.
2023-03-03 09:50:58 +01:00
David Veszelovszki
d58a43e63a
SCIM: More fixes (#48577)
- Simplify fromAccountData()
- Remove unused test case
- Make account_data the source of truth
- Move `convertUserToSCIMResource` to user.go
- Get external ID from attributes
- Slightly improve user displayName getting
- Unwrapping error to return the correct (409) error code
- Remove test logging
- Remove two obsolete TODOs
- Deduplicate data encryption
- Rename a local variable
- Narrow a function interface
- Move a function out of struct
- Fix externalID and serviceID
- Update tests
2023-03-03 08:52:49 +01:00
Alex Ostrikov
29b160c5c2
permissions-center: remove unnecessary useEffect usage for jobs refetch. (#48600)
The reason that `useEffect` is not needed is that when the filter is
selected, component (`PermissionsSyncJobsTable`) state is changed at it
is being re-rendered with new parameters, hence new GraphQL query is
sent.

Also, `refetch` call in `useEffect` was never made with the same reason
-- filters and GraphQL query variables were never different because of
component state update.

Test plan:
Local sg run and manual tests.
2023-03-03 07:02:16 +00:00
Erik Seliger
c56371cf23
Own discoverability (#48232)
This PR mainly does two things to increase the visibility of Own:

- It adds to the landing page examples

(Slightly outdated, now replaces "get advanced" if own is on)
<img width="1299" alt="Screenshot 2023-02-26 at 04 48 53@2x"
src="https://user-images.githubusercontent.com/19534377/221391306-9dd679a9-9906-48fa-9731-84efae9c1122.png">

- And also adds a new banner to the Own panel, with a short description
of it and also more hints towards trying search, too.


![image](https://user-images.githubusercontent.com/19534377/221391182-5f9ed589-d7e8-494f-b731-8f866ce1803f.png)

I am not sure if we want to merge this ~as is or want to make more
changes, but we need to find _some_ consensus soon so I'm just putting
it out here and I'll let you comment what you think about it, how we
should adjust wording, and I shouldn't have removed another example to
make room for this one.

All of these things only appear when Own is enabled, so no one gets
confused. For non-enabled instances, the visibility should be solved by
an in-app page instead.

Closes https://github.com/sourcegraph/sourcegraph/issues/48518

Co-authored-by: Malo Marrec <malo.marrec@gmail.com>
2023-03-03 03:28:56 +01:00
Marek
2ac49b1b27
app: Add app outbound url params on notebooks page (#48476) 2023-03-02 21:13:30 -05:00
Erik Seliger
1257ccdd99
own: Small ingestion API fixes (#48584)
- GraphQL APIs have to take IDs vs ints, so I adjusted that and also
allowed names now, which makes things a bit easier in src-cli
- Removed a redundant err.Wrap, that was rendering the same content
twice
2023-03-03 02:37:37 +01:00
David Veszelovszki
0095e26ec7
Only link update if available, link changelog (#48537)
- Link current version in changelog.
- If there's no update available, hide the "Update" link.
2023-03-03 00:52:47 +01:00
Philipp Spiess
e390eae8e8
Fix GitHub pull links for blame lines (#48583) 2023-03-03 00:00:48 +01:00
Felix Kling
4f69c2b3f7
search input: Move query validation to reusable module (#48552)
This moves the query validation extension into its own module and adds
it to the new query input.

## Test plan

Manual test.
2023-03-02 23:39:21 +01:00
Eric Fritz
0a487f5a61
sentinel: Add GraphQL layer for basic listing of vuln/vuln matches (#48575) 2023-03-02 21:08:19 +00:00
Eric Fritz
6106f59e7e
sentinel: Add GraphQL layer for direct object access (#48570) 2023-03-02 20:46:54 +00:00
Ólafur Páll Geirsson
de3c131955
Highlighting: switch Go highlighter engine to tree-sitter (#48528)
Go is the only language we have a tree-sitter highlighter for that
hasn't been turned on by default. This change fixes an off-by-one error
in the syntect->scip conversion that affects pages like
https://sourcegraph.com/github.com/hashicorp/errwrap/-/blob/errwrap.go

## Test plan

Manually tested by loading
https://sourcegraph.test:3443/github.com/hashicorp/errwrap/-/blob/errwrap.go
and verifying that the off-by-one bug is fixed with the tree-sitter
highlighter.

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-03-02 20:41:45 +00:00
Eric Fritz
314c3b0128
sentinel: Add store methods to insert and query vulnerability matches (#48486) 2023-03-02 18:50:29 +00:00
Warren Gifford
c088168d97
add auto_upgrade column to versions table (#48260)
Add `auto_upgrade` column to `versions` table

Part of #48048 

## Test plan

`up > down > up` -- checking Sourcegraph with sg start
2023-03-02 10:38:30 -08:00
Eric Fritz
476d69ad73
sentinel: Add store methods to insert and query vulnerabilities (#48485) 2023-03-02 18:31:57 +00:00
Alex Ostrikov
7c37b6f171
setup-experience: add setup info to jscontext. (#48563)
Test plan:
Local sg run and `window.context` check.
2023-03-02 18:25:30 +00:00
sourcegraph-buildkite
e2888ecea5
zoekt: update to sourcegraph/zoekt@a4018300b2 (#48566)
This PR is autogenerated to update to
sourcegraph/zoekt@a4018300b2

## Test Plan

Testing is done on the zoekt repo. All checks on this PR are sufficient.

Co-authored-by: jhchabran <jhchabran@users.noreply.github.com>
2023-03-02 20:07:18 +02:00
Gabe Torres
32583c10ba
Add changes to services in helm (#48519)
closes #48523 
## Test plan
Doc update
<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
2023-03-02 09:51:59 -08:00
leo
120a4ec152
own: add graphql schema and resolvers for manual codeowners files (#48182) 2023-03-02 17:19:42 +00:00
Philipp Spiess
1f7b4f66a6
Make more fields as deprecated and explaining the newer alternatives (#48455) 2023-03-02 18:19:10 +01:00
Philipp Spiess
5811169411
Treeview: Fix scrolling in symbol tree (#48543)
The symbol tree has an input element that is `position: sticky;` which
caused issues when scrolling to elements inside the view.

We fix this by adding a `scroll-margin-top` to the node component.
2023-03-02 17:15:57 +00:00
Alex Ostrikov
3fb3c5d858
permissions-center: add permissions sync jobs filters by reason and state. (#48462)
Test plan:
Storybook.
Local sg run and tests.
2023-03-02 17:52:55 +01:00
Bryan Potter
6ba75e322e
[fixes #2761] Update remote selection to prefer 'upstream' and 'origin' (#48369)
Co-authored-by: Philipp Spiess <hello@philippspiess.com>
2023-03-02 17:51:58 +01:00
Philipp Spiess
3bc347fb22
Fix VSCode build (#48559) 2023-03-02 17:24:27 +01:00
Eric Fritz
cab757596f
ranking: Do not re-process references for the same project for a single map step (#48521) 2023-03-02 10:14:30 -06:00
Felix Kling
d894b64ff2
experimental search input: Remove filter field background (#48551)
We decided to remove the background color and continue to use the same
styling we already have. By removing it we also magically fix this part
of the dark mode problem ;)

Whether or not to keep the context filter border is still up for debate
but I've slightly tweaked the border color for now to make it more
visible in dark mode.

Moving `tokenInfo` before `filterDecoration` fixes the "layout shift"
when hovering over the `context:` filter.


<img width="819" alt="2023-03-02_14-58"
src="https://user-images.githubusercontent.com/179026/222465999-ec5528be-5c03-4a14-96d9-77d85e8be2b1.png">


## Test plan

Manual testing.

## App preview:

- [Web](https://sg-web-fkling-search-input-style.onrender.com/search)

Check out the [client app preview
documentation](https://docs.sourcegraph.com/dev/how-to/client_pr_previews)
to learn more.
2023-03-02 17:11:36 +01:00
Idan Varsano
3f6a7377c6
Ingest Webhooks from Azure DevOps (#48391)
Ingest Azure DevOps Webhooks for Batch Changes
2023-03-02 11:00:46 -05:00
Eric Fritz
aad9f1050b
lint: Fix unused codeintel vars (#48556) 2023-03-02 15:48:16 +00:00