From 868b79467c914940366a713e6d2cb3cc120cf003 Mon Sep 17 00:00:00 2001 From: Jean-Hadrien Chabran Date: Fri, 10 Mar 2023 15:33:22 +0100 Subject: [PATCH] Update buildfiles (#48908) ~Quick~ update to catchup with latest changes and fix edge cases. ## Test plan Bazel jobs should be green. --------- Co-authored-by: Jason Bedard Co-authored-by: Valery Bugakov --- .aspect/bazelrc/ci.sourcegraph.bazelrc | 4 + WORKSPACE | 16 +- client/backstage-backend/.gitignore | 3 - client/backstage-backend/.prettierignore | 2 - client/backstage-backend/BUILD.bazel | 40 ---- client/backstage-backend/CONTRIBUTING.md | 187 ------------------ .../backstage-backend/app-config.example.yaml | 18 -- client/backstage-backend/babel.config.js | 8 - client/backstage-backend/jest.config.js | 14 -- client/backstage-backend/package.dist.json | 20 -- client/backstage-backend/package.json | 46 ----- client/backstage-backend/scripts/esbuild.ts | 55 ------ .../src/client/Query.test.ts | 26 --- client/backstage-backend/src/client/Query.ts | 125 ------------ .../src/client/SourcegraphClient.test.ts | 112 ----------- .../src/client/SourcegraphClient.ts | 93 --------- client/backstage-backend/src/client/index.ts | 2 - client/backstage-backend/src/index.ts | 8 - .../backstage-backend/src/providers/index.ts | 1 - .../src/providers/parsers.ts | 97 --------- .../src/providers/providers.ts | 87 -------- client/backstage-backend/src/setupTests.ts | 2 - .../src/tests/integration/e2e.test.ts | 16 -- client/backstage-backend/tsconfig.json | 35 ---- client/backstage-frontend/.eslintrc.js | 12 -- client/backstage-frontend/.gitignore | 3 - client/backstage-frontend/.prettierignore | 3 - client/backstage-frontend/BUILD.bazel | 61 ------ client/backstage-frontend/README.md | 17 -- client/backstage-frontend/babel.config.js | 8 - client/backstage-frontend/dev/index.tsx | 12 -- client/backstage-frontend/package.dist.json | 27 --- client/backstage-frontend/package.json | 57 ------ client/backstage-frontend/scripts/esbuild.ts | 48 ----- .../ExampleComponent.test.tsx | 22 --- .../ExampleComponent/ExampleComponent.tsx | 28 --- .../src/components/ExampleComponent/index.ts | 1 - .../ExampleFetchComponent.test.tsx | 23 --- .../ExampleFetchComponent.tsx | 84 -------- .../components/ExampleFetchComponent/index.ts | 1 - client/backstage-frontend/src/index.ts | 1 - client/backstage-frontend/src/plugin.test.ts | 7 - client/backstage-frontend/src/plugin.ts | 18 -- client/backstage-frontend/src/routes.ts | 5 - client/backstage-frontend/src/setupTests.ts | 2 - client/backstage-frontend/tsconfig.json | 31 --- client/web/BUILD.bazel | 27 ++- client/web/dev/BUILD.bazel | 5 - client/web/dev/esbuild/BUILD.bazel | 4 + ...ceNode.tsx.tsx => ExternalServiceNode.tsx} | 0 .../externalServices/ExternalServicesPage.tsx | 2 +- cmd/frontend/enterprise/BUILD.bazel | 1 - cmd/frontend/graphqlbackend/BUILD.bazel | 2 + .../internal/app/jscontext/BUILD.bazel | 1 + .../internal/auth/userpasswd/BUILD.bazel | 4 + cmd/frontend/internal/bg/BUILD.bazel | 1 + cmd/frontend/internal/cli/BUILD.bazel | 3 + cmd/frontend/internal/highlight/BUILD.bazel | 6 + cmd/frontend/internal/httpapi/BUILD.bazel | 7 + cmd/frontend/shared/BUILD.bazel | 5 +- cmd/gitserver/server/BUILD.bazel | 3 + cmd/gitserver/shared/BUILD.bazel | 3 + deps.bzl | 4 +- dev/linters/ineffassign/BUILD.bazel | 2 +- dev/mocha.bzl | 8 +- docker-images/syntax-highlighter/BUILD.bazel | 14 +- .../crates/sg-macros/BUILD.bazel | 28 +-- .../crates/sg-syntax/BUILD.bazel | 31 +-- .../internal/batches/rbac/BUILD.bazel | 9 + .../internal/batches/resolvers/BUILD.bazel | 4 + .../internal/own/resolvers/BUILD.bazel | 18 +- .../cmd/worker/internal/codeintel/BUILD.bazel | 1 + enterprise/dev/ci/internal/ci/pipeline.go | 3 +- .../internal/batches/testing/BUILD.bazel | 3 + .../codeintel/autoindexing/BUILD.bazel | 6 +- .../internal/background/BUILD.bazel | 3 +- .../internal/enqueuer/BUILD.bazel | 1 + .../internal/inference/BUILD.bazel | 5 +- .../internal/codeintel/policies/BUILD.bazel | 1 - .../ranking/internal/background/BUILD.bazel | 4 +- .../ranking/internal/shared/BUILD.bazel | 9 + .../ranking/internal/store/BUILD.bazel | 2 + .../codeintel/shared/background/BUILD.bazel | 17 ++ .../uploads/internal/background/BUILD.bazel | 6 +- .../gitserver/integration_tests/BUILD.bazel | 3 + enterprise/internal/insights/BUILD.bazel | 2 +- .../query/querybuilder/regexp_test.go | 1 + .../migrations/batches/BUILD.bazel | 3 + .../internal/own/codeowners/BUILD.bazel | 4 +- enterprise/internal/own/search/BUILD.bazel | 3 + enterprise/internal/paths/BUILD.bazel | 18 ++ enterprise/internal/scim/BUILD.bazel | 1 + enterprise/internal/search/BUILD.bazel | 1 + internal/codeintel/dependencies/BUILD.bazel | 6 + .../internal/background/BUILD.bazel | 13 ++ .../dependencies/internal/store/BUILD.bazel | 1 + internal/database/dbtest/dbtest.go | 2 +- internal/extsvc/bitbucketcloud/BUILD.bazel | 1 + internal/extsvc/github/BUILD.bazel | 1 - internal/extsvc/gitlab/BUILD.bazel | 4 + internal/gitserver/BUILD.bazel | 3 + .../gitserver/integration_tests/BUILD.bazel | 3 + internal/goroutine/recorder/BUILD.bazel | 4 + internal/grpc/BUILD.bazel | 2 +- internal/httpcli/BUILD.bazel | 4 + internal/httpcli/client.go | 2 +- internal/packagefilters/BUILD.bazel | 14 ++ internal/rbac/BUILD.bazel | 13 +- internal/repos/BUILD.bazel | 2 +- internal/search/backend/BUILD.bazel | 3 + internal/singleprogram/filepicker/BUILD.bazel | 1 + internal/usagestats/BUILD.bazel | 2 + internal/wrexec/BUILD.bazel | 4 + migrations/BUILD.bazel | 33 ++++ monitoring/definitions/BUILD.bazel | 1 + nogo_config.json | 2 +- 116 files changed, 343 insertions(+), 1555 deletions(-) delete mode 100644 client/backstage-backend/.gitignore delete mode 100644 client/backstage-backend/.prettierignore delete mode 100644 client/backstage-backend/BUILD.bazel delete mode 100644 client/backstage-backend/CONTRIBUTING.md delete mode 100644 client/backstage-backend/app-config.example.yaml delete mode 100644 client/backstage-backend/babel.config.js delete mode 100644 client/backstage-backend/jest.config.js delete mode 100644 client/backstage-backend/package.dist.json delete mode 100644 client/backstage-backend/package.json delete mode 100644 client/backstage-backend/scripts/esbuild.ts delete mode 100644 client/backstage-backend/src/client/Query.test.ts delete mode 100644 client/backstage-backend/src/client/Query.ts delete mode 100644 client/backstage-backend/src/client/SourcegraphClient.test.ts delete mode 100644 client/backstage-backend/src/client/SourcegraphClient.ts delete mode 100644 client/backstage-backend/src/client/index.ts delete mode 100644 client/backstage-backend/src/index.ts delete mode 100644 client/backstage-backend/src/providers/index.ts delete mode 100644 client/backstage-backend/src/providers/parsers.ts delete mode 100644 client/backstage-backend/src/providers/providers.ts delete mode 100644 client/backstage-backend/src/setupTests.ts delete mode 100644 client/backstage-backend/src/tests/integration/e2e.test.ts delete mode 100644 client/backstage-backend/tsconfig.json delete mode 100644 client/backstage-frontend/.eslintrc.js delete mode 100644 client/backstage-frontend/.gitignore delete mode 100644 client/backstage-frontend/.prettierignore delete mode 100644 client/backstage-frontend/BUILD.bazel delete mode 100644 client/backstage-frontend/README.md delete mode 100644 client/backstage-frontend/babel.config.js delete mode 100644 client/backstage-frontend/dev/index.tsx delete mode 100644 client/backstage-frontend/package.dist.json delete mode 100644 client/backstage-frontend/package.json delete mode 100644 client/backstage-frontend/scripts/esbuild.ts delete mode 100644 client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.test.tsx delete mode 100644 client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.tsx delete mode 100644 client/backstage-frontend/src/components/ExampleComponent/index.ts delete mode 100644 client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx delete mode 100644 client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx delete mode 100644 client/backstage-frontend/src/components/ExampleFetchComponent/index.ts delete mode 100644 client/backstage-frontend/src/index.ts delete mode 100644 client/backstage-frontend/src/plugin.test.ts delete mode 100644 client/backstage-frontend/src/plugin.ts delete mode 100644 client/backstage-frontend/src/routes.ts delete mode 100644 client/backstage-frontend/src/setupTests.ts delete mode 100644 client/backstage-frontend/tsconfig.json create mode 100644 client/web/dev/esbuild/BUILD.bazel rename client/web/src/components/externalServices/{ExternalServiceNode.tsx.tsx => ExternalServiceNode.tsx} (100%) create mode 100644 enterprise/cmd/frontend/internal/batches/rbac/BUILD.bazel create mode 100644 enterprise/internal/codeintel/ranking/internal/shared/BUILD.bazel create mode 100644 enterprise/internal/codeintel/shared/background/BUILD.bazel create mode 100644 enterprise/internal/paths/BUILD.bazel create mode 100644 internal/packagefilters/BUILD.bazel diff --git a/.aspect/bazelrc/ci.sourcegraph.bazelrc b/.aspect/bazelrc/ci.sourcegraph.bazelrc index 3751b9259cb..880402be3ec 100644 --- a/.aspect/bazelrc/ci.sourcegraph.bazelrc +++ b/.aspect/bazelrc/ci.sourcegraph.bazelrc @@ -16,3 +16,7 @@ test --action_env=PATH test --action_env=PGUSER test --action_env=PGSSLMODE test --action_env=PGDATABASE + +# Allow tests to understand they're running in CI, which forces dbtest to drop database even in case of failures. +# TODO(JH) we should instead wipe all templates after a job finishes. +test --action_env=CI diff --git a/WORKSPACE b/WORKSPACE index 3e122c5b989..50aa51210c2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -230,11 +230,11 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") rules_rust_dependencies() rust_register_toolchains( - edition = "2021", - # Keep in sync with docker-images/syntax-highlighter/Dockerfile - versions = [ - "1.67.1" - ], + edition = "2021", + # Keep in sync with docker-images/syntax-highlighter/Dockerfile + versions = [ + "1.67.1", + ], ) load("@rules_rust//crate_universe:defs.bzl", "crates_repository") @@ -247,9 +247,9 @@ crates_repository( # To regenerate this file run: CARGO_BAZEL_REPIN=1 bazel sync --only=crates_index lockfile = "//docker-images/syntax-highlighter:Cargo.Bazel.lock", manifests = [ - "//docker-images/syntax-highlighter:crates/sg-macros/Cargo.toml", - "//docker-images/syntax-highlighter:crates/sg-syntax/Cargo.toml", - "//docker-images/syntax-highlighter:Cargo.toml", + "//docker-images/syntax-highlighter:crates/sg-macros/Cargo.toml", + "//docker-images/syntax-highlighter:crates/sg-syntax/Cargo.toml", + "//docker-images/syntax-highlighter:Cargo.toml", ], ) diff --git a/client/backstage-backend/.gitignore b/client/backstage-backend/.gitignore deleted file mode 100644 index bba18296a4f..00000000000 --- a/client/backstage-backend/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -dist/ -dist-types/ -node_modules/ diff --git a/client/backstage-backend/.prettierignore b/client/backstage-backend/.prettierignore deleted file mode 100644 index de4d1f007dd..00000000000 --- a/client/backstage-backend/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -dist -node_modules diff --git a/client/backstage-backend/BUILD.bazel b/client/backstage-backend/BUILD.bazel deleted file mode 100644 index 5a18423252c..00000000000 --- a/client/backstage-backend/BUILD.bazel +++ /dev/null @@ -1,40 +0,0 @@ -load("@npm//:defs.bzl", "npm_link_all_packages") -load("//dev:defs.bzl", "ts_project") - -npm_link_all_packages(name = "node_modules") - -ts_project( - name = "backstage-backend", - srcs = [ - "src/client/Query.ts", - "src/client/SourcegraphClient.ts", - "src/client/index.ts", - "src/index.ts", - "src/providers/index.ts", - "src/providers/parsers.ts", - "src/providers/providers.ts", - "src/setupTests.ts", - ], - deps = [ - ":node_modules/@backstage/catalog-model", - ":node_modules/@backstage/plugin-catalog-backend", - ":node_modules/@sourcegraph/http-client", - ":node_modules/@sourcegraph/shared", - "//:node_modules/@apollo/client", - ], -) - -ts_project( - name = "backstage-backend_tests", - testonly = True, - srcs = [ - "src/client/Query.test.ts", - "src/client/SourcegraphClient.test.ts", - "src/tests/integration/e2e.test.ts", - ], - deps = [ - ":backstage-backend", - ":node_modules/@jest/globals", - "//:node_modules/@apollo/client", - ], -) diff --git a/client/backstage-backend/CONTRIBUTING.md b/client/backstage-backend/CONTRIBUTING.md deleted file mode 100644 index 2f2cbc4ddfc..00000000000 --- a/client/backstage-backend/CONTRIBUTING.md +++ /dev/null @@ -1,187 +0,0 @@ -# Sourcegraph Backstage Common library plugin - -Welcome to the Sourcegraph Backstage common plugin! - -## How this plugin was generated. - -Backstage has a cli named `backstage-cli` which performs a bunch of operations relating to Backstage maintenance and developing, including generating scaffolding for plugins. - -There are a few plugin types but we're only interested in the following types for now: - -- frontend-plugin: a plugin that adds components and integration with the Backstage frontend. The generated scaffolding allows running the plugin on its own without Backstage, as long as there is an `app-config.yaml` for configuration. -- backend-plugin: a plugin that integrates with the Backstage backend. Typically does not contain any visual components. The generated scaffolding allows you to run the plugin on its own as a backend application, meaning there won't be a web page to visit. -- common-plugin: a plugin that is more a library, with common functionality you want to share across plugins. Unlike the other plugin types, this plugin cannot be run on its own. - -### How to generate plugin scaffolding. - -1. Make sure you're in the Backstage repo generated with `@backstage/create-app` (Not a hard requirement, but the rest of the points assume this directory). -2. Run `backstage-cli new`, where a mini wizard will ask you questions about your plugin. -3. Once the command completes, the generated plugin scaffolding can be found under `plugins/`. - -The plugin scaffolding now has been generated but the scaffolding assumes the plugin will stay in the Backstage repo which it won't. To make the plugin 'workable' outside of the Backstage repository we have make some additional changes. - -1. Add the following `tsconfig.json` to the plugin directory. - -```json -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "target": "es2020", - "lib": ["esnext", "DOM", "DOM.Iterable"], - "sourceMap": true, - "sourceRoot": "src", - "baseUrl": "./src", - "paths": { - "@sourcegraph/*": ["../*"], - "*": ["types/*", "../../shared/src/types/*", "../../common/src/types/*", "*"] - }, - "esModuleInterop": true, - "resolveJsonModule": true, - "strict": true, - "jsx": "react-jsx" - }, - "references": [ - { - "path": "../shared" - } - ], - "include": ["./package.json", "**/*", ".*", "**/*.d.ts"], - "exclude": ["node_modules", "../../node_modules", "dist"] -} -``` - -The above `tsconfig` was copied from `client/jetbrains` and adapted to fit our usecase. - -2. Take note of the plugin directory structure. - -```console - -. -├── README.md -├── dist -│   ├── index.cjs.js -│   ├── index.cjs.js.map -│   ├── index.d.ts -│   ├── index.esm.js -│   └── index.esm.js.map -├── dist-types -│   ├── src -│   │   ├── catalog -│   │   │   ├── index.d.ts -│   │   │   └── parsers.d.ts -│   │   ├── client -│   │   │   ├── SourcegraphClient.d.ts -│   │   │   ├── SourcegraphClient.test.d.ts -│   │   │   └── index.d.ts -│   │   ├── index.d.ts -│   │   ├── providers -│   │   │   ├── SourcegraphEntityProvider.d.ts -│   │   │   └── index.d.ts -│   │   └── setupTests.d.ts -│   └── tsconfig.tsbuildinfo -├── node_modules -├── package.json -├── src -│   ├── catalog -│   │   ├── index.ts -│   │   └── parsers.ts -│   ├── client -│   │   ├── SourcegraphClient.test.ts -│   │   ├── SourcegraphClient.ts -│   │   └── index.ts -│   ├── index.ts -│   ├── providers -│   │   ├── SourcegraphEntityProvider.ts -│   │   └── index.ts -│   └── setupTests.ts -└── tsconfig.json - -17 directories, 27 files -``` - -3. The plugin will use libraries and components from the Sourcegraph repo, which are all private and not available on the npm registry. Which means, when this plugin is installed into Backstage, it will try to look for any dependencies defined in the `package.json` on the npm registry. It will find some, but any Sourcegraph referenced projects, it won't be able to find anything. We thus need to make some changes to the `package.json` and also look into using a bundler like `esbuild`. - -4. The notable changes we make in the `package.json` are that: - -- change the `main` attribute to have the `dist/index.js` - note no `cjs`. This is due to use using a bundler, which bundles everything into a `js` file. -- add a script `es` which invokes `esbuild` with a particular config and we copy `package.dist.json` to `dist/package.json`. `package.dist.json` is a slimmed down version of our root package.json and defines how one should install the bundled artefact of our plugin, namely `index.js`. - -```json -{ - "name": "backstage-plugin-sourcegraph-common", - "description": "Common functionalities for the Sourcegraph plugin", - "version": "0.1.0", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "license": "Apache-2.0", - "private": true, - "publishConfig": { - "access": "public", - "main": "dist/index.js", - "module": "dist/index.esm.js", - "types": "dist/index.d.ts" - }, - "backstage": { - "role": "common-library" - }, - "scripts": { - "es": "ts-node --transpile-only ./scripts/esbuild.ts && cp package.dist.json dist/", - "build": "backstage-cli package build", - "lint": "backstage-cli package lint", - "test": "backstage-cli package test", - "clean": "backstage-cli package clean", - "prepack": "backstage-cli package prepack", - "postpack": "backstage-cli package postpack" - }, - "devDependencies": { - "@backstage/cli": "^0.22.1", - "@jest/globals": "^29.4.0", - "@sourcegraph/tsconfig": "^4.0.1", - "@types/jest": "^29.4.0", - "ts-jest": "^29.0.5" - }, - "dependencies": { - "@backstage/catalog-model": "^1.1.5", - "@backstage/config": "^1.0.6", - "@backstage/plugin-catalog-backend": "^1.7.1", - "@sourcegraph/shared": "workspace:^1.0.0" - }, - "files": ["dist"] -} -``` - -5. If we take a look at the `esbuild` config defined in `scripts/esbuild.ts` there are a few options to take note of: - -- we use `external` and define most of our dependencies except the Sourcegraph related ones. External tells `esbuild` that it shouldn't bundle these dependencies into the final artefact. We set it to the values we defined in our `package.json` because they can be found on the npm registry. This also explains why we don't have `@sourcegraph/*` defined there, since we **do** want them bundled. Unfortunately, some transitive dependencies will also be bundled as they're imported, which why `lodash` and `apollo` are defined. It is a bit of a cat and mouse game, to get the right dependencies excluded. - -6. We can now copy the directory to wherever we want, like the Sourcgraph repo `cp plugins/backstage-plugin-test ~/sourcegraph/client/backstage/test`. - -7. Depending on the type of plugin that was generated, a dependency entry was added to either the `packages/app/package.json or `packages/backend/packages.json`. Now that the plugin has been 'moved' we don't want Backstage to still refer to these locations, so remove the plugin with `yarn workspace backend remove `or`yarn workspace app remove `. - -### Run the plugin with Backstage / Local Development - -Since we copied the plugin to a different directory we need to tell Backstage where to find the plugin. - -1. Make sure the plugin is built. Note that we use pnpm here and not yarn, which is because Sourcegraph uses pnpm. Both yarn and pnpm work with the command defined in the `package.json` which just executes `backstage-cli` with some args. - -```console -$ cd sourcegraph/client/backstage/plugin -$ pnpm es -``` - -2. There should now be a dist directory in `sourcegraph/client/backstage/plugin`. -3. We're now ready to show Backstage where the plugin is. Move to the Backstage root directory and execute: - For a plugin that integrates with the backend: - -```console -$ yarn workspace backend add link:~/sourcegraph/client/backstage/plugin/dist -``` - -For a plugin that integrates with the frontend: - -```console -$ yarn workspace app add link:~/sourcegraph/client/backstage/plugin/dist -``` - -4. You should be able to start the Backstage app now with `yarn dev` diff --git a/client/backstage-backend/app-config.example.yaml b/client/backstage-backend/app-config.example.yaml deleted file mode 100644 index e1365da7a97..00000000000 --- a/client/backstage-backend/app-config.example.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# an example config to use with Backstage -app: - title: Sourcegraph Backstage App - baseUrl: http://localhost:3000 - -organization: - name: Sourcegraph - -sourcegraph: - endpoint: https://sourcegraph.test:3443 - orgId: sourcegraph - token: ${SG_SUDO_TOKEN} - file: - query: "lang:yaml repo:^ghe\\.sgdev\\.org/william/service-catalog$" - grpc: - query: "repo:^github\\.com/sourcegraph/sourcegraph$ file:.proto$" - graphql: - query: "repo:^github\\.com/sourcegraph/sourcegraph$ file:schema\\.graphql" diff --git a/client/backstage-backend/babel.config.js b/client/backstage-backend/babel.config.js deleted file mode 100644 index 5b5dc53092f..00000000000 --- a/client/backstage-backend/babel.config.js +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-check - -/** @type {import('@babel/core').TransformOptions} */ -const config = { - extends: '../../babel.config.js', -} - -module.exports = config diff --git a/client/backstage-backend/jest.config.js b/client/backstage-backend/jest.config.js deleted file mode 100644 index 96ddc6396ff..00000000000 --- a/client/backstage-backend/jest.config.js +++ /dev/null @@ -1,14 +0,0 @@ -// @ts-check -const path = require('path') - -const config = require('../../jest.config.base') - -/** @type {import('@jest/types').Config.InitialOptions} */ -const exportedConfig = { - ...config, - displayName: 'backstage-backend', - rootDir: __dirname, - setupFiles: [...config.setupFiles], -} - -module.exports = exportedConfig diff --git a/client/backstage-backend/package.dist.json b/client/backstage-backend/package.dist.json deleted file mode 100644 index 1a9d6626abd..00000000000 --- a/client/backstage-backend/package.dist.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@sourcegraph/backstage-common", - "description": "Common functionalities for the Sourcegraph plugin. This differs from the base package.json since it lists internal packages which cannot be fetched and are bundled instead.", - "version": "0.1.0", - "main": "index.js", - "types": "types/index.d.ts", - "license": "Apache-2.0", - "private": true, - "publishConfig": { - "access": "public" - }, - "backstage": { - "role": "common-library" - }, - "dependencies": { - "@backstage/catalog-model": "^1.1.5", - "@backstage/config": "^1.0.6", - "@backstage/plugin-catalog-backend": "^1.7.1" - } -} diff --git a/client/backstage-backend/package.json b/client/backstage-backend/package.json deleted file mode 100644 index 71a415339d8..00000000000 --- a/client/backstage-backend/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "@sourcegraph/backstage-backend", - "description": "Common functionalities for the Sourcegraph plugin", - "version": "0.1.0", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "license": "Apache-2.0", - "private": true, - "publishConfig": { - "access": "public", - "main": "dist/index.js", - "module": "dist/index.esm.js", - "types": "dist/index.d.ts" - }, - "backstage": { - "role": "common-library" - }, - "scripts": { - "dist": "ts-node --transpile-only ./scripts/esbuild.ts && pnpm types && cp package.dist.json dist/package.json", - "types": "tsc -d -p tsconfig.json", - "format": "prettier -w true .", - "test": "jest --testPathIgnorePatterns src/tests/integration/", - "e2e": "jest --testPathPattern src/tests/integration/" - }, - "devDependencies": { - "@backstage/cli": "^0.22.1", - "@jest/globals": "^29.4.0", - "@sourcegraph/build-config": "workspace:*", - "@sourcegraph/tsconfig": "^4.0.1", - "babel-jest": "^28.1.3", - "babel-loader": "^9.1.0", - "esbuild": "^0.17.8", - "winston": "^3.8.2" - }, - "dependencies": { - "@backstage/backend-common": "^0.18.1", - "@backstage/catalog-model": "^1.1.5", - "@backstage/config": "^1.0.6", - "@backstage/plugin-catalog-backend": "^1.7.1", - "@sourcegraph/http-client": "workspace:^0.0.1", - "@sourcegraph/shared": "workspace:^1.0.0" - }, - "files": [ - "dist" - ] -} diff --git a/client/backstage-backend/scripts/esbuild.ts b/client/backstage-backend/scripts/esbuild.ts deleted file mode 100644 index b8ae213b56c..00000000000 --- a/client/backstage-backend/scripts/esbuild.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { existsSync } from 'fs' -import path from 'path' - -import * as esbuild from 'esbuild' -import { rm } from 'shelljs' - -import { WORKSPACES_PATH, buildTimerPlugin } from '@sourcegraph/build-config' - -const PACKAGE_ROOT_PATH = path.resolve(WORKSPACES_PATH, 'backstage-frontend') -const DIST_PATH = path.resolve(PACKAGE_ROOT_PATH, 'dist') - -async function build(): Promise { - if (existsSync(DIST_PATH)) { - rm('-rf', DIST_PATH) - } - - await esbuild.build({ - entryPoints: [path.resolve(PACKAGE_ROOT_PATH, 'src', 'index.ts')], - bundle: true, - external: [ - '@backstage/cli', - '@backstage/catalog-model', - '@backstage/config', - '@backstage/backend-common', - '@backstage/plugin-catalog-backend', - 'graphql-request', - 'react', - 'react-dom', - 'lodash', - 'apollo', - 'winston', - ], - // If we don't specify module first, esbuild bundles somethings "incorrectly" and you'll get a error with './impl/format' error - // Most likely due to https://github.com/evanw/esbuild/issues/1619#issuecomment-922787629 - mainFields: ['module', 'main'], - format: 'cjs', - platform: 'node', - define: { - 'process.env.IS_TEST': 'false', - global: 'globalThis', - }, - plugins: [buildTimerPlugin], - ignoreAnnotations: true, - treeShaking: true, - sourcemap: true, - outdir: DIST_PATH, - }) -} - -if (require.main == module) { - build().catch(error => { - console.error('Error:', error) - process.exit(1) - }) -} diff --git a/client/backstage-backend/src/client/Query.test.ts b/client/backstage-backend/src/client/Query.test.ts deleted file mode 100644 index 753baf5714e..00000000000 --- a/client/backstage-backend/src/client/Query.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { describe, expect, test } from '@jest/globals' -import { createService, Config } from './SourcegraphClient' - -const INTEGRATION_TEST = true - -describe.skip('query marshalling', () => { - if (!INTEGRATION_TEST) { - return - } - - const config: Config = { - // TODO(@burmudar): this should be made configurable, even though it is for an integration test - endpoint: 'https://sourcegraph.test:3443', - token: 'SOURCEGRAPH_TOKEN' in process.env ? (process.env['SOURCEGRAPH_TOKEN'] as string) : '', - sudoUsername: 'sourcegraph', - } - - const client = createService(config) - test('check CurrentUser is marshalled', () => { - expect(client.Users.currentUsername).toBe('sourcegraph') - }) - - test('check AuthenticatedUser is marshalled', () => { - expect(client.Users.getAuthenticatedUser()).toBe({}) - }) -}) diff --git a/client/backstage-backend/src/client/Query.ts b/client/backstage-backend/src/client/Query.ts deleted file mode 100644 index a4eb626281a..00000000000 --- a/client/backstage-backend/src/client/Query.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { gql } from '@apollo/client' -import type { DocumentNode } from '@apollo/client' - -export interface Query { - gql(): DocumentNode - vars(): string - marshal(data: any): T -} - -export type SearchResults = Array -export interface SearchResult { - readonly __typename?: string - readonly repository: string - readonly filename?: string - readonly fileContent?: string -} - -export class SearchQuery implements Query { - private readonly query: string - static raw: string = ` - query ($search: String!) { - search(query: $search) { - results { - results { - __typename - ... on FileMatch { - repository { - name - } - file { - name - content - } - } - } - } - } - } - ` - - constructor(query: string) { - this.query = query - } - - marshal(data: any): SearchResults { - const results = new Array() - if (!data.search) { - return results - } - - for (const value of data.search.results.results) { - let filename = '' - let fileContent = '' - if ('file' in value) { - filename = value.file.name - fileContent = value.file.content - } - - results.push({ repository: value.repository.name, filename: filename, fileContent: fileContent }) - } - - return results - } - - vars(): any { - return { search: this.query } - } - - gql(): DocumentNode { - return gql(SearchQuery.raw) - } -} - -export class SearchRepoQuery extends SearchQuery { - static raw: string = ` - query ($search: String!) { - search(query: $search) { - results { - results { - __typename - ... on FileMatch { - repository { - name - } - } - } - } - } - } - ` - - constructor(query: string) { - super(query) - } - - gql(): DocumentNode { - return gql(SearchRepoQuery.raw) - } -} - -export class UserQuery implements Query { - static raw: string = ` - query { - currentUser { - username - } - } - ` - - vars(): any { - return {} - } - - gql(): DocumentNode { - return gql(UserQuery.raw) - } - - marshal(data: any): string { - if ('currentUser' in data) { - const { currentUser } = data - return currentUser.username - } - throw new Error('currentUser field missing') - } -} diff --git a/client/backstage-backend/src/client/SourcegraphClient.test.ts b/client/backstage-backend/src/client/SourcegraphClient.test.ts deleted file mode 100644 index 186b53b9111..00000000000 --- a/client/backstage-backend/src/client/SourcegraphClient.test.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { describe, expect, test } from '@jest/globals' -import { SourcegraphClient, SourcegraphService, BaseClient } from './SourcegraphClient' -import { SearchQuery, SearchRepoQuery, SearchResult, UserQuery } from './Query' -import { createMockClient } from '@apollo/client/testing' - -describe('SourcegraphService', () => { - test('current user query', async () => { - // setup - const data = { - currentUser: { - username: 'william', - }, - } - - const query: UserQuery = new UserQuery() - const base = new BaseClient(createMockClient(data, query.gql())) - let sourcegraphService: SourcegraphService = new SourcegraphClient(base) - // test - const username = await sourcegraphService.Users.currentUsername() - // verify - expect(username).toBe('william') - }) - test('search query with 2 results', async () => { - // setup - const expected: SearchResult[] = [ - { repository: 'repo 1', filename: 'filename-1', fileContent: 'logs of bogus content' }, - { repository: 'repo 1', filename: 'filename-2', fileContent: 'logs of bogus content' }, - ] - const data = { - search: { - results: { - results: [ - { - __typename: 'FileMatch', - repository: { name: expected[0].repository }, - file: { - name: expected[0].filename, - content: expected[0].fileContent, - }, - }, - { - __typename: 'FileMatch', - repository: { name: expected[1].repository }, - file: { - name: expected[1].filename, - content: expected[1].fileContent, - }, - }, - ], - }, - }, - } - - const query: SearchQuery = new SearchQuery('mock query') - const base = new BaseClient(createMockClient(data, query.gql(), query.vars())) - let sourcegraphService: SourcegraphService = new SourcegraphClient(base) - // test - const results: SearchResult[] = await sourcegraphService.Search.searchQuery('mock query') - // verify - expect(results).toEqual(expected) - }) - test('search query with 0 results', async () => { - // setup - const expected: SearchResult[] = [] - const data = { - search: { - results: { - results: [], - }, - }, - } - - const query: SearchQuery = new SearchQuery('mock query') - const base = new BaseClient(createMockClient(data, query.gql(), query.vars())) - let sourcegraphService: SourcegraphService = new SourcegraphClient(base) - // test - const results: SearchResult[] = await sourcegraphService.Search.searchQuery('mock query') - // verify - expect(results).toEqual(expected) - }) - test('search query with only repository names', async () => { - // setup - const expected: SearchResult[] = [ - { repository: 'repo-1', filename: '', fileContent: '' }, - { repository: 'repo-2', filename: '', fileContent: '' }, - ] - const data = { - search: { - results: { - results: [ - { - __typename: 'FileMatch', - repository: { name: 'repo-1' }, - }, - { - __typename: 'FileMatch', - repository: { name: 'repo-2' }, - }, - ], - }, - }, - } - - const query: SearchRepoQuery = new SearchRepoQuery('mock query') - const base = new BaseClient(createMockClient(data, query.gql(), query.vars())) - let sourcegraphService: SourcegraphService = new SourcegraphClient(base) - // test - const results: SearchResult[] = await sourcegraphService.Search.doQuery(query) - // verify - expect(results).toEqual(expected) - }) -}) diff --git a/client/backstage-backend/src/client/SourcegraphClient.ts b/client/backstage-backend/src/client/SourcegraphClient.ts deleted file mode 100644 index c97b05749c9..00000000000 --- a/client/backstage-backend/src/client/SourcegraphClient.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { getGraphQLClient, GraphQLClient } from '@sourcegraph/http-client' -import { generateCache } from '@sourcegraph/shared/src/backend/apolloCache' -import { UserQuery, Query, SearchQuery, SearchResult, SearchResults } from './Query' - -export interface Config { - endpoint: string - token: string - sudoUsername?: string -} - -export interface UserService { - currentUsername(): Promise -} - -export interface SearchService { - searchQuery(query: string): Promise - doQuery(query: Query): Promise -} - -export interface SourcegraphService { - Users: UserService - Search: SearchService -} - -export const createService = async (config: Config): Promise => { - const { endpoint, token, sudoUsername } = config - const base = await BaseClient.create(endpoint, token, sudoUsername || '') - return new SourcegraphClient(base) -} - -export class SourcegraphClient implements SourcegraphService, UserService, SearchService { - private client: BaseClient - Users: UserService = this - Search: SearchService = this - - constructor(client: BaseClient) { - this.client = client - } - - async searchQuery(query: string): Promise { - return await this.doQuery(new SearchQuery(query)) - } - - async doQuery(query: Query): Promise { - return await this.client.fetch(query) - } - - async currentUsername(): Promise { - const q = new UserQuery() - - const result = await this.client.fetch(q) - return result - } -} - -export class BaseClient { - private client: GraphQLClient - - static async create(baseUrl: string, token: string, sudoUsername: string): Promise { - const authz = - sudoUsername?.length > 0 ? `token - sudo user = "${sudoUsername}", token = "${token}"` : `token ${token}` - const headers: RequestInit['headers'] = { - 'X-Requested-With': `Sourcegraph - Backstage plugin DEV`, - Authorization: authz, - } - - try { - const client: GraphQLClient = await getGraphQLClient({ - baseUrl: baseUrl, - headers: headers, - isAuthenticated: true, - cache: generateCache(), - }) - return new BaseClient(client) - } catch (e) { - throw new Error(`failed to create graphsql client: ${e}`) - } - } - constructor(client: GraphQLClient) { - this.client = client - } - - async fetch(query: Query): Promise { - const { data } = await this.client.query({ - query: query.gql(), - variables: query.vars(), - }) - if (!data) { - throw new Error('grapql request failed: no data') - } - return query.marshal(data) - } -} diff --git a/client/backstage-backend/src/client/index.ts b/client/backstage-backend/src/client/index.ts deleted file mode 100644 index d1ea55d71a9..00000000000 --- a/client/backstage-backend/src/client/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { SourcegraphService, createService, createDummySearch, SearchService, UserService } from './SourcegraphClient' -export * from './Query' diff --git a/client/backstage-backend/src/index.ts b/client/backstage-backend/src/index.ts deleted file mode 100644 index 2941491886b..00000000000 --- a/client/backstage-backend/src/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Common functionalities for the sg-common plugin. - * - * @packageDocumentation - */ - -export * from './providers' -export * from './client' diff --git a/client/backstage-backend/src/providers/index.ts b/client/backstage-backend/src/providers/index.ts deleted file mode 100644 index dd77c2839ad..00000000000 --- a/client/backstage-backend/src/providers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { GrpcEntityProvider, YamlFileEntityProvider, GraphQLEntityProvider } from './providers' diff --git a/client/backstage-backend/src/providers/parsers.ts b/client/backstage-backend/src/providers/parsers.ts deleted file mode 100644 index 58887727561..00000000000 --- a/client/backstage-backend/src/providers/parsers.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { ANNOTATION_LOCATION, ANNOTATION_ORIGIN_LOCATION, ApiEntity } from '@backstage/catalog-model' -import { CatalogProcessorEntityResult, DeferredEntity, parseEntityYaml } from '@backstage/plugin-catalog-backend' -import { SearchResult } from '../client' -import type { EntityType } from './providers' - -export type ParserFunction = (results: SearchResult[], providerName: string) => DeferredEntity[] - -const apiEntityDefinitionParser = ( - searchResults: SearchResult[], - providerName: string, - entityType: EntityType -): DeferredEntity[] => { - const results: DeferredEntity[] = [] - - // TODO(@burmudar): remove - only temporary - console.log(`parsing ${searchResults.length} proto results`) - searchResults.forEach((r: SearchResult) => { - const location = { - type: 'url', - target: `${r.repository}/${r.filename}`, - } - const definition = Buffer.from(r.fileContent, 'utf8').toString() - const entity: ApiEntity = { - kind: 'API', - apiVersion: 'backstage.io/v1alpha1', - metadata: { - name: r.filename, - annotations: { - [ANNOTATION_LOCATION]: `url:${location.target}`, - [ANNOTATION_ORIGIN_LOCATION]: providerName, - }, - }, - spec: { - type: entityType, - lifecycle: 'production', - owner: 'engineering', - definition: definition, - }, - } - results.push({ - entity: entity, - locationKey: `https://${location.target}`, - }) - }) - - console.log(`${results.length} ${entityType} entities`) - return results -} - -export const parseCatalogContent: ParserFunction = ( - searchResults: SearchResult[], - providerName: string -): DeferredEntity[] => { - const results: DeferredEntity[] = [] - - searchResults.forEach((r: SearchResult) => { - const location = { - type: 'url', - target: `https://${r.repository}/${r.filename}`, - } - const yaml = Buffer.from(r.fileContent, 'utf8') - - for (const item of parseEntityYaml(yaml, location)) { - const parsed = item as CatalogProcessorEntityResult - results.push({ - entity: { - ...parsed.entity, - metadata: { - ...parsed.entity.metadata, - annotations: { - ...parsed.entity.metadata.annotations, - [ANNOTATION_LOCATION]: `url:${parsed.location.target}`, - [ANNOTATION_ORIGIN_LOCATION]: providerName, - }, - }, - }, - locationKey: parsed.location.target, - }) - } - }) - return results -} - -const apiEntityParser = - (type: EntityType): ParserFunction => - (src: SearchResult[], providerName: string): DeferredEntity[] => - apiEntityDefinitionParser(src, providerName, type) - -export const parserForType = (entityType: EntityType): ParserFunction => { - if (entityType === 'file') { - return parseCatalogContent - } else if (entityType === 'grpc' || entityType === 'graphql') { - return apiEntityParser(entityType) - } else { - throw new Error(`unknown Entity Type: ${entityType}`) - } -} diff --git a/client/backstage-backend/src/providers/providers.ts b/client/backstage-backend/src/providers/providers.ts deleted file mode 100644 index 38feace55e5..00000000000 --- a/client/backstage-backend/src/providers/providers.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { Config } from '@backstage/config' -import { SearchService, createService } from '../client' -import { parserForType, ParserFunction } from './parsers' -import { EntityProvider, EntityProviderConnection } from '@backstage/plugin-catalog-backend' - -export type EntityType = 'file' | 'grpc' | 'graphql' - -abstract class BaseEntityProvider implements EntityProvider { - private connection?: EntityProviderConnection - private sourcegraph?: SearchService - private query: string - private endpoint: string - private disabled: boolean = false - private readonly entityType: EntityType - private entityParseFn: ParserFunction - - protected constructor(config: Config, entityType: EntityType) { - const token = config.getString('sourcegraph.token') - const sudoUsername = config.getOptionalString('sourcegraph.sudoUsername') - const queryConfig = config.getConfig(`sourcegraph.${entityType}`) - - this.endpoint = config.getString('sourcegraph.endpoint') - this.entityType = entityType - this.entityParseFn = parserForType(entityType) - this.query = queryConfig.getOptionalString('query') ?? '' - - this.disabled = this.query == '' - if (!this.disabled) { - createService({ endpoint: this.endpoint, token, sudoUsername }).then( - service => (this.sourcegraph = service.Search) - ) - } else { - console.error("query '' is invalid - provider will be in disabled state") - } - } - - getProviderName(): string { - return `url: ${this.endpoint}/sourcegraph-${this.entityType}-entity-provider` - } - - async connect(connection: EntityProviderConnection): Promise { - this.connection = connection - } - - async run(): Promise { - if (!this.connection) { - throw new Error('connection not initialized') - } - - await this.fullMutation() - } - - async fullMutation() { - // TODO(@burmudar): remove - only temporary - if (this.disabled) { - console.log(`${this.getProviderName} is disabled`) - return - } - const results = await this.sourcegraph?.searchQuery(this.query) - console.log(`${results?.length} items matched query ${this.query}`) - - const entities = this.entityParseFn(results ?? [], this.getProviderName()) - - await this.connection?.applyMutation({ - type: 'full', - entities: entities, - }) - } -} - -export class GrpcEntityProvider extends BaseEntityProvider { - constructor(config: Config) { - super(config, 'grpc') - } -} - -export class GraphQLEntityProvider extends BaseEntityProvider { - constructor(config: Config) { - super(config, 'graphql') - } -} - -export class YamlFileEntityProvider extends BaseEntityProvider { - constructor(config: Config) { - super(config, 'file') - } -} diff --git a/client/backstage-backend/src/setupTests.ts b/client/backstage-backend/src/setupTests.ts deleted file mode 100644 index 2e116e85d55..00000000000 --- a/client/backstage-backend/src/setupTests.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Need an empty export to make it a module tsc complains about the empty file -export {} diff --git a/client/backstage-backend/src/tests/integration/e2e.test.ts b/client/backstage-backend/src/tests/integration/e2e.test.ts deleted file mode 100644 index db404e7dd21..00000000000 --- a/client/backstage-backend/src/tests/integration/e2e.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { describe, expect, test } from '@jest/globals' -import { createService, Config, SourcegraphService } from '../../client/SourcegraphClient' - -const sgConf: Config = { - endpoint: 'https://scaletesting.sgdev.org', - token: process.env.SG_TOKEN ?? '', -} - -describe('integration test against dotCom', async () => { - const sourcegraphService: SourcegraphService = await createService(sgConf) - test('check current user', async () => { - const username: string = await sourcegraphService.Users.currentUsername() - console.log(username) - expect(username).toBe('burmudar') - }) -}) diff --git a/client/backstage-backend/tsconfig.json b/client/backstage-backend/tsconfig.json deleted file mode 100644 index bcc050cd4a5..00000000000 --- a/client/backstage-backend/tsconfig.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - "target": "es2020", - "lib": ["esnext", "DOM", "DOM.Iterable"], - "sourceMap": true, - "sourceRoot": "src", - "baseUrl": "./src", - "paths": { - "@sourcegraph/*": ["../*"], - "*": ["types/*", "../../shared/src/types/*", "../../common/src/types/*", "*"], - }, - "esModuleInterop": true, - "resolveJsonModule": true, - "strict": true, - "jsx": "react-jsx", - "declaration": true, - "outDir": "dist/types", - "rootDir": "./src", - }, - "references": [ - { - "path": "../build-config", - }, - { - "path": "../http-client", - }, - { - "path": "../shared", - }, - ], - "include": ["**/*", "**/*.d.ts"], - "exclude": ["node_modules", "../../node_modules", "dist", "**/*.test.ts", "scripts"], -} diff --git a/client/backstage-frontend/.eslintrc.js b/client/backstage-frontend/.eslintrc.js deleted file mode 100644 index fb6648fb1af..00000000000 --- a/client/backstage-frontend/.eslintrc.js +++ /dev/null @@ -1,12 +0,0 @@ -const baseConfig = require('../../.eslintrc') -module.exports = { - extends: '../../.eslintrc.js', - parserOptions: { - ...baseConfig.parserOptions, - project: [__dirname + '/tsconfig.json'], - }, - rules: { - 'no-console': 'off', - }, - overrides: baseConfig.overrides, -} diff --git a/client/backstage-frontend/.gitignore b/client/backstage-frontend/.gitignore deleted file mode 100644 index 42e3cf6150f..00000000000 --- a/client/backstage-frontend/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -dist -dev/ -!dev/index.tsx diff --git a/client/backstage-frontend/.prettierignore b/client/backstage-frontend/.prettierignore deleted file mode 100644 index ac029fb7b98..00000000000 --- a/client/backstage-frontend/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -dist/ -dev/* -!dev/*.tsx diff --git a/client/backstage-frontend/BUILD.bazel b/client/backstage-frontend/BUILD.bazel deleted file mode 100644 index e414715503e..00000000000 --- a/client/backstage-frontend/BUILD.bazel +++ /dev/null @@ -1,61 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_config") -load("@npm//:defs.bzl", "npm_link_all_packages") -load("//dev:defs.bzl", "ts_project") - -npm_link_all_packages(name = "node_modules") - -ts_config( - name = "tsconfig", - src = "tsconfig.json", - visibility = ["//client:__subpackages__"], - deps = [ - "//:tsconfig", - "//client/build-config:tsconfig", - ], -) - -ts_project( - name = "backstage-frontend", - srcs = [ - "src/components/ExampleComponent/ExampleComponent.tsx", - "src/components/ExampleComponent/index.ts", - "src/components/ExampleFetchComponent/ExampleFetchComponent.tsx", - "src/components/ExampleFetchComponent/index.ts", - "src/index.ts", - "src/plugin.ts", - "src/routes.ts", - "src/setupTests.ts", - ], - tsconfig = ":tsconfig", - deps = [ - ":node_modules/@backstage/core-components", - ":node_modules/@backstage/core-plugin-api", - ":node_modules/@material-ui/core", - ":node_modules/@material-ui/lab", - ":node_modules/@testing-library/jest-dom", - ":node_modules/cross-fetch", - ":node_modules/react", - ":node_modules/react-use", - "//:node_modules/@types/react", #keep - "//:node_modules/@types/testing-library__jest-dom", - ], -) - -ts_project( - name = "backstage-frontend_tests", - testonly = True, - srcs = [ - "src/components/ExampleComponent/ExampleComponent.test.tsx", - "src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx", - "src/plugin.test.ts", - ], - tsconfig = ":tsconfig", - deps = [ - ":backstage-frontend", - ":node_modules/@backstage/test-utils", - ":node_modules/@testing-library/react", - ":node_modules/msw", - ":node_modules/react", - "//:node_modules/@types/react", - ], -) diff --git a/client/backstage-frontend/README.md b/client/backstage-frontend/README.md deleted file mode 100644 index 3e13fab4838..00000000000 --- a/client/backstage-frontend/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Sourcegraph Backstage Frontend (WIP) - -Welcome to the Sourcegraph Backstage Frontend plugin! - -_This plugin was created through the Backstage CLI_ - -## NOTE - -This plugin is still very much in development as is a work in progress. For any questions please ask in #job-fair-backstage or dm @William Bezuidenhout - -## Getting started - -Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/sourcegraph](http://localhost:3000/sourcegraph). - -You can also serve the plugin in isolation by running `yarn start` in the plugin directory. -This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. -It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory. diff --git a/client/backstage-frontend/babel.config.js b/client/backstage-frontend/babel.config.js deleted file mode 100644 index 5b5dc53092f..00000000000 --- a/client/backstage-frontend/babel.config.js +++ /dev/null @@ -1,8 +0,0 @@ -// @ts-check - -/** @type {import('@babel/core').TransformOptions} */ -const config = { - extends: '../../babel.config.js', -} - -module.exports = config diff --git a/client/backstage-frontend/dev/index.tsx b/client/backstage-frontend/dev/index.tsx deleted file mode 100644 index 8a32fa5bbe9..00000000000 --- a/client/backstage-frontend/dev/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react' -import { createDevApp } from '@backstage/dev-utils' -import { sourcegraphPlugin, SourcegraphPage } from '../src/plugin' - -createDevApp() - .registerPlugin(sourcegraphPlugin) - .addPage({ - element: , - title: 'Root Page', - path: '/william', - }) - .render() diff --git a/client/backstage-frontend/package.dist.json b/client/backstage-frontend/package.dist.json deleted file mode 100644 index 0d9e049ff2e..00000000000 --- a/client/backstage-frontend/package.dist.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@sourcegraph/backstage-frontend", - "description": "The Sourcegraph frontend plugin for Backstage", - "version": "0.1.0", - "main": "index.js", - "types": "types/src/index.d.ts", - "module": "index.js", - "license": "Apache-2.0", - "private": true, - "publishConfig": { - "access": "public" - }, - "backstage": { - "role": "frontend-library" - }, - "dependencies": { - "@backstage/core-components": "^0.12.3", - "@backstage/core-plugin-api": "^1.3.0", - "@backstage/theme": "^0.2.16", - "@material-ui/core": "^4.9.13", - "@material-ui/icons": "^4.9.1", - "@material-ui/lab": "4.0.0-alpha.57", - "react": "^17.0.0", - "react-dom": "^17.0.0", - "react-use": "^17.2.4" - } -} diff --git a/client/backstage-frontend/package.json b/client/backstage-frontend/package.json deleted file mode 100644 index 93513c5b300..00000000000 --- a/client/backstage-frontend/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "@sourcegraph/backstage-frontend", - "version": "0.1.0", - "main": "dist/index.ts", - "types": "dist/types/index.d.ts", - "license": "Apache-2.0", - "private": true, - "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" - }, - "backstage": { - "role": "frontend-plugin" - }, - "scripts": { - "dist": "ts-node --transpile-only ./scripts/esbuild.ts && pnpm types && cp package.dist.json dist/package.json", - "types": "tsc -d -p tsconfig.json", - "format": "prettier -w true .", - "test": "jest" - }, - "dependencies": { - "@backstage/core-components": "^0.12.3", - "@backstage/core-plugin-api": "^1.3.0", - "@backstage/theme": "^0.2.16", - "@material-ui/core": "^4.9.13", - "@material-ui/icons": "^4.9.1", - "@material-ui/lab": "4.0.0-alpha.57", - "react": "^17.0.0", - "react-dom": "^17.0.0", - "react-use": "^17.2.4" - }, - "peerDependencies": { - "react": "^16.13.1 || ^17.0.0" - }, - "devDependencies": { - "@backstage/cli": "^0.22.1", - "@backstage/core-app-api": "^1.4.0", - "@backstage/dev-utils": "^1.0.11", - "@backstage/test-utils": "^1.2.4", - "@sourcegraph/build-config": "workspace:^0.0.1", - "@sourcegraph/tsconfig": "^4.0.1", - "@testing-library/jest-dom": "^5.10.1", - "@testing-library/react": "^12.1.3", - "@testing-library/user-event": "^14.0.0", - "@types/node": "*", - "babel-jest": "^28.1.3", - "babel-loader": "^9.1.0", - "cross-fetch": "^3.1.5", - "esbuild": "^0.17.8", - "esbuild-node-externals": "^1.6.0", - "msw": "^0.49.0" - }, - "files": [ - "dist" - ] -} diff --git a/client/backstage-frontend/scripts/esbuild.ts b/client/backstage-frontend/scripts/esbuild.ts deleted file mode 100644 index 754dc2da7c9..00000000000 --- a/client/backstage-frontend/scripts/esbuild.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { existsSync } from 'fs' -import path from 'path' -import { nodeExternalsPlugin } from 'esbuild-node-externals' - -import * as esbuild from 'esbuild' -import { rm } from 'shelljs' - -import { stylePlugin, workerPlugin, buildTimerPlugin, WORKSPACES_PATH } from '@sourcegraph/build-config' - -const PACKAGE_ROOT_PATH = path.resolve(WORKSPACES_PATH, 'backstage-frontend') -const DIST_PATH = path.resolve(PACKAGE_ROOT_PATH, 'dist') - -async function build(): Promise { - if (existsSync(DIST_PATH)) { - rm('-rf', DIST_PATH) - } - - await esbuild.build({ - entryPoints: [path.resolve(PACKAGE_ROOT_PATH, 'src', 'index.ts')], - bundle: true, - format: 'esm', - logLevel: 'error', - jsx: 'automatic', - external: ['@backstage/*', '@material-ui/*', 'react-use', 'react', 'react-dom'], - plugins: [stylePlugin, workerPlugin, buildTimerPlugin, nodeExternalsPlugin()], - // mainFields: ['browser', 'module', 'main'], - // platform: 'browser', - define: { - 'process.env.IS_TEST': 'false', - global: 'window', - }, - loader: { - '.yaml': 'text', - '.ttf': 'file', - '.png': 'file', - }, - treeShaking: true, - target: 'esnext', - sourcemap: true, - outdir: DIST_PATH, - }) -} - -if (require.main == module) { - build() - .catch(error => console.error('Error:', error)) - .finally(() => process.exit(0)) -} diff --git a/client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.test.tsx b/client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.test.tsx deleted file mode 100644 index a5098e885a6..00000000000 --- a/client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.test.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react' -import { ExampleComponent } from './ExampleComponent' -import { rest } from 'msw' -import { setupServer } from 'msw/node' -import { screen } from '@testing-library/react' -import { setupRequestMockHandlers, renderInTestApp } from '@backstage/test-utils' - -describe('ExampleComponent', () => { - const server = setupServer() - // Enable sane handlers for network requests - setupRequestMockHandlers(server) - - // setup mock response - beforeEach(() => { - server.use(rest.get('/*', (_, res, ctx) => res(ctx.status(200), ctx.json({})))) - }) - - it('should render', async () => { - await renderInTestApp() - expect(screen.getByText('Welcome to Sourcgraph!')).toBeInTheDocument() - }) -}) diff --git a/client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.tsx b/client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.tsx deleted file mode 100644 index a9f884a4e6b..00000000000 --- a/client/backstage-frontend/src/components/ExampleComponent/ExampleComponent.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react' -import { Typography, Grid } from '@material-ui/core' -import { InfoCard, Header, Page, Content, ContentHeader, HeaderLabel, SupportButton } from '@backstage/core-components' -import { ExampleFetchComponent } from '../ExampleFetchComponent' - -export const ExampleComponent = () => ( - -
- - -
- - - A description of your plugin goes here. - - - - - All content should be wrapped in a card like this. - - - - - - - -
-) diff --git a/client/backstage-frontend/src/components/ExampleComponent/index.ts b/client/backstage-frontend/src/components/ExampleComponent/index.ts deleted file mode 100644 index 8b981ff4b30..00000000000 --- a/client/backstage-frontend/src/components/ExampleComponent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ExampleComponent } from './ExampleComponent' diff --git a/client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx b/client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx deleted file mode 100644 index a027525e0e6..00000000000 --- a/client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.test.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react' -import { render, screen } from '@testing-library/react' -import { ExampleFetchComponent } from './ExampleFetchComponent' -import { rest } from 'msw' -import { setupServer } from 'msw/node' -import { setupRequestMockHandlers } from '@backstage/test-utils' - -describe('ExampleFetchComponent', () => { - const server = setupServer() - // Enable sane handlers for network requests - setupRequestMockHandlers(server) - - // setup mock response - beforeEach(() => { - server.use( - rest.get('https://randomuser.me/*', (_, res, ctx) => res(ctx.status(200), ctx.delay(2000), ctx.json({}))) - ) - }) - it('should render', async () => { - await render() - expect(await screen.findByTestId('progress')).toBeInTheDocument() - }) -}) diff --git a/client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx b/client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx deleted file mode 100644 index 1eec81c6aa3..00000000000 --- a/client/backstage-frontend/src/components/ExampleFetchComponent/ExampleFetchComponent.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import React from 'react' -import { makeStyles } from '@material-ui/core/styles' -import { Table, TableColumn, Progress } from '@backstage/core-components' -import Alert from '@material-ui/lab/Alert' -import useAsync from 'react-use/lib/useAsync' - -const useStyles = makeStyles({ - avatar: { - height: 32, - width: 32, - borderRadius: '50%', - }, -}) - -type User = { - gender: string // "male" - name: { - title: string // "Mr", - first: string // "Duane", - last: string // "Reed" - } - location: object // {street: {number: 5060, name: "Hickory Creek Dr"}, city: "Albany", state: "New South Wales",…} - email: string // "duane.reed@example.com" - login: object // {uuid: "4b785022-9a23-4ab9-8a23-cb3fb43969a9", username: "blackdog796", password: "patch",…} - dob: object // {date: "1983-06-22T12:30:23.016Z", age: 37} - registered: object // {date: "2006-06-13T18:48:28.037Z", age: 14} - phone: string // "07-2154-5651" - cell: string // "0405-592-879" - id: { - name: string // "TFN", - value: string // "796260432" - } - picture: { medium: string } // {medium: "https://randomuser.me/api/portraits/men/95.jpg",…} - nat: string // "AU" -} - -type DenseTableProps = { - users: User[] -} - -export const DenseTable = ({ users }: DenseTableProps) => { - const classes = useStyles() - - const columns: TableColumn[] = [ - { title: 'Avatar', field: 'avatar' }, - { title: 'Name', field: 'name' }, - { title: 'Email', field: 'email' }, - { title: 'Nationality', field: 'nationality' }, - ] - - const data = users.map(user => { - return { - avatar: {user.name.first}, - name: `${user.name.first} ${user.name.last}`, - email: user.email, - nationality: user.nat, - } - }) - - return ( - - ) -} - -export const ExampleFetchComponent = () => { - const { value, loading, error } = useAsync(async (): Promise => { - const response = await fetch('https://randomuser.me/api/?results=20') - const data = await response.json() - return data.results - }, []) - - if (loading) { - return - } else if (error) { - return {error.message} - } - - return -} diff --git a/client/backstage-frontend/src/components/ExampleFetchComponent/index.ts b/client/backstage-frontend/src/components/ExampleFetchComponent/index.ts deleted file mode 100644 index 1900c4b62e3..00000000000 --- a/client/backstage-frontend/src/components/ExampleFetchComponent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ExampleFetchComponent } from './ExampleFetchComponent' diff --git a/client/backstage-frontend/src/index.ts b/client/backstage-frontend/src/index.ts deleted file mode 100644 index 90bd376a28b..00000000000 --- a/client/backstage-frontend/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { sourcegraphPlugin, SourcegraphPage } from './plugin' diff --git a/client/backstage-frontend/src/plugin.test.ts b/client/backstage-frontend/src/plugin.test.ts deleted file mode 100644 index 32f11953f1d..00000000000 --- a/client/backstage-frontend/src/plugin.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { sourcegraphPlugin } from './plugin' - -describe('sourcegraph', () => { - it('should export plugin', () => { - expect(sourcegraphPlugin).toBeDefined() - }) -}) diff --git a/client/backstage-frontend/src/plugin.ts b/client/backstage-frontend/src/plugin.ts deleted file mode 100644 index 9358f841efc..00000000000 --- a/client/backstage-frontend/src/plugin.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { createPlugin, createRoutableExtension } from '@backstage/core-plugin-api' - -import { rootRouteRef } from './routes' - -export const sourcegraphPlugin = createPlugin({ - id: 'sourcegraph', - routes: { - root: rootRouteRef, - }, -}) - -export const SourcegraphPage = sourcegraphPlugin.provide( - createRoutableExtension({ - name: 'SourcegraphPage', - component: () => import('./components/ExampleComponent').then(m => m.ExampleComponent), - mountPoint: rootRouteRef, - }) -) diff --git a/client/backstage-frontend/src/routes.ts b/client/backstage-frontend/src/routes.ts deleted file mode 100644 index 3b82e1f0677..00000000000 --- a/client/backstage-frontend/src/routes.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createRouteRef } from '@backstage/core-plugin-api' - -export const rootRouteRef = createRouteRef({ - id: 'sourcegraph', -}) diff --git a/client/backstage-frontend/src/setupTests.ts b/client/backstage-frontend/src/setupTests.ts deleted file mode 100644 index cb0286f65da..00000000000 --- a/client/backstage-frontend/src/setupTests.ts +++ /dev/null @@ -1,2 +0,0 @@ -import '@testing-library/jest-dom' -import 'cross-fetch/polyfill' diff --git a/client/backstage-frontend/tsconfig.json b/client/backstage-frontend/tsconfig.json deleted file mode 100644 index 9014cee909a..00000000000 --- a/client/backstage-frontend/tsconfig.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - "target": "es2020", - "sourceMap": true, - "sourceRoot": "src", - "baseUrl": ".", - "paths": { - "@sourcegraph/*": ["../*"], - "*": ["types/*", "../../shared/src/types/*", "../../common/src/types/*", "*"], - }, - "resolveJsonModule": true, - "jsx": "react", - "declaration": true, - "outDir": "dist/types", - "rootDir": ".", - }, - "references": [ - { - "path": "../build-config", - }, - ], - "include": ["**/*", ".*", "./src/**/*.json"], - "exclude": ["node_modules", "../../node_modules", "dist", "**/*.test.ts", "scripts"], - "ts-node": { - "moduleTypes": { - "scripts/**/*": "cjs", - }, - }, -} diff --git a/client/web/BUILD.bazel b/client/web/BUILD.bazel index b3d1fa8a3a5..6d21831de51 100644 --- a/client/web/BUILD.bazel +++ b/client/web/BUILD.bazel @@ -264,6 +264,8 @@ ts_project( "src/components/externalServices/AddExternalServicesPage.tsx", "src/components/externalServices/ExternalServiceCard.tsx", "src/components/externalServices/ExternalServiceEditPage.tsx", + "src/components/externalServices/ExternalServiceEditingAppLimitInPlaceAlert.tsx", + "src/components/externalServices/ExternalServiceEditingAppLimitReachedAlert.tsx", "src/components/externalServices/ExternalServiceEditingDisabledAlert.tsx", "src/components/externalServices/ExternalServiceEditingTemporaryAlert.tsx", "src/components/externalServices/ExternalServiceForm.tsx", @@ -278,6 +280,7 @@ ts_project( "src/components/externalServices/backend.ts", "src/components/externalServices/externalServices.tsx", "src/components/externalServices/index.ts", + "src/components/externalServices/isAppLocalFileService.ts", "src/components/fuzzyFinder/FuzzyActions.tsx", "src/components/fuzzyFinder/FuzzyFiles.tsx", "src/components/fuzzyFinder/FuzzyFinder.mocks.tsx", @@ -532,12 +535,20 @@ ts_project( "src/enterprise/codeintel/configuration/components/EmptyPoliciesList.tsx", "src/enterprise/codeintel/configuration/components/FlashMessage.tsx", "src/enterprise/codeintel/configuration/components/IndexConfigurationSaveToolbar.tsx", - "src/enterprise/codeintel/configuration/components/InferenceScriptEditor.tsx", "src/enterprise/codeintel/configuration/components/RepositoryPatternList.tsx", + "src/enterprise/codeintel/configuration/components/inference-form/CommandInput.tsx", + "src/enterprise/codeintel/configuration/components/inference-form/IndexJobLabel.tsx", + "src/enterprise/codeintel/configuration/components/inference-form/IndexJobNode.tsx", + "src/enterprise/codeintel/configuration/components/inference-form/InferenceForm.tsx", + "src/enterprise/codeintel/configuration/components/inference-form/auto-index-to-form-job.ts", + "src/enterprise/codeintel/configuration/components/inference-form/form-data-to-schema.ts", + "src/enterprise/codeintel/configuration/components/inference-form/types.ts", + "src/enterprise/codeintel/configuration/components/inference-script/InferenceScriptEditor.tsx", + "src/enterprise/codeintel/configuration/components/inference-script/InferenceScriptPreview.tsx", + "src/enterprise/codeintel/configuration/components/inference-script/backend.ts", "src/enterprise/codeintel/configuration/hooks/queryPolicies.tsx", "src/enterprise/codeintel/configuration/hooks/types.tsx", "src/enterprise/codeintel/configuration/hooks/useDeletePolicies.tsx", - "src/enterprise/codeintel/configuration/hooks/useInferJobs.tsx", "src/enterprise/codeintel/configuration/hooks/useInferenceScript.tsx", "src/enterprise/codeintel/configuration/hooks/useInferredConfig.tsx", "src/enterprise/codeintel/configuration/hooks/usePolicyConfigurationById.tsx", @@ -1282,6 +1293,7 @@ ts_project( "src/settings/tokens/AccessTokenNode.tsx", "src/setup-wizard/SetupWizard.tsx", "src/setup-wizard/components/ProgressBar.tsx", + "src/setup-wizard/components/SyncRepositoriesStep.tsx", "src/setup-wizard/components/remote-repositories-step/RemoteRepositoriesStep.tsx", "src/setup-wizard/components/remote-repositories-step/components/CodeHostExternalServiceAlert.tsx", "src/setup-wizard/components/remote-repositories-step/components/code-host-delete-modal/CodeHostDeleteModal.tsx", @@ -1526,6 +1538,7 @@ ts_project( ":graphql_operations", ":module_style_typings", ":node_modules/@sourcegraph/branded", + ":node_modules/@sourcegraph/client-api", #keep ":node_modules/@sourcegraph/codeintellify", ":node_modules/@sourcegraph/common", ":node_modules/@sourcegraph/extension-api-types", #keep @@ -1538,6 +1551,7 @@ ts_project( "//:node_modules/@codemirror/lang-json", "//:node_modules/@codemirror/lang-markdown", "//:node_modules/@codemirror/language", + "//:node_modules/@codemirror/legacy-modes", "//:node_modules/@codemirror/search", "//:node_modules/@codemirror/state", "//:node_modules/@codemirror/view", @@ -1559,6 +1573,7 @@ ts_project( "//:node_modules/@reach/visually-hidden", "//:node_modules/@sentry/browser", #keep "//:node_modules/@sourcegraph/extension-api-classes", + "//:node_modules/@storybook/client-api", #keep "//:node_modules/@types/bloomfilter", "//:node_modules/@types/chrome", #keep "//:node_modules/@types/classnames", @@ -1674,6 +1689,10 @@ ts_project( "src/enterprise/code-monitoring/components/actions/EmailAction.test.tsx", "src/enterprise/code-monitoring/components/actions/SlackWebhookAction.test.tsx", "src/enterprise/code-monitoring/components/actions/WebhookAction.test.tsx", + "src/enterprise/codeintel/configuration/components/inference-form/auto-index-to-schema.test.ts", + + # TODO(bazel): should not be here. Caused by the issue in `rules_js`. + "src/enterprise/codeintel/configuration/schema.json", #keep "src/enterprise/insights/components/creation-ui/code-insight-time-step-picker/get-interval-descrtiption-text/get-interval-description.text.test.ts", "src/enterprise/insights/hooks/use-parallel-requests/use-prallel-requests.test.ts", "src/enterprise/insights/pages/CodeInsightsRootPage.test.tsx", @@ -1768,6 +1787,8 @@ ts_project( "//:node_modules/@types/react-dom", "//:node_modules/@types/semver", "//:node_modules/@types/sinon", + "//:node_modules/ajv", + "//:node_modules/ajv-formats", "//:node_modules/date-fns", "//:node_modules/delay", "//:node_modules/history", @@ -1905,6 +1926,6 @@ build_test( name = "webpack_test", targets = [ ":bundle", - ":bundle-dev", + ":bundle-enterprise", ], ) diff --git a/client/web/dev/BUILD.bazel b/client/web/dev/BUILD.bazel index 461c9cc7672..f0a9a862b65 100644 --- a/client/web/dev/BUILD.bazel +++ b/client/web/dev/BUILD.bazel @@ -20,9 +20,6 @@ ts_config( ts_project( name = "dev", srcs = [ - "esbuild/build.ts", - "esbuild/manifestPlugin.ts", - "esbuild/server.ts", "mocks/mockEventLogger.ts", "server/production.server.ts", "utils/constants.ts", @@ -48,7 +45,6 @@ ts_project( "//:node_modules/chalk", "//:node_modules/compression", "//:node_modules/connect-history-api-fallback", - "//:node_modules/esbuild", "//:node_modules/express", "//:node_modules/express-static-gzip", "//:node_modules/http-proxy-middleware", @@ -57,7 +53,6 @@ ts_project( "//:node_modules/signale", "//:node_modules/webpack", #keep "//client/web:node_modules/@sourcegraph/build-config", - "//client/web:node_modules/@sourcegraph/common", "//client/web:web_lib", #keep ], ) diff --git a/client/web/dev/esbuild/BUILD.bazel b/client/web/dev/esbuild/BUILD.bazel new file mode 100644 index 00000000000..88a786fb104 --- /dev/null +++ b/client/web/dev/esbuild/BUILD.bazel @@ -0,0 +1,4 @@ +# TODO(bazel): esbuild dev tools currently disabled in bazel +# See client/build-config/src/esbuild/BUILD.bazel + +# gazelle:js disabled diff --git a/client/web/src/components/externalServices/ExternalServiceNode.tsx.tsx b/client/web/src/components/externalServices/ExternalServiceNode.tsx similarity index 100% rename from client/web/src/components/externalServices/ExternalServiceNode.tsx.tsx rename to client/web/src/components/externalServices/ExternalServiceNode.tsx diff --git a/client/web/src/components/externalServices/ExternalServicesPage.tsx b/client/web/src/components/externalServices/ExternalServicesPage.tsx index b1f496239a7..34da6a30778 100644 --- a/client/web/src/components/externalServices/ExternalServicesPage.tsx +++ b/client/web/src/components/externalServices/ExternalServicesPage.tsx @@ -21,7 +21,7 @@ import { useExternalServicesConnection } from './backend' import { ExternalServiceEditingAppLimitAlert } from './ExternalServiceEditingAppLimitReachedAlert' import { ExternalServiceEditingDisabledAlert } from './ExternalServiceEditingDisabledAlert' import { ExternalServiceEditingTemporaryAlert } from './ExternalServiceEditingTemporaryAlert' -import { ExternalServiceNode } from './ExternalServiceNode.tsx' +import { ExternalServiceNode } from './ExternalServiceNode' import { isAppLocalFileService } from './isAppLocalFileService' interface Props extends TelemetryProps { diff --git a/cmd/frontend/enterprise/BUILD.bazel b/cmd/frontend/enterprise/BUILD.bazel index 46998350a67..86a394981df 100644 --- a/cmd/frontend/enterprise/BUILD.bazel +++ b/cmd/frontend/enterprise/BUILD.bazel @@ -13,7 +13,6 @@ go_library( "//internal/auth", "//internal/codeintel/types", "//internal/conf", - "//internal/conf/deploy", "//internal/database", "//internal/search/job/jobutil", ], diff --git a/cmd/frontend/graphqlbackend/BUILD.bazel b/cmd/frontend/graphqlbackend/BUILD.bazel index 54c81ef9513..1f6a9e5c061 100644 --- a/cmd/frontend/graphqlbackend/BUILD.bazel +++ b/cmd/frontend/graphqlbackend/BUILD.bazel @@ -93,6 +93,7 @@ go_library( "outbound_webhook_logs.go", "outbound_webhooks.go", "own.go", + "package_repo_filters.go", "package_repos.go", "parse_search_query.go", "permissions_sync_jobs.go", @@ -213,6 +214,7 @@ go_library( "//internal/binary", "//internal/cloneurls", "//internal/codeintel/dependencies", + "//internal/codeintel/dependencies/shared", "//internal/codeintel/resolvers", "//internal/conf", "//internal/conf/conftypes", diff --git a/cmd/frontend/internal/app/jscontext/BUILD.bazel b/cmd/frontend/internal/app/jscontext/BUILD.bazel index fca84bbf520..a7f1ab8657f 100644 --- a/cmd/frontend/internal/app/jscontext/BUILD.bazel +++ b/cmd/frontend/internal/app/jscontext/BUILD.bazel @@ -22,6 +22,7 @@ go_library( "//internal/database", "//internal/env", "//internal/lazyregexp", + "//internal/singleprogram/filepicker", "//internal/types", "//internal/version", "//schema", diff --git a/cmd/frontend/internal/auth/userpasswd/BUILD.bazel b/cmd/frontend/internal/auth/userpasswd/BUILD.bazel index 42df5eff224..b0ea6a08658 100644 --- a/cmd/frontend/internal/auth/userpasswd/BUILD.bazel +++ b/cmd/frontend/internal/auth/userpasswd/BUILD.bazel @@ -64,6 +64,10 @@ go_test( "verify_email_test.go", ], embed = [":userpasswd"], + tags = [ + # requires localhost database + "requires-network", + ], deps = [ "//cmd/frontend/backend", "//cmd/frontend/internal/session", diff --git a/cmd/frontend/internal/bg/BUILD.bazel b/cmd/frontend/internal/bg/BUILD.bazel index 4c9d23c279f..a5469fd7971 100644 --- a/cmd/frontend/internal/bg/BUILD.bazel +++ b/cmd/frontend/internal/bg/BUILD.bazel @@ -21,6 +21,7 @@ go_library( "//internal/redispool", "//internal/types", "//lib/errors", + "@com_github_fatih_color//:color", "@com_github_gomodule_redigo//redis", "@com_github_inconshreveable_log15//:log15", "@com_github_pkg_browser//:browser", diff --git a/cmd/frontend/internal/cli/BUILD.bazel b/cmd/frontend/internal/cli/BUILD.bazel index cb752af7490..56e4b47d0b9 100644 --- a/cmd/frontend/internal/cli/BUILD.bazel +++ b/cmd/frontend/internal/cli/BUILD.bazel @@ -50,6 +50,8 @@ go_library( "//internal/featureflag", "//internal/gitserver", "//internal/goroutine", + "//internal/grpc", + "//internal/grpc/defaults", "//internal/httpserver", "//internal/instrumentation", "//internal/jsonc", @@ -82,6 +84,7 @@ go_library( "@com_github_throttled_throttled_v2//:throttled", "@com_github_throttled_throttled_v2//store/memstore", "@com_github_throttled_throttled_v2//store/redigostore", + "@org_golang_google_grpc//:go_default_library", ], ) diff --git a/cmd/frontend/internal/highlight/BUILD.bazel b/cmd/frontend/internal/highlight/BUILD.bazel index 41c7ec9c7d1..321e01f2ab6 100644 --- a/cmd/frontend/internal/highlight/BUILD.bazel +++ b/cmd/frontend/internal/highlight/BUILD.bazel @@ -46,12 +46,18 @@ go_test( "html_test.go", "language_test.go", ], + data = glob(["testdata/**"]), embed = [":highlight"], + embedsrcs = [ + "testdata/telemetry-raw.txt", + "testdata/telemetry.scip", + ], deps = [ "//internal/gosyntect", "//lib/errors", "@com_github_google_go_cmp//cmp", "@com_github_grafana_regexp//:regexp", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_scip//bindings/go/scip", "@com_github_stretchr_testify//require", "@org_golang_google_protobuf//proto", diff --git a/cmd/frontend/internal/httpapi/BUILD.bazel b/cmd/frontend/internal/httpapi/BUILD.bazel index cd6738381e0..d6d6870961d 100644 --- a/cmd/frontend/internal/httpapi/BUILD.bazel +++ b/cmd/frontend/internal/httpapi/BUILD.bazel @@ -78,8 +78,12 @@ go_library( "@com_github_prometheus_client_golang//prometheus/promauto", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_zoekt//:zoekt", + "@com_github_sourcegraph_zoekt//cmd/zoekt-sourcegraph-indexserver/protos/sourcegraph/zoekt/configuration/v1:configuration", "@com_github_throttled_throttled_v2//:throttled", "@io_opentelemetry_go_otel//attribute", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", ], ) @@ -129,14 +133,17 @@ go_test( "@com_github_derision_test_glock//:glock", "@com_github_derision_test_go_mockgen//testutil/require", "@com_github_google_go_cmp//cmp", + "@com_github_google_go_cmp//cmp/cmpopts", "@com_github_gorilla_mux//:mux", "@com_github_graph_gophers_graphql_go//errors", "@com_github_inconshreveable_log15//:log15", "@com_github_masterminds_semver//:semver", "@com_github_sourcegraph_log//logtest", "@com_github_sourcegraph_zoekt//:zoekt", + "@com_github_sourcegraph_zoekt//cmd/zoekt-sourcegraph-indexserver/protos/sourcegraph/zoekt/configuration/v1:configuration", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", "@com_github_throttled_throttled_v2//store/memstore", + "@org_golang_google_protobuf//testing/protocmp", ], ) diff --git a/cmd/frontend/shared/BUILD.bazel b/cmd/frontend/shared/BUILD.bazel index ca1f67799f9..4648efc98e1 100644 --- a/cmd/frontend/shared/BUILD.bazel +++ b/cmd/frontend/shared/BUILD.bazel @@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "shared", - srcs = ["service.go"], + srcs = [ + "debug.go", + "service.go", + ], importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/shared", visibility = ["//visibility:public"], deps = [ diff --git a/cmd/gitserver/server/BUILD.bazel b/cmd/gitserver/server/BUILD.bazel index 2b85ab3cd0f..d9cf5a75cf5 100644 --- a/cmd/gitserver/server/BUILD.bazel +++ b/cmd/gitserver/server/BUILD.bazel @@ -123,6 +123,9 @@ go_test( # Test requires localhost database "requires-network", ], + # This test loads coursier as a side effect, so we ensure the + # path is sandboxed properly. + env = {"COURSIER_CACHE_DIR": "/tmp"}, deps = [ "//internal/actor", "//internal/api", diff --git a/cmd/gitserver/shared/BUILD.bazel b/cmd/gitserver/shared/BUILD.bazel index c59aeff228f..0170d6a13bd 100644 --- a/cmd/gitserver/shared/BUILD.bazel +++ b/cmd/gitserver/shared/BUILD.bazel @@ -58,6 +58,9 @@ go_test( name = "shared_test", srcs = ["shared_test.go"], embed = [":shared"], + # This test loads coursier as a side effect, so we ensure the + # path is sandboxed properly. + env = {"COURSIER_CACHE_DIR": "/tmp"}, deps = [ "//cmd/gitserver/server", "//internal/api", diff --git a/deps.bzl b/deps.bzl index ee94cb8361a..f18d8c624d2 100644 --- a/deps.bzl +++ b/deps.bzl @@ -5723,8 +5723,8 @@ def go_dependencies(): name = "com_github_sourcegraph_zoekt", build_file_proto_mode = "disable_global", importpath = "github.com/sourcegraph/zoekt", - sum = "h1:XO7th5aa0YMebq14wz6HC8guKkz9pjvlW1QKIbXchZk=", - version = "v0.0.0-20230303172250-3b0248719b12", + sum = "h1:O834DoaXIyOiQ27/qrev1Pjd79njJru1Kqjwf59ahpg=", + version = "v0.0.0-20230308131753-939eb52f3486", ) go_repository( diff --git a/dev/linters/ineffassign/BUILD.bazel b/dev/linters/ineffassign/BUILD.bazel index 5e7f4dda24d..12dd555edb8 100644 --- a/dev/linters/ineffassign/BUILD.bazel +++ b/dev/linters/ineffassign/BUILD.bazel @@ -5,5 +5,5 @@ go_library( srcs = ["ineffassign.go"], importpath = "github.com/sourcegraph/sourcegraph/dev/linters/ineffassign", visibility = ["//visibility:public"], - deps = ["@com_github_gordonklaus_ineffassign//pkg/ineffassign:go_default_library"], + deps = ["@com_github_gordonklaus_ineffassign//pkg/ineffassign"], ) diff --git a/dev/mocha.bzl b/dev/mocha.bzl index f72175fb5f6..08246913b3f 100644 --- a/dev/mocha.bzl +++ b/dev/mocha.bzl @@ -62,15 +62,15 @@ def mocha_test(name, tests, deps = [], args = [], data = [], env = {}, **kwargs) "MOCHA_FILE": "$$XML_OUTPUT_FILE", # TODO(bazel): e2e test environment - "TEST_USER_EMAIL": "test@sourcegraph.com" - "TEST_USER_PASSWORD": "supersecurepassword" - "SOURCEGRAPH_BASE_URL": "https://sourcegraph.test:3443" + "TEST_USER_EMAIL": "test@sourcegraph.com", + "TEST_USER_PASSWORD": "supersecurepassword", + "SOURCEGRAPH_BASE_URL": "https://sourcegraph.test:3443", "GH_TOKEN": "fake-gh-token", "SOURCEGRAPH_SUDO_TOKEN": "fake-sg-token", "NO_CLEANUP": "true", "KEEP_BROWSER": "true", "DEVTOOLS": "true", - "BROWSER": "chrome" + "BROWSER": "chrome", }), tags = ["manual"], **kwargs diff --git a/docker-images/syntax-highlighter/BUILD.bazel b/docker-images/syntax-highlighter/BUILD.bazel index 129d5d2158e..e7fabf651f9 100644 --- a/docker-images/syntax-highlighter/BUILD.bazel +++ b/docker-images/syntax-highlighter/BUILD.bazel @@ -5,25 +5,25 @@ rust_binary( name = "syntect_server", srcs = ["src/main.rs"], aliases = aliases(), - deps = all_crate_deps( - normal = True, - ) + ["//docker-images/syntax-highlighter/crates/sg-syntax:sg-syntax"], proc_macro_deps = all_crate_deps( proc_macro = True, ), + deps = all_crate_deps( + normal = True, + ) + ["//docker-images/syntax-highlighter/crates/sg-syntax:sg-syntax"], ) rust_test( name = "unit_test", - crate = ":syntect_server", aliases = aliases( normal_dev = True, proc_macro_dev = True, ), + crate = ":syntect_server", + proc_macro_deps = all_crate_deps( + proc_macro_dev = True, + ), deps = all_crate_deps( normal_dev = True, ), - proc_macro_deps = all_crate_deps( - proc_macro_dev = True, - ), ) diff --git a/docker-images/syntax-highlighter/crates/sg-macros/BUILD.bazel b/docker-images/syntax-highlighter/crates/sg-macros/BUILD.bazel index 0ff7e0389ee..a9d2cf40974 100644 --- a/docker-images/syntax-highlighter/crates/sg-macros/BUILD.bazel +++ b/docker-images/syntax-highlighter/crates/sg-macros/BUILD.bazel @@ -2,29 +2,29 @@ load("@crate_index//:defs.bzl", "aliases", "all_crate_deps") load("@rules_rust//rust:defs.bzl", "rust_proc_macro", "rust_test") rust_proc_macro( - name = "sg-macros", - srcs = ["src/lib.rs"], - aliases = aliases(), - deps = all_crate_deps( - normal = True, - ), - proc_macro_deps = all_crate_deps( - proc_macro = True, - ), - visibility = ["//docker-images/syntax-highlighter:__subpackages__"], + name = "sg-macros", + srcs = ["src/lib.rs"], + aliases = aliases(), + proc_macro_deps = all_crate_deps( + proc_macro = True, + ), + visibility = ["//docker-images/syntax-highlighter:__subpackages__"], + deps = all_crate_deps( + normal = True, + ), ) rust_test( name = "unit_test", - crate = ":sg-macros", aliases = aliases( normal_dev = True, proc_macro_dev = True, ), + crate = ":sg-macros", + proc_macro_deps = all_crate_deps( + proc_macro_dev = True, + ), deps = all_crate_deps( normal_dev = True, ), - proc_macro_deps = all_crate_deps( - proc_macro_dev = True, - ), ) diff --git a/docker-images/syntax-highlighter/crates/sg-syntax/BUILD.bazel b/docker-images/syntax-highlighter/crates/sg-syntax/BUILD.bazel index 0d26c94eb8f..ea40c6a39b3 100644 --- a/docker-images/syntax-highlighter/crates/sg-syntax/BUILD.bazel +++ b/docker-images/syntax-highlighter/crates/sg-syntax/BUILD.bazel @@ -4,32 +4,35 @@ load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") rust_library( name = "sg-syntax", srcs = glob(["src/*.rs"]), - compile_data = glob(["queries/**"], allow_empty=False), aliases = aliases(), - deps = all_crate_deps( - normal = True, + compile_data = glob( + ["queries/**"], + allow_empty = False, ), proc_macro_deps = all_crate_deps( proc_macro = True, ) + ["//docker-images/syntax-highlighter/crates/sg-macros:sg-macros"], visibility = ["//docker-images/syntax-highlighter:__subpackages__"], + deps = all_crate_deps( + normal = True, + ), ) +# This prevents bazel configure for generating buildfiles because it sees +# some go files in that folder. +# gazelle:exclude src/snapshots rust_test( name = "unit_test", - crate = ":sg-syntax", - data = glob(["src/snapshots/**"], allow_empty=False), + size = "small", aliases = aliases( normal_dev = True, proc_macro_dev = True, ), - deps = all_crate_deps( - normal_dev = True, + crate = ":sg-syntax", + data = glob( + ["src/snapshots/**"], + allow_empty = False, ), - proc_macro_deps = all_crate_deps( - proc_macro_dev = True, - ), - size = "small", env = { "RUST_BACKTRACE": "1", # NOTE: Outside of Bazel, insta relies on invoking `cargo` (via PATH) @@ -39,4 +42,10 @@ rust_test( # so tests don't need `cargo` access at runtime. "INSTA_WORKSPACE_ROOT": ".", }, + proc_macro_deps = all_crate_deps( + proc_macro_dev = True, + ), + deps = all_crate_deps( + normal_dev = True, + ), ) diff --git a/enterprise/cmd/frontend/internal/batches/rbac/BUILD.bazel b/enterprise/cmd/frontend/internal/batches/rbac/BUILD.bazel new file mode 100644 index 00000000000..4e87050dae0 --- /dev/null +++ b/enterprise/cmd/frontend/internal/batches/rbac/BUILD.bazel @@ -0,0 +1,9 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "rbac", + srcs = ["permissions.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/batches/rbac", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = ["//internal/types"], +) diff --git a/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel index 3247e11f2a4..ba3f840e453 100644 --- a/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel @@ -43,6 +43,7 @@ go_library( "//cmd/frontend/graphqlbackend", "//cmd/frontend/graphqlbackend/externallink", "//cmd/frontend/graphqlbackend/graphqlutil", + "//enterprise/cmd/frontend/internal/batches/rbac", "//enterprise/internal/batches/graphql", "//enterprise/internal/batches/reconciler", "//enterprise/internal/batches/rewirer", @@ -70,6 +71,7 @@ go_library( "//internal/gitserver", "//internal/gitserver/gitdomain", "//internal/gqlutil", + "//internal/rbac", "//internal/trace", "//internal/types", "//internal/usagestats", @@ -121,6 +123,7 @@ go_test( "//cmd/frontend/globals", "//cmd/frontend/graphqlbackend", "//cmd/frontend/graphqlbackend/externallink", + "//enterprise/cmd/frontend/internal/batches/rbac", "//enterprise/cmd/frontend/internal/batches/resolvers/apitest", "//enterprise/internal/batches/graphql", "//enterprise/internal/batches/search", @@ -148,6 +151,7 @@ go_test( "//internal/gqlutil", "//internal/httptestutil", "//internal/observation", + "//internal/rbac", "//internal/rcache", "//internal/repos", "//internal/repoupdater", diff --git a/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel index a9e032be6a1..680de0361b3 100644 --- a/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel @@ -16,26 +16,36 @@ go_library( "//enterprise/internal/own/codeowners", "//enterprise/internal/own/codeowners/v1:codeowners", "//enterprise/internal/own/types", + "//internal/actor", "//internal/api", "//internal/auth", "//internal/database", + "//internal/deviceid", "//internal/errcode", + "//internal/featureflag", "//internal/gitserver", "//internal/gqlutil", "//internal/types", + "//internal/usagestats", "//lib/errors", "@com_github_graph_gophers_graphql_go//:graphql-go", "@com_github_graph_gophers_graphql_go//relay", + "@com_github_sourcegraph_log//:log", ], ) go_test( name = "resolvers_test", - srcs = ["resolvers_test.go"], + srcs = [ + "codeowners_resolvers_test.go", + "resolvers_test.go", + ], + embed = [":resolvers"], deps = [ - ":resolvers", "//cmd/frontend/backend", "//cmd/frontend/graphqlbackend", + "//enterprise/internal/database", + "//enterprise/internal/own", "//enterprise/internal/own/codeowners", "//enterprise/internal/own/codeowners/v1:codeowners", "//internal/actor", @@ -43,8 +53,12 @@ go_test( "//internal/authz", "//internal/database", "//internal/database/fakedb", + "//internal/featureflag", "//internal/gitserver", "//internal/types", + "//lib/errors", + "@com_github_google_go_cmp//cmp", "@com_github_graph_gophers_graphql_go//relay", + "@com_github_sourcegraph_log//logtest", ], ) diff --git a/enterprise/cmd/worker/internal/codeintel/BUILD.bazel b/enterprise/cmd/worker/internal/codeintel/BUILD.bazel index 705e8c2e97e..aa8541f54aa 100644 --- a/enterprise/cmd/worker/internal/codeintel/BUILD.bazel +++ b/enterprise/cmd/worker/internal/codeintel/BUILD.bazel @@ -11,6 +11,7 @@ go_library( "crates_syncer.go", "lsifuploadstore_expirer.go", "metrics_reporter.go", + "package_filter_applicator.go", "policies_repomatcher_job.go", "sentinel_job.go", "upload_backfiller.go", diff --git a/enterprise/dev/ci/internal/ci/pipeline.go b/enterprise/dev/ci/internal/ci/pipeline.go index e2cd2a2c9d7..4d1725917a9 100644 --- a/enterprise/dev/ci/internal/ci/pipeline.go +++ b/enterprise/dev/ci/internal/ci/pipeline.go @@ -118,7 +118,7 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { })) // At this stage, we don't break builds because of a Bazel failure. - // TODO(JH) Disabled until we fix database isolation + // TODO(JH) Disabled until re-enabled with flag // ops.Merge(BazelOperations(true)) // Now we set up conditional operations that only apply to pull requests. @@ -278,6 +278,7 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { triggerAsync(buildOptions))) // At this stage, we don't break builds because of a Bazel failure. + // TODO(JH) disabled until I re-enable this with a flag // ops.Merge(BazelOperations(true)) // Slow image builds diff --git a/enterprise/internal/batches/testing/BUILD.bazel b/enterprise/internal/batches/testing/BUILD.bazel index ed8af3f0989..f10e408f234 100644 --- a/enterprise/internal/batches/testing/BUILD.bazel +++ b/enterprise/internal/batches/testing/BUILD.bazel @@ -15,6 +15,7 @@ go_library( "mock_repo_perms.go", "mock_sync_state.go", "org.go", + "rbac.go", "repos.go", "rsa.go", "specs.go", @@ -42,6 +43,7 @@ go_library( "//internal/extsvc/gitlab", "//internal/gitserver", "//internal/gitserver/gitdomain", + "//internal/rbac", "//internal/repoupdater", "//internal/repoupdater/protocol", "//internal/timeutil", @@ -54,5 +56,6 @@ go_library( "@com_github_sourcegraph_go_diff//diff", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//require", + "@in_gopkg_yaml_v2//:yaml_v2", ], ) diff --git a/enterprise/internal/codeintel/autoindexing/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/BUILD.bazel index 6094acadc03..23a1a38bf73 100644 --- a/enterprise/internal/codeintel/autoindexing/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/BUILD.bazel @@ -33,7 +33,6 @@ go_library( "//internal/workerutil/dbworker/store", "//lib/codeintel/autoindex/config", "//lib/errors", - "@com_github_derision_test_glock//:glock", "@com_github_grafana_regexp//:regexp", "@com_github_opentracing_opentracing_go//log", "@com_github_sourcegraph_log//:log", @@ -48,6 +47,10 @@ go_test( "service_test.go", ], embed = [":autoindexing"], + tags = [ + # requires localhost database + "requires-network", + ], deps = [ "//enterprise/internal/codeintel/autoindexing/internal/jobselector", "//enterprise/internal/codeintel/autoindexing/internal/store", @@ -56,7 +59,6 @@ go_test( "//enterprise/internal/codeintel/uploads/shared", "//internal/api", "//internal/codeintel/dependencies", - "//internal/database", "//internal/gitserver/gitdomain", "//internal/observation", "//internal/repoupdater/protocol", diff --git a/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel index 13c448a1c2f..a0c8c217bab 100644 --- a/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel @@ -10,7 +10,6 @@ go_library( "job_resetters.go", "job_scheduler.go", "job_summary_builder.go", - "metrics_janitor.go", "metrics_resetter.go", "utils.go", ], @@ -24,6 +23,7 @@ go_library( "//enterprise/internal/codeintel/autoindexing/shared", "//enterprise/internal/codeintel/policies", "//enterprise/internal/codeintel/policies/shared", + "//enterprise/internal/codeintel/shared/background", "//enterprise/internal/codeintel/shared/types", "//enterprise/internal/codeintel/uploads/shared", "//internal/actor", @@ -48,7 +48,6 @@ go_library( "//internal/workerutil/dbworker/store", "//lib/codeintel/precise", "//lib/errors", - "@com_github_derision_test_glock//:glock", "@com_github_grafana_regexp//:regexp", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", diff --git a/enterprise/internal/codeintel/autoindexing/internal/enqueuer/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/internal/enqueuer/BUILD.bazel index caa775d5c27..eac2d948926 100644 --- a/enterprise/internal/codeintel/autoindexing/internal/enqueuer/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/internal/enqueuer/BUILD.bazel @@ -16,6 +16,7 @@ go_library( "//enterprise/internal/codeintel/autoindexing/internal/store", "//enterprise/internal/codeintel/shared/types", "//internal/codeintel/dependencies", + "//internal/database", "//internal/errcode", "//internal/metrics", "//internal/observation", diff --git a/enterprise/internal/codeintel/autoindexing/internal/inference/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/internal/inference/BUILD.bazel index 5845401679e..170dd073050 100644 --- a/enterprise/internal/codeintel/autoindexing/internal/inference/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/internal/inference/BUILD.bazel @@ -17,6 +17,7 @@ go_library( "//enterprise/internal/codeintel/autoindexing/internal/inference/libs", "//enterprise/internal/codeintel/autoindexing/internal/inference/lua", "//enterprise/internal/codeintel/autoindexing/internal/inference/luatypes", + "//enterprise/internal/paths", "//internal/api", "//internal/authz", "//internal/codeintel/dependencies", @@ -33,7 +34,6 @@ go_library( "//internal/ratelimit", "//lib/codeintel/autoindex/config", "//lib/errors", - "@com_github_grafana_regexp//:regexp", "@com_github_opentracing_opentracing_go//log", "@com_github_sourcegraph_log//:log", "@com_github_yuin_gopher_lua//:gopher-lua", @@ -61,16 +61,17 @@ go_test( embed = [":inference"], deps = [ "//enterprise/internal/codeintel/autoindexing/internal/inference/libs", + "//enterprise/internal/paths", "//internal/api", "//internal/codeintel/dependencies", "//internal/gitserver", + "//internal/gitserver/gitdomain", "//internal/luasandbox", "//internal/observation", "//internal/ratelimit", "//internal/unpack/unpacktest", "//lib/codeintel/autoindex/config", "@com_github_google_go_cmp//cmp", - "@com_github_grafana_regexp//:regexp", "@org_golang_x_time//rate", ], ) diff --git a/enterprise/internal/codeintel/policies/BUILD.bazel b/enterprise/internal/codeintel/policies/BUILD.bazel index 053aa5873ea..ab595065946 100644 --- a/enterprise/internal/codeintel/policies/BUILD.bazel +++ b/enterprise/internal/codeintel/policies/BUILD.bazel @@ -46,7 +46,6 @@ go_test( "//enterprise/internal/codeintel/policies/internal/store", "//enterprise/internal/codeintel/policies/shared", "//enterprise/internal/codeintel/shared/types", - "//internal/database", "//internal/gitserver/gitdomain", "//internal/observation", "//internal/timeutil", diff --git a/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel b/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel index f7e8f7e2f1b..45f0dd48ab7 100644 --- a/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel +++ b/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel @@ -4,7 +4,6 @@ go_library( name = "background", srcs = [ "job_graph_exporter.go", - "metrics.go", "observabililty.go", "ranking.go", ], @@ -12,13 +11,14 @@ go_library( visibility = ["//enterprise:__subpackages__"], deps = [ "//enterprise/internal/codeintel/ranking/internal/lsifstore", + "//enterprise/internal/codeintel/ranking/internal/shared", "//enterprise/internal/codeintel/ranking/internal/store", + "//enterprise/internal/codeintel/shared/background", "//enterprise/internal/codeintel/uploads/shared", "//internal/conf", "//internal/goroutine", "//internal/observation", "@com_github_prometheus_client_golang//prometheus", - "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_scip//bindings/go/scip", ], diff --git a/enterprise/internal/codeintel/ranking/internal/shared/BUILD.bazel b/enterprise/internal/codeintel/ranking/internal/shared/BUILD.bazel new file mode 100644 index 00000000000..4faa27a8b25 --- /dev/null +++ b/enterprise/internal/codeintel/ranking/internal/shared/BUILD.bazel @@ -0,0 +1,9 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "shared", + srcs = ["keys.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/ranking/internal/shared", + visibility = ["//enterprise:__subpackages__"], + deps = ["//internal/conf"], +) diff --git a/enterprise/internal/codeintel/ranking/internal/store/BUILD.bazel b/enterprise/internal/codeintel/ranking/internal/store/BUILD.bazel index d3f5ba56f2c..608e07628aa 100644 --- a/enterprise/internal/codeintel/ranking/internal/store/BUILD.bazel +++ b/enterprise/internal/codeintel/ranking/internal/store/BUILD.bazel @@ -11,6 +11,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/ranking/internal/store", visibility = ["//enterprise:__subpackages__"], deps = [ + "//enterprise/internal/codeintel/ranking/internal/shared", "//enterprise/internal/codeintel/uploads/shared", "//internal/api", "//internal/database", @@ -40,6 +41,7 @@ go_test( "requires-network", ], deps = [ + "//enterprise/internal/codeintel/ranking/internal/shared", "//enterprise/internal/codeintel/shared/types", "//enterprise/internal/codeintel/uploads/shared", "//internal/api", diff --git a/enterprise/internal/codeintel/shared/background/BUILD.bazel b/enterprise/internal/codeintel/shared/background/BUILD.bazel new file mode 100644 index 00000000000..a4458859f0d --- /dev/null +++ b/enterprise/internal/codeintel/shared/background/BUILD.bazel @@ -0,0 +1,17 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "background", + srcs = [ + "janitor_job.go", + "pipeline_job.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/shared/background", + visibility = ["//enterprise:__subpackages__"], + deps = [ + "//internal/goroutine", + "//internal/metrics", + "//internal/observation", + "@com_github_prometheus_client_golang//prometheus", + ], +) diff --git a/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel b/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel index 8273537d956..6e1f0b539f4 100644 --- a/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel +++ b/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel @@ -12,7 +12,6 @@ go_library( "job_resetters.go", "job_worker_handler.go", "metrics_expirer.go", - "metrics_janitors.go", "metrics_resetter.go", "observability.go", "scip.go", @@ -22,6 +21,7 @@ go_library( deps = [ "//enterprise/internal/codeintel/policies", "//enterprise/internal/codeintel/policies/shared", + "//enterprise/internal/codeintel/shared/background", "//enterprise/internal/codeintel/shared/types", "//enterprise/internal/codeintel/uploads/internal/lsifstore", "//enterprise/internal/codeintel/uploads/internal/store", @@ -34,7 +34,6 @@ go_library( "//internal/goroutine", "//internal/honey", "//internal/memo", - "//internal/metrics", "//internal/observation", "//internal/timeutil", "//internal/types", @@ -45,7 +44,6 @@ go_library( "//lib/codeintel/pathexistence", "//lib/codeintel/precise", "//lib/errors", - "@com_github_derision_test_glock//:glock", "@com_github_jackc_pgconn//:pgconn", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_opentracing_opentracing_go//log", @@ -71,6 +69,7 @@ go_test( embed = [":background"], deps = [ "//cmd/frontend/backend", + "//enterprise/internal/codeintel/autoindexing/shared", "//enterprise/internal/codeintel/policies", "//enterprise/internal/codeintel/policies/shared", "//enterprise/internal/codeintel/shared/types", @@ -90,7 +89,6 @@ go_test( "//internal/workerutil/dbworker/store", "//lib/codeintel/precise", "//lib/errors", - "@com_github_derision_test_glock//:glock", "@com_github_google_go_cmp//cmp", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", diff --git a/enterprise/internal/gitserver/integration_tests/BUILD.bazel b/enterprise/internal/gitserver/integration_tests/BUILD.bazel index 6f17066b07f..e5f438da123 100644 --- a/enterprise/internal/gitserver/integration_tests/BUILD.bazel +++ b/enterprise/internal/gitserver/integration_tests/BUILD.bazel @@ -6,6 +6,9 @@ go_test( "commits_test.go", "tree_test.go", ], + # This test loads coursier as a side effect, so we ensure the + # path is sandboxed properly. + env = {"COURSIER_CACHE_DIR": "/tmp"}, deps = [ "//enterprise/internal/authz/subrepoperms", "//enterprise/internal/database", diff --git a/enterprise/internal/insights/BUILD.bazel b/enterprise/internal/insights/BUILD.bazel index 67dde577ade..ac0c6da8282 100644 --- a/enterprise/internal/insights/BUILD.bazel +++ b/enterprise/internal/insights/BUILD.bazel @@ -6,7 +6,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/insights", visibility = ["//enterprise:__subpackages__"], deps = [ - "//cmd/frontend/enterprise", + "//cmd/frontend/graphqlbackend", "//enterprise/internal/database", "//internal/conf", "//internal/conf/conftypes", diff --git a/enterprise/internal/insights/query/querybuilder/regexp_test.go b/enterprise/internal/insights/query/querybuilder/regexp_test.go index e398b896e55..224be84ac5e 100644 --- a/enterprise/internal/insights/query/querybuilder/regexp_test.go +++ b/enterprise/internal/insights/query/querybuilder/regexp_test.go @@ -241,6 +241,7 @@ func TestReplace_Valid(t *testing.T) { got, err := replacer.Replace(test.replacement) test.want.Equal(t, got) + require.NoError(t, err) }) } } diff --git a/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel b/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel index 1e5f0922c12..70003949d3a 100644 --- a/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel +++ b/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "batches", srcs = [ + "empty_spec_id_migrator.go", "external_fork_name_migrator.go", "ssh_migrator.go", ], @@ -24,6 +25,7 @@ go_library( go_test( name = "batches_test", srcs = [ + "empty_spec_id_migrator_test.go", "external_fork_name_migrator_test.go", "ssh_migrator_test.go", ], @@ -36,6 +38,7 @@ go_test( "//enterprise/internal/batches/sources/bitbucketcloud", "//enterprise/internal/batches/store", "//enterprise/internal/batches/testing", + "//enterprise/internal/batches/types", "//internal/actor", "//internal/api", "//internal/database", diff --git a/enterprise/internal/own/codeowners/BUILD.bazel b/enterprise/internal/own/codeowners/BUILD.bazel index 5df10cec0bf..f21f9567d88 100644 --- a/enterprise/internal/own/codeowners/BUILD.bazel +++ b/enterprise/internal/own/codeowners/BUILD.bazel @@ -4,7 +4,6 @@ go_library( name = "codeowners", srcs = [ "file.go", - "find_owners.go", "owner_types.go", "parse.go", "repr.go", @@ -13,10 +12,11 @@ go_library( visibility = ["//:__subpackages__"], deps = [ "//enterprise/internal/own/codeowners/v1:codeowners", + "//enterprise/internal/paths", + "//internal/api", "//internal/lazyregexp", "//internal/types", "//lib/errors", - "@com_github_becheran_wildmatch_go//:wildmatch-go", ], ) diff --git a/enterprise/internal/own/search/BUILD.bazel b/enterprise/internal/own/search/BUILD.bazel index 20986dc07c5..f72cdeeb567 100644 --- a/enterprise/internal/own/search/BUILD.bazel +++ b/enterprise/internal/own/search/BUILD.bazel @@ -39,9 +39,12 @@ go_test( "//internal/authz", "//internal/database", "//internal/gitserver", + "//internal/search", + "//internal/search/job", "//internal/search/result", "//internal/types", "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//require", ], ) diff --git a/enterprise/internal/paths/BUILD.bazel b/enterprise/internal/paths/BUILD.bazel new file mode 100644 index 00000000000..f404d9c4522 --- /dev/null +++ b/enterprise/internal/paths/BUILD.bazel @@ -0,0 +1,18 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "paths", + srcs = ["match.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/paths", + visibility = ["//enterprise:__subpackages__"], + deps = [ + "//lib/errors", + "@com_github_becheran_wildmatch_go//:wildmatch-go", + ], +) + +go_test( + name = "paths_test", + srcs = ["match_test.go"], + embed = [":paths"], +) diff --git a/enterprise/internal/scim/BUILD.bazel b/enterprise/internal/scim/BUILD.bazel index 9b09b0825dc..c8a88ac7670 100644 --- a/enterprise/internal/scim/BUILD.bazel +++ b/enterprise/internal/scim/BUILD.bazel @@ -48,6 +48,7 @@ go_test( ], embed = [":scim"], deps = [ + "//internal/database", "//internal/observation", "//internal/types", "@com_github_elimity_com_scim//:scim", diff --git a/enterprise/internal/search/BUILD.bazel b/enterprise/internal/search/BUILD.bazel index ceabe359e79..045c1e0fcbf 100644 --- a/enterprise/internal/search/BUILD.bazel +++ b/enterprise/internal/search/BUILD.bazel @@ -7,6 +7,7 @@ go_library( visibility = ["//enterprise:__subpackages__"], deps = [ "//enterprise/internal/own/search", + "//internal/search", "//internal/search/job", "//internal/search/job/jobutil", ], diff --git a/internal/codeintel/dependencies/BUILD.bazel b/internal/codeintel/dependencies/BUILD.bazel index f66cf8ff126..c792c352d49 100644 --- a/internal/codeintel/dependencies/BUILD.bazel +++ b/internal/codeintel/dependencies/BUILD.bazel @@ -9,6 +9,10 @@ go_library( "service.go", ], importpath = "github.com/sourcegraph/sourcegraph/internal/codeintel/dependencies", + tags = [ + # requires localhost database + "requires-network", + ], visibility = ["//:__subpackages__"], deps = [ "//internal/codeintel/dependencies/internal/background", @@ -19,6 +23,8 @@ go_library( "//internal/goroutine", "//internal/metrics", "//internal/observation", + "//internal/packagefilters", + "//lib/errors", "@com_github_opentracing_opentracing_go//log", ], ) diff --git a/internal/codeintel/dependencies/internal/background/BUILD.bazel b/internal/codeintel/dependencies/internal/background/BUILD.bazel index 7ac05164805..97ab7672bf7 100644 --- a/internal/codeintel/dependencies/internal/background/BUILD.bazel +++ b/internal/codeintel/dependencies/internal/background/BUILD.bazel @@ -5,6 +5,7 @@ go_library( srcs = [ "iface.go", "job_cratesyncer.go", + "job_packages_filter.go", "observability.go", ], importpath = "github.com/sourcegraph/sourcegraph/internal/codeintel/dependencies/internal/background", @@ -13,6 +14,7 @@ go_library( "//internal/actor", "//internal/api", "//internal/authz", + "//internal/codeintel/dependencies/internal/store", "//internal/codeintel/dependencies/shared", "//internal/conf/reposource", "//internal/database", @@ -24,11 +26,13 @@ go_library( "//internal/jsonc", "//internal/metrics", "//internal/observation", + "//internal/packagefilters", "//internal/types", "//lib/errors", "//schema", "@com_github_derision_test_glock//:glock", "@com_github_json_iterator_go//:go", + "@com_github_prometheus_client_golang//prometheus", ], ) @@ -36,15 +40,22 @@ go_test( name = "background_test", srcs = [ "job_cratesyncer_test.go", + "job_packages_filter_test.go", "mocks_test.go", ], embed = [":background"], + tags = [ + # requires localhost database + "requires-network", + ], deps = [ "//internal/api", "//internal/authz", + "//internal/codeintel/dependencies/internal/store", "//internal/codeintel/dependencies/shared", "//internal/conf/reposource", "//internal/database", + "//internal/database/dbtest", "//internal/encryption", "//internal/gitserver", "//internal/gitserver/gitdomain", @@ -54,6 +65,8 @@ go_test( "//lib/errors", "//schema", "@com_github_derision_test_glock//:glock", + "@com_github_google_go_cmp//cmp", + "@com_github_sourcegraph_log//logtest", "@org_golang_x_exp//slices", ], ) diff --git a/internal/codeintel/dependencies/internal/store/BUILD.bazel b/internal/codeintel/dependencies/internal/store/BUILD.bazel index 689bec17a8f..2724426666e 100644 --- a/internal/codeintel/dependencies/internal/store/BUILD.bazel +++ b/internal/codeintel/dependencies/internal/store/BUILD.bazel @@ -19,6 +19,7 @@ go_library( "//internal/metrics", "//internal/observation", "//lib/errors", + "@com_github_jackc_pgconn//:pgconn", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", "@com_github_opentracing_opentracing_go//log", diff --git a/internal/database/dbtest/dbtest.go b/internal/database/dbtest/dbtest.go index 07b6313dbd7..c953cbc5695 100644 --- a/internal/database/dbtest/dbtest.go +++ b/internal/database/dbtest/dbtest.go @@ -159,7 +159,7 @@ func newFromDSN(logger log.Logger, t testing.TB, templateNamespace string) *sql. t.Cleanup(func() { defer db.Close() - if t.Failed() { + if t.Failed() && os.Getenv("CI") != "true" { t.Logf("DATABASE %s left intact for inspection", dbname) return } diff --git a/internal/extsvc/bitbucketcloud/BUILD.bazel b/internal/extsvc/bitbucketcloud/BUILD.bazel index 83b3c7afdf1..18ba4fe4c8b 100644 --- a/internal/extsvc/bitbucketcloud/BUILD.bazel +++ b/internal/extsvc/bitbucketcloud/BUILD.bazel @@ -25,6 +25,7 @@ go_library( "//internal/metrics", "//internal/oauthutil", "//internal/ratelimit", + "//internal/timeutil", "//internal/trace/ot", "//lib/errors", "//schema", diff --git a/internal/extsvc/github/BUILD.bazel b/internal/extsvc/github/BUILD.bazel index 529651be23c..62ae71381ad 100644 --- a/internal/extsvc/github/BUILD.bazel +++ b/internal/extsvc/github/BUILD.bazel @@ -23,7 +23,6 @@ go_library( "//internal/metrics", "//internal/oauthutil", "//internal/ratelimit", - "//internal/timeutil", "//internal/trace/ot", "//lib/errors", "@com_github_golang_jwt_jwt_v4//:jwt", diff --git a/internal/extsvc/gitlab/BUILD.bazel b/internal/extsvc/gitlab/BUILD.bazel index 7aefc91e1fb..a5cbc8065e1 100644 --- a/internal/extsvc/gitlab/BUILD.bazel +++ b/internal/extsvc/gitlab/BUILD.bazel @@ -65,6 +65,10 @@ go_test( ], data = glob(["testdata/**"]), embed = [":gitlab"], + tags = [ + # requires localhost database + "requires-network", + ], deps = [ "//internal/conf", "//internal/errcode", diff --git a/internal/gitserver/BUILD.bazel b/internal/gitserver/BUILD.bazel index b9c9d38ecb4..0a7d7d0c5ae 100644 --- a/internal/gitserver/BUILD.bazel +++ b/internal/gitserver/BUILD.bazel @@ -70,6 +70,9 @@ go_test( "internal_test.go", ], embed = [":gitserver"], + # This test loads coursier as a side effect, so we ensure the + # path is sandboxed properly. + env = {"COURSIER_CACHE_DIR": "/tmp"}, deps = [ "//cmd/gitserver/server", "//internal/actor", diff --git a/internal/gitserver/integration_tests/BUILD.bazel b/internal/gitserver/integration_tests/BUILD.bazel index 2021bc7d981..ac29671a1b3 100644 --- a/internal/gitserver/integration_tests/BUILD.bazel +++ b/internal/gitserver/integration_tests/BUILD.bazel @@ -32,6 +32,9 @@ go_test( "tree_test.go", ], embed = [":integration_tests"], + # This test loads coursier as a side effect, so we ensure the + # path is sandboxed properly. + env = {"COURSIER_CACHE_DIR": "/tmp"}, deps = [ "//internal/actor", "//internal/api", diff --git a/internal/goroutine/recorder/BUILD.bazel b/internal/goroutine/recorder/BUILD.bazel index ad0e5919156..fc6ed9e6431 100644 --- a/internal/goroutine/recorder/BUILD.bazel +++ b/internal/goroutine/recorder/BUILD.bazel @@ -20,6 +20,10 @@ go_test( name = "recorder_test", srcs = ["common_test.go"], embed = [":recorder"], + tags = [ + # requires localhost database + "requires-network", + ], deps = [ "//internal/rcache", "//lib/errors", diff --git a/internal/grpc/BUILD.bazel b/internal/grpc/BUILD.bazel index 0b5be61b158..b4120bac081 100644 --- a/internal/grpc/BUILD.bazel +++ b/internal/grpc/BUILD.bazel @@ -10,7 +10,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/internal/grpc", visibility = ["//:__subpackages__"], deps = [ - "//internal/featureflag", + "//internal/conf", "@com_github_sourcegraph_log//:log", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//codes", diff --git a/internal/httpcli/BUILD.bazel b/internal/httpcli/BUILD.bazel index b27bfdc4bbd..5b2f0057f0a 100644 --- a/internal/httpcli/BUILD.bazel +++ b/internal/httpcli/BUILD.bazel @@ -42,6 +42,10 @@ go_test( "redis_logger_middleware_test.go", ], embed = [":httpcli"], + tags = [ + # Test requires localhost database + "requires-network", + ], deps = [ "//internal/actor", "//internal/rcache", diff --git a/internal/httpcli/client.go b/internal/httpcli/client.go index d3b02ba7f36..59a235fa346 100644 --- a/internal/httpcli/client.go +++ b/internal/httpcli/client.go @@ -475,7 +475,7 @@ var schemeErrorRe = lazyregexp.New(`unsupported protocol scheme`) // to NewRetryPolicy. If we're in tests, it returns 1, otherwise it tries to // parse SRC_HTTP_CLI_MAX_RETRIES and return that. If it can't, it defaults to 20. func MaxRetries(n int) int { - if strings.HasSuffix(os.Args[0], ".test") { + if strings.HasSuffix(os.Args[0], ".test") || strings.HasSuffix(os.Args[0], "_test") { return 0 } return n diff --git a/internal/packagefilters/BUILD.bazel b/internal/packagefilters/BUILD.bazel new file mode 100644 index 00000000000..b6118ad7c4d --- /dev/null +++ b/internal/packagefilters/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "packagefilters", + srcs = ["package_filters.go"], + importpath = "github.com/sourcegraph/sourcegraph/internal/packagefilters", + visibility = ["//:__subpackages__"], + deps = [ + "//internal/codeintel/dependencies/shared", + "//internal/conf/reposource", + "//lib/errors", + "@com_github_gobwas_glob//:glob", + ], +) diff --git a/internal/rbac/BUILD.bazel b/internal/rbac/BUILD.bazel index 49770b2314d..fc1ba00c924 100644 --- a/internal/rbac/BUILD.bazel +++ b/internal/rbac/BUILD.bazel @@ -3,10 +3,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "rbac", srcs = [ - "permissions.go", - "permission.go", - "types.go", "parser.go", + "permission.go", + "permissions.go", + "types.go", ], embedsrcs = ["schema.yaml"], importpath = "github.com/sourcegraph/sourcegraph/internal/rbac", @@ -17,6 +17,7 @@ go_library( "//internal/database", "//internal/types", "//lib/errors", + "@com_github_grafana_regexp//:regexp", "@in_gopkg_yaml_v3//:yaml_v3", ], ) @@ -24,11 +25,15 @@ go_library( go_test( name = "rbac_test", srcs = [ - "permissions_test.go", "parser_test.go", "permission_test.go", + "permissions_test.go", ], embed = [":rbac"], + tags = [ + # requires localhost database + "requires-network", + ], deps = [ "//internal/actor", "//internal/auth", diff --git a/internal/repos/BUILD.bazel b/internal/repos/BUILD.bazel index d78274f7a1c..a2940582928 100644 --- a/internal/repos/BUILD.bazel +++ b/internal/repos/BUILD.bazel @@ -67,7 +67,6 @@ go_library( "//internal/extsvc/gitlab", "//internal/extsvc/gitolite", "//internal/extsvc/gomodproxy", - "//internal/extsvc/jvmpackages/coursier", "//internal/extsvc/npm", "//internal/extsvc/pagure", "//internal/extsvc/perforce", @@ -83,6 +82,7 @@ go_library( "//internal/metrics", "//internal/observation", "//internal/ratelimit", + "//internal/repoupdater", "//internal/repoupdater/protocol", "//internal/timeutil", "//internal/trace", diff --git a/internal/search/backend/BUILD.bazel b/internal/search/backend/BUILD.bazel index 474b15e7fb6..5408f1b8da0 100644 --- a/internal/search/backend/BUILD.bazel +++ b/internal/search/backend/BUILD.bazel @@ -17,6 +17,7 @@ go_library( visibility = ["//:__subpackages__"], deps = [ "//internal/actor", + "//internal/api", "//internal/conf", "//internal/honey", "//internal/httpcli", @@ -36,10 +37,12 @@ go_library( "@com_github_prometheus_client_golang//prometheus/promauto", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_zoekt//:zoekt", + "@com_github_sourcegraph_zoekt//cmd/zoekt-sourcegraph-indexserver/protos/sourcegraph/zoekt/configuration/v1:configuration", "@com_github_sourcegraph_zoekt//query", "@com_github_sourcegraph_zoekt//rpc", "@com_github_sourcegraph_zoekt//stream", "@io_opentelemetry_go_otel//attribute", + "@org_golang_google_protobuf//types/known/timestamppb", "@org_golang_x_exp//slices", ], ) diff --git a/internal/singleprogram/filepicker/BUILD.bazel b/internal/singleprogram/filepicker/BUILD.bazel index 0ee9ac4e384..5a4864f08d2 100644 --- a/internal/singleprogram/filepicker/BUILD.bazel +++ b/internal/singleprogram/filepicker/BUILD.bazel @@ -6,6 +6,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/internal/singleprogram/filepicker", visibility = ["//:__subpackages__"], deps = [ + "//internal/syncx", "//lib/errors", "@com_github_sourcegraph_log//:log", ], diff --git a/internal/usagestats/BUILD.bazel b/internal/usagestats/BUILD.bazel index b8df6a59ab5..0b8dd143f5c 100644 --- a/internal/usagestats/BUILD.bazel +++ b/internal/usagestats/BUILD.bazel @@ -20,6 +20,7 @@ go_library( "ide_extensions.go", "migrated_extensions.go", "notebooks.go", + "own.go", "repositories.go", "retention.go", "saved_searches.go", @@ -72,6 +73,7 @@ go_test( "main_test.go", "migrated_extensions_test.go", "notebooks_test.go", + "own_test.go", "retention_test.go", "usage_stats_test.go", ], diff --git a/internal/wrexec/BUILD.bazel b/internal/wrexec/BUILD.bazel index 2556c6a23da..87536015fa7 100644 --- a/internal/wrexec/BUILD.bazel +++ b/internal/wrexec/BUILD.bazel @@ -20,6 +20,10 @@ go_test( "cmd_test.go", "recording_cmd_test.go", ], + tags = [ + # requires localhost database + "requires-network", + ], deps = [ ":wrexec", "//internal/rcache", diff --git a/migrations/BUILD.bazel b/migrations/BUILD.bazel index 4d0785a57d2..80a3d23b0e1 100644 --- a/migrations/BUILD.bazel +++ b/migrations/BUILD.bazel @@ -790,6 +790,39 @@ go_library( "frontend/1678112318_add_external_accounts_scim_index/down.sql", "frontend/1678112318_add_external_accounts_scim_index/metadata.yaml", "frontend/1678112318_add_external_accounts_scim_index/up.sql", + "frontend/1678214530_fix_indexes_on_ranking_tables/down.sql", + "frontend/1678214530_fix_indexes_on_ranking_tables/metadata.yaml", + "frontend/1678214530_fix_indexes_on_ranking_tables/up.sql", + "frontend/1677166643_package_repos_allowblock_lists/down.sql", + "frontend/1677166643_package_repos_allowblock_lists/metadata.yaml", + "frontend/1677166643_package_repos_allowblock_lists/up.sql", + "frontend/1678290792_drop_unused_index_event_logs_user_id/down.sql", + "frontend/1678290792_drop_unused_index_event_logs_user_id/metadata.yaml", + "frontend/1678290792_drop_unused_index_event_logs_user_id/up.sql", + "frontend/1678291091_drop_unused_indexes_for_batch_changes_rand_id_columns/down.sql", + "frontend/1678291091_drop_unused_indexes_for_batch_changes_rand_id_columns/metadata.yaml", + "frontend/1678291091_drop_unused_indexes_for_batch_changes_rand_id_columns/up.sql", + "frontend/1678291402_drop_unused_index_on_user_repo_permissionsuser_id/down.sql", + "frontend/1678291402_drop_unused_index_on_user_repo_permissionsuser_id/metadata.yaml", + "frontend/1678291402_drop_unused_index_on_user_repo_permissionsuser_id/up.sql", + "frontend/1678291831_drop_unused_index_package_repo_versions_fk_idx/down.sql", + "frontend/1678291831_drop_unused_index_package_repo_versions_fk_idx/metadata.yaml", + "frontend/1678291831_drop_unused_index_package_repo_versions_fk_idx/up.sql", + "frontend/1678175532_index_github_topics/down.sql", + "frontend/1678175532_index_github_topics/metadata.yaml", + "frontend/1678175532_index_github_topics/up.sql", + "frontend/1678213774_sg_telemetry_allowlist/down.sql", + "frontend/1678213774_sg_telemetry_allowlist/metadata.yaml", + "frontend/1678213774_sg_telemetry_allowlist/up.sql", + "frontend/1678220614_sg_telemetry_allowlist/down.sql", + "frontend/1678220614_sg_telemetry_allowlist/metadata.yaml", + "frontend/1678220614_sg_telemetry_allowlist/up.sql", + "frontend/1678320579_normalize_webhook_urns/down.sql", + "frontend/1678320579_normalize_webhook_urns/metadata.yaml", + "frontend/1678320579_normalize_webhook_urns/up.sql", + "frontend/1678380933_comment_on_topic_index/down.sql", + "frontend/1678380933_comment_on_topic_index/metadata.yaml", + "frontend/1678380933_comment_on_topic_index/up.sql", ], importpath = "github.com/sourcegraph/sourcegraph/migrations", visibility = ["//visibility:public"], diff --git a/monitoring/definitions/BUILD.bazel b/monitoring/definitions/BUILD.bazel index 0d0c8d82201..586e78b2324 100644 --- a/monitoring/definitions/BUILD.bazel +++ b/monitoring/definitions/BUILD.bazel @@ -10,6 +10,7 @@ go_library( "codeintel_uploads.go", "containers.go", "dashboards.go", + "embeddings.go", "executor.go", "frontend.go", "git_server.go", diff --git a/nogo_config.json b/nogo_config.json index cb2d8692e81..dcbf91c775f 100644 --- a/nogo_config.json +++ b/nogo_config.json @@ -1,6 +1,6 @@ { "_base": { - "description": "Base config which all analyzers will inherit, even unspecified", + "description": "Base config which all analyzers will inherit, unless a specific config is given", "exclude_files": { "rules_go.*/*": "ignore rules_go working directory", "external/*": "no need to vet third party code",