After walking through the LSIF quickstart guide, add a job to your CI so code intelligence keeps up with the changes to your repository.
Your CI machines will need two command-line tools installed. Depending on your build system setup, you can do this as part of the CI step, or you can add it directly to your CI machines for use by the build.
src
).We recommend that you start with a CI job that runs on every commit (including branches).
If you see too much load on your CI, your Sourcegraph instance, or a rapid decrease in free disk space on your Sourcegraph instance, you can instead index only the default branch, or set up a periodic job (e.g. daily) in CI that indexes your default branch.
With periodic jobs, you should still receive precise code intelligence on non-indexed commits on lines that are unchanged since the nearest indexed commit. This requires that the indexed commit be a direct ancestor or descendant no more than 100 commits away. If your commit frequency is too high and your index frequency is too low, you may find commits with no precise code intelligence at all. In this case, we recommend you try to increase your index frequency if possible.
You can use GitHub Actions to (1) generate LSIF data and (2) upload it to a Sourcegraph instance, like Sourcegraph.com.
Actions to Generate LSIF index data for each language:
Action to upload LSIF data.
Create a workflow file .github/workflows/lsif.yaml
in your repository.
You will need configure two actions to (1) generate the LSIF data and (2) upload it to Sourcegraph. Here's an example for generating LSIF data for a Go project:
name: LSIF on: - push jobs: index: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Generate LSIF data uses: sourcegraph/lsif-go-action@master - name: Upload LSIF data uses: sourcegraph/lsif-upload-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} endpoint: https://sourcegraph.com # use sourcegraph.com, or alternatively, your own instance
Depending on your code requirements, you may need to add additional steps after checkout but before indexing (installing dependencies, generating indexable assets, etc).
Once that workflow is committed to your repository, you will start to see LSIF workflows in the Actions tab of your repository (e.g. https://github.com/sourcegraph/sourcegraph/actions).
After the workflow succeeds, you should see LSIF-powered code intelligence on your repository on Sourcegraph.com or on GitHub with the Sourcegraph browser extension.
LSIF data can be uploaded to a self-hosted Sourcegraph instance or to Sourcegraph.com. Using the Sourcegraph.com endpoint will surface code intelligence for your public repositories directly on GitHub via the Sourcegraph browser extension and at https://sourcegraph.com/github.com/<your-username>/<your-repo>
.
Using the Sourcegraph.com endpoint is free and your LSIF data is treated as User-Generated Content (you own it, as covered in our Sourcegraph.com terms of service). If you run into trouble, or a situation arises where you need all of your LSIF data expunged, please reach out to us at [email protected].