Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/scip-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: SCIP index uploading

on:
schedule:
- cron: '0 0 * * *' # Run every day at midnight UTC
workflow_dispatch: # Allow manual triggering

permissions:
contents: read

jobs:
index-k8s:
if: github.repository == 'sourcegraph/scip' # Skip running on forks
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: index-k8s
cancel-in-progress: true
container: sourcegraph/scip-go:latest
steps:
- name: Checkout kubernetes/kubernetes
uses: actions/checkout@v5
with:
repository: kubernetes/kubernetes
ref: master
fetch-depth: 1

- name: Configure git safe.directory
run: git config --global --add safe.directory $GITHUB_WORKSPACE
Comment on lines +28 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for configuring this? I read the docs, but I don't remember us configuring this in other CI jobs before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try to run a workflow without it and it failed. I've seen this being used here: https://github.com/sourcegraph/sourcegraph/blob/f80ec0d84a54336daf66fa6e9c8a43cea9ac1fc2/.github/workflows/scip-go.yml#L26-L27

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's weird, I guess it's a relatively new git behavior.

git/git@8959555

Do you remember what error you saw? (I tried looking at previous Actions runs, but couldn't find it in a couple of minutes of looking.)

Fine with leaving this in, but it'd be nice to add a comment summarizing the error to describe why we have this line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation given by amp:

The src code-intel upload command needs to determine the Git commit SHA to associate the uploaded SCIP index with the correct code
version on Sourcegraph.

Internally, it runs Git commands (like git rev-parse HEAD) to get the current commit. When Git detects the repository is owned by a
different user (common in CI/CD environments), it refuses to execute any Git commands due to the CVE-2022-24765 security check.

The error message shows this flow:

   1. src code-intel upload tries to auto-detect the commit
   2. Git fails with "dubious ownership" (exit status 128)
   3. The upload fails with "Unable to determine commit from environment"

That's why you need to either:

   * Add the directory to safe.directory so Git commands work
   * Bypass Git entirely by providing -commit=$GITHUB_SHA explicitly

This does match src-cli behavior:
https://github.com/sourcegraph/src-cli/blob/a8695294ab07ad884fa2b4801f6e568dfa9d32e7/cmd/src/code_intel_upload_flags.go#L252-L254


- name: Get src-cli
run: |
curl -L https://sourcegraph.com/.api/src-cli/src_linux_amd64 \
-o /usr/local/bin/src
chmod +x /usr/local/bin/src

- name: Install Go
uses: actions/setup-go@v5
with: { go-version-file: 'go.mod' }

- name: Run scip-go
run: |
scip-go --version
scip-go --verbose

- name: Validate SCIP index size
run: |
if [ $(stat -c%s index.scip) -lt 10000000 ]; then
echo "ERROR: SCIP dump suspiciously small (< 10MB)"
exit 1
fi
echo "SCIP dump size: $(du -h index.scip)"

- name: Upload SCIP dump to Sourcegraph
run: |
src code-intel upload -no-progress \
-repo=github.com/kubernetes/kubernetes \
-file=index.scip
env:
SRC_ENDPOINT: https://sourcegraph.com/
# A repo-local secret with access token for a Service Account
# that has a role allowing SCIP index upload.
SRC_ACCESS_TOKEN: ${{ secrets.SRC_ACCESS_TOKEN_DOTCOM_SCIP_SA }}
Loading