mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 16:51:55 +00:00
Rename and move lsif directory (#9366)
This commit is contained in:
parent
368a4f5c19
commit
60d7f713e4
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
@ -250,10 +250,9 @@ Dockerfile @sourcegraph/distribution
|
||||
/cmd/frontend/db/discussion* @slimsag
|
||||
|
||||
# LSIF
|
||||
/lsif/ @sourcegraph/code-intel
|
||||
/cmd/lsif-server/ @sourcegraph/code-intel
|
||||
/internal/lsif @sourcegraph/code-intel
|
||||
/enterprise/internal/codeintel @sourcegraph/code-intel
|
||||
/cmd/lsif-server/ @sourcegraph/code-intel
|
||||
/cmd/frontend/graphqlbackend/codeintel.go @sourcegraph/code-intel
|
||||
|
||||
# Development
|
||||
|
||||
8
.github/workflows/lsif.yml
vendored
8
.github/workflows/lsif.yml
vendored
@ -32,21 +32,21 @@ jobs:
|
||||
root: web
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
lsif-lsif:
|
||||
lsif-precise-code-intel:
|
||||
runs-on: ubuntu-latest
|
||||
container: node:13.8.0-alpine3.10
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install dependencies
|
||||
run: yarn --cwd lsif
|
||||
run: yarn --cwd cmd/lsif-server/precise-code-intel
|
||||
- name: Generate LSIF data
|
||||
uses: sourcegraph/lsif-node-action@master
|
||||
with:
|
||||
project_root: lsif
|
||||
project_root: cmd/lsif-server/precise-code-intel
|
||||
- name: Upload LSIF data
|
||||
uses: sourcegraph/lsif-upload-action@master
|
||||
with:
|
||||
root: lsif
|
||||
root: cmd/lsif-server/precise-code-intel
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
lsif-shared:
|
||||
|
||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -64,7 +64,7 @@
|
||||
"changeProcessCWD": true,
|
||||
},
|
||||
{
|
||||
"directory": "lsif",
|
||||
"directory": "cmd/lsif-server/precise-code-intel",
|
||||
"changeProcessCWD": true,
|
||||
},
|
||||
],
|
||||
|
||||
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@ -53,7 +53,7 @@
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "eslint",
|
||||
"path": "lsif/",
|
||||
"path": "cmd/lsif-server/precise-code-intel/",
|
||||
"problemMatcher": ["$eslint-stylish"],
|
||||
},
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@ module.exports = api => {
|
||||
],
|
||||
plugins: [
|
||||
'babel-plugin-lodash',
|
||||
// Required to support typeoerm decorators in ./lsif
|
||||
// Required to support typeoerm decorators in ./cmd/lsif-server/precise-code-intel
|
||||
['@babel/plugin-proposal-decorators', { legacy: true }],
|
||||
// Node 12 (released 2019 Apr 23) supports these natively, but there seem to be issues when used with TypeScript.
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
# keep this in sync with docker-images/prometheus/Dockerfile
|
||||
FROM prom/prometheus:v2.15.2@sha256:35c52c0c2b76433bbfc44a5a7abc294c2f032ed80250be02b441db5dd91b203a AS prometheus
|
||||
|
||||
FROM alpine:3.10@sha256:e4355b66995c96b4b468159fc5c7e3540fcef961189ca13fee877798649f531a AS lsif-builder
|
||||
FROM alpine:3.10@sha256:e4355b66995c96b4b468159fc5c7e3540fcef961189ca13fee877798649f531a AS pci-builder
|
||||
|
||||
RUN apk add --no-cache nodejs-current=12.4.0-r0 nodejs-npm=10.19.0-r0
|
||||
RUN npm install -g yarn@1.17.3
|
||||
|
||||
COPY lsif/package.json lsif/yarn.lock lsif/tsconfig.json /lsif/
|
||||
RUN yarn --cwd /lsif
|
||||
# TODO - check if this copies everything
|
||||
COPY precise-code-intel/package.json precise-code-intel/yarn.lock precise-code-intel/tsconfig.json /precise-code-intel/
|
||||
RUN yarn --cwd /precise-code-intel
|
||||
|
||||
COPY lsif/src /lsif/src
|
||||
RUN yarn --cwd /lsif run build
|
||||
COPY precise-code-intel/src /precise-code-intel/src
|
||||
RUN yarn --cwd /precise-code-intel run build
|
||||
|
||||
FROM sourcegraph/alpine:3.10@sha256:4d05cd5669726fc38823e92320659a6d1ef7879e62268adec5df658a0bacf65c
|
||||
|
||||
@ -34,22 +35,20 @@ RUN apk update && apk add --no-cache \
|
||||
USER root
|
||||
RUN mkdir -p $PROMETHEUS_STORAGE_DIR && chown -R sourcegraph:sourcegraph $PROMETHEUS_STORAGE_DIR
|
||||
RUN mkdir -p $PROMETHEUS_CONFIGURATION_DIR && chown -R sourcegraph:sourcegraph $PROMETHEUS_CONFIGURATION_DIR
|
||||
|
||||
# Ensures that a directory with the correct permissions exist in the image.
|
||||
# Without this, in Docker Compose deployments the Docker daemon would first
|
||||
# create the volume directory and it would be owned by `root` and then
|
||||
# lsif-server would be unable to create the `/lsif-storage` because it would
|
||||
# be trying to do so in a directory owned by `root` as the user `sourcegraph`.
|
||||
# (And no, this is not dumb, this is just Docker. See https://github.com/docker/compose/issues/3270#issuecomment-363478501)
|
||||
# Ensures that a directory with the correct permissions exist in the image. Without this, in Docker Compose
|
||||
# deployments the Docker daemon would first create the volume directory and it would be owned by `root` and
|
||||
# then one of the precise-code-intel processes would be unable to create the `/lsif-storage` because it
|
||||
# would be trying to do so in a directory owned by `root` as the user `sourcegraph`. And no, this is not
|
||||
# dumb, this is just Docker: https://github.com/docker/compose/issues/3270#issuecomment-363478501.
|
||||
RUN mkdir -p /lsif-storage && chown -R sourcegraph:sourcegraph /lsif-storage
|
||||
USER sourcegraph
|
||||
|
||||
COPY --from=lsif-builder /lsif /lsif
|
||||
COPY --from=pci-builder /precise-code-intel /precise-code-intel
|
||||
COPY ./lsif-server /usr/local/bin/lsif-server
|
||||
COPY --from=prometheus /bin/prometheus /bin/prometheus
|
||||
COPY ./prometheus.yml $PROMETHEUS_CONFIGURATION_DIR/prometheus.yml
|
||||
|
||||
# http server, bundle manager server, (first) worker metrics server, prometheus
|
||||
# http api server, bundle manager server, (first) worker metrics server, prometheus
|
||||
EXPOSE 3186 3187 3188 9090
|
||||
ENV GO111MODULES=on LANG=en_US.utf8 LOG_LEVEL=debug
|
||||
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/lsif-server"]
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
A small wrapper around the TypeScript/node processes that serve precise LSIF code intelligence data.
|
||||
|
||||
- [lsif-api-server](../../lsif/src/api-server/api.ts)
|
||||
- [lsif-bundle-manager](../../lsif/src/bundle-manager/manager.ts)
|
||||
- [lsif-worker](../../lsif/src/worker/worker.ts)
|
||||
- [precise-code-intel-api-server](../../precise-code-intel/src/api-server/api.ts)
|
||||
- [precise-code-intel-bundle-manager](../../precise-code-intel/src/bundle-manager/manager.ts)
|
||||
- [precise-code-intel-worker](../../precise-code-intel/src/worker/worker.ts)
|
||||
|
||||
These processes are run in a [goreman](https://github.com/mattn/goreman) supervisor. By default, there will be one API process and one worker process. The number of replicas per process can be tuned with the environment variables `LSIF_NUM_APIS` (zero or one), `LSIF_NUM_BUNDLE_MANAGERS` (zero or one), and `LSIF_NUM_WORKERS` (zero or more).
|
||||
|
||||
## Prometheus metrics
|
||||
|
||||
The lsif-api-server and lsif-bundle-manager expose HTTP APIs on ports 3186 and 3187, respectively. These APIs contain a `/metrics` endpoint to be scraped by Prometheus. The lsif-worker exposes a metrics server (but nothing else interesting) on port 3188. It's possible to run multiple workers, but impossible for them all to serve metrics from the same port. Therefore, this container also includes a minimally-configured Prometheus process that will scrape metrics from all of the processes. It is suggested that you use [federation](https://prometheus.io/docs/prometheus/latest/federation/) to scrape all of the process metrics at once instead of scraping the individual ports directly. Doing so will ensure that scaling up or down the number of workers will not change the the required Prometheus configuration.
|
||||
The precise-code-intel-api-server and precise-code-intel-bundle-manager expose HTTP APIs on ports 3186 and 3187, respectively. These APIs contain a `/metrics` endpoint to be scraped by Prometheus. The precise-code-intel-worker exposes a metrics server (but nothing else interesting) on port 3188. It's possible to run multiple workers, but impossible for them all to serve metrics from the same port. Therefore, this container also includes a minimally-configured Prometheus process that will scrape metrics from all of the processes. It is suggested that you use [federation](https://prometheus.io/docs/prometheus/latest/federation/) to scrape all of the process metrics at once instead of scraping the individual ports directly. Doing so will ensure that scaling up or down the number of workers will not change the the required Prometheus configuration.
|
||||
|
||||
@ -16,7 +16,7 @@ export GOARCH=amd64
|
||||
export GOOS=linux
|
||||
export CGO_ENABLED=0
|
||||
|
||||
cp -a ./lsif "$OUTPUT"
|
||||
cp -a ./cmd/lsif-server/precise-code-intel "$OUTPUT"
|
||||
cp -a ./cmd/lsif-server/prometheus.yml "$OUTPUT"
|
||||
|
||||
echo "--- go build"
|
||||
|
||||
@ -69,17 +69,17 @@ func makeProcfile(numAPIs, numBundleManagers, numWorkers int64) string {
|
||||
}
|
||||
|
||||
if numAPIs > 0 {
|
||||
addProcess("lsif-api-server", "node /lsif/out/api-server/api.js")
|
||||
addProcess("pci-api-server", "node /precise-code-intel/out/api-server/api.js")
|
||||
}
|
||||
|
||||
if numBundleManagers > 0 {
|
||||
addProcess("lsif-bundle-manager", "node /lsif/out/bundle-manager/manager.js")
|
||||
addProcess("pci-bundle-manager", "node /precise-code-intel/out/bundle-manager/manager.js")
|
||||
}
|
||||
|
||||
for i := 0; i < int(numWorkers); i++ {
|
||||
addProcess(
|
||||
fmt.Sprintf("lsif-worker-%d", i),
|
||||
fmt.Sprintf("env METRICS_PORT=%d node /lsif/out/worker/worker.js", workerPort+i),
|
||||
fmt.Sprintf("pci-worker-%d", i),
|
||||
fmt.Sprintf("env METRICS_PORT=%d node /precise-code-intel/out/worker/worker.js", workerPort+i),
|
||||
)
|
||||
}
|
||||
|
||||
@ -103,15 +103,15 @@ func makePrometheusTargets(numAPIs, numBundleManagers, numWorkers int64) string
|
||||
}
|
||||
|
||||
if numAPIs > 0 {
|
||||
addTarget("lsif-api-server", apiPort)
|
||||
addTarget("pci-api-server", apiPort)
|
||||
}
|
||||
|
||||
if numBundleManagers > 0 {
|
||||
addTarget("lsif-bundle-manager", bundleManagerPort)
|
||||
addTarget("pci-bundle-manager", bundleManagerPort)
|
||||
}
|
||||
|
||||
for i := 0; i < int(numWorkers); i++ {
|
||||
addTarget("lsif-worker", workerPort+i)
|
||||
addTarget("pci-worker", workerPort+i)
|
||||
}
|
||||
|
||||
return strings.Join(content, "\n") + "\n"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const baseConfig = require('../.eslintrc')
|
||||
const baseConfig = require('../../../.eslintrc')
|
||||
module.exports = {
|
||||
extends: '../.eslintrc.js',
|
||||
extends: '../../../.eslintrc.js',
|
||||
parserOptions: {
|
||||
...baseConfig.parserOptions,
|
||||
project: 'tsconfig.json',
|
||||
@ -14,7 +14,7 @@ This project is split into three parts, all currently written in TypeScript. The
|
||||
|
||||
### Entrypoint
|
||||
|
||||
The docker image for this part of the application is produced by [./cmd/lsif-server](.././cmd/lsif-server), which wraps a server, a bundle manager, and a worker with a supervisor.
|
||||
The docker image for this part of the application is produced by [./cmd/lsif-server](../), which wraps a server, a bundle manager, and a worker with a supervisor.
|
||||
|
||||
### Documentation
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
/** @type {import('@babel/core').TransformOptions} */
|
||||
const config = {
|
||||
extends: '../babel.config.js',
|
||||
extends: '../../../babel.config.js',
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
@ -9,4 +9,4 @@ We rely on the Sourcegraph frontend to apply our DB migrations. These live in th
|
||||
|
||||
## Migrations
|
||||
|
||||
To add a new migration for the tables used by the LSIF processes, create a new migration in the frontend according to the instructions in [the migration documentation](../../migrations/README.md). Then, update the value of `MINIMUM_MIGRATION_VERSION` in [postgres.ts](../src/shared/database/postgres.ts) to be the timestamp from the generated filename.
|
||||
To add a new migration for the tables used by the LSIF processes, create a new migration in the frontend according to the instructions in [the migration documentation](../../../../migrations/README.md). Then, update the value of `MINIMUM_MIGRATION_VERSION` in [postgres.ts](../src/shared/database/postgres.ts) to be the timestamp from the generated filename.
|
||||
@ -1,7 +1,7 @@
|
||||
// @ts-check
|
||||
|
||||
/** @type {jest.InitialOptions} */
|
||||
const config = require('../jest.config.base')
|
||||
const config = require('../../../jest.config.base')
|
||||
|
||||
/** @type {jest.InitialOptions} */
|
||||
module.exports = { ...config, setupFilesAfterEnv: ['./jest.setup.js'], displayName: 'lsif', rootDir: __dirname }
|
||||
@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "lsif",
|
||||
"description": "LSIF-based precise code intelligence",
|
||||
"name": "precise-code-intel",
|
||||
"description": "Precise code intelligence services for Sourcegraph",
|
||||
"author": "Sourcegraph",
|
||||
"license": "MIT",
|
||||
"version": "0.1.0",
|
||||
"version": "0.0.0-DEVELOPMENT",
|
||||
"scripts": {
|
||||
"build": "tsc -b .",
|
||||
"test": "jest",
|
||||
"tslint": "../node_modules/.bin/tslint -p tsconfig.json",
|
||||
"eslint": "../node_modules/.bin/eslint --cache 'src/**/*.ts?(x)'",
|
||||
"tslint": "../../../node_modules/.bin/tslint -p tsconfig.json",
|
||||
"eslint": "../../../node_modules/.bin/eslint --cache 'src/**/*.ts?(x)'",
|
||||
"run:api-server": "tsc-watch --onSuccess \"node -r source-map-support/register out/api-server/api.js\" --noClear",
|
||||
"run:bundle-manager": "tsc-watch --onSuccess \"node -r source-map-support/register out/bundle-manager/manager.js\" --noClear",
|
||||
"run:worker": "tsc-watch --onSuccess \"node -r source-map-support/register out/worker/worker.js\" --noClear"
|
||||
@ -31,7 +31,7 @@ async function main(logger: Logger): Promise<void> {
|
||||
const fetchConfiguration = await waitForConfiguration(logger)
|
||||
|
||||
// Configure distributed tracing
|
||||
const tracer = createTracer('lsif-api-server', fetchConfiguration())
|
||||
const tracer = createTracer('precise-code-intel-api-server', fetchConfiguration())
|
||||
|
||||
// Ensure storage roots exist
|
||||
await ensureDirectory(settings.STORAGE_ROOT)
|
||||
@ -70,7 +70,7 @@ function selectHistogram(route: string): promClient.Histogram<string> | undefine
|
||||
}
|
||||
|
||||
// Initialize logger
|
||||
const appLogger = createLogger('lsif-api-server')
|
||||
const appLogger = createLogger('precise-code-intel-api-server')
|
||||
|
||||
// Run app!
|
||||
main(appLogger).catch(error => {
|
||||
@ -48,7 +48,7 @@ async function main(logger: Logger): Promise<void> {
|
||||
}
|
||||
|
||||
// Initialize logger
|
||||
const appLogger = createLogger('lsif-bundle-manager')
|
||||
const appLogger = createLogger('precise-code-intel-bundle-manager')
|
||||
|
||||
// Launch!
|
||||
main(appLogger).catch(error => {
|
||||
@ -37,13 +37,13 @@ export const CLEAN_FAILED_UPLOADS_INTERVAL = readEnvInt('CLEAN_FAILED_UPLOADS_IN
|
||||
/** The maximum age (in seconds) that the files for an unprocessed upload can remain on disk. */
|
||||
export const FAILED_UPLOAD_MAX_AGE = readEnvInt('FAILED_UPLOAD_MAX_AGE', 24 * 60 * 60)
|
||||
|
||||
/** How many times to retry requests to lsif-api-server in the background. */
|
||||
/** How many times to retry requests to precise-code-intel-api-server in the background. */
|
||||
export const MAX_REQUEST_RETRIES = readEnvInt('MAX_REQUEST_RETRIES', 60)
|
||||
|
||||
/** How long to wait (minimum, in seconds) between lsif-api-server request attempts. */
|
||||
/** How long to wait (minimum, in seconds) between precise-code-intel-api-server request attempts. */
|
||||
export const MIN_REQUEST_RETRY_TIMEOUT = readEnvInt('MIN_REQUEST_RETRY_TIMEOUT', 1)
|
||||
|
||||
/** How long to wait (maximum, in seconds) between lsif-api-server request attempts. */
|
||||
/** How long to wait (maximum, in seconds) between precise-code-intel-api-server request attempts. */
|
||||
export const MAX_REQUEST_RETRY_TIMEOUT = readEnvInt('MAX_REQUEST_RETRY_TIMEOUT', 30)
|
||||
|
||||
/** The maximum rate that the server will send upload payloads. */
|
||||
@ -27,10 +27,9 @@ export async function createCleanPostgresDatabase(): Promise<{ connection: Conne
|
||||
const password = process.env.PGPASSWORD || ''
|
||||
const database = `sourcegraph-test-lsif-${suffix}`
|
||||
|
||||
// Determine the path of the migrate script. This will cover the case
|
||||
// where `yarn test` is run from within the root or from the lsif directory.
|
||||
// const migrateScriptPath = nodepath.join((await fs.exists('dev')) ? '' : '..', 'dev', 'migrate.sh')
|
||||
const migrationsPath = nodepath.join((await fs.exists('migrations')) ? '' : '..', 'migrations')
|
||||
// Determine the path of the migrate script. This will cover the case where `yarn test` is
|
||||
// run from within the root or from the precise-code-intel directory.
|
||||
const migrationsPath = nodepath.join((await fs.exists('migrations')) ? '' : '../../../migrations')
|
||||
|
||||
// Ensure environment gets passed to child commands
|
||||
const env = {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user