|
| 1 | +name: SCIP Import |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + scip-tool: |
| 7 | + description: "SCIP indexer to run" |
| 8 | + required: true |
| 9 | + type: string # rust | typescript | python |
| 10 | + scip-file-path: |
| 11 | + description: "Path to the SCIP index file" |
| 12 | + required: false |
| 13 | + type: string |
| 14 | + default: ".scip/index.scip" |
| 15 | + daemon-socket: |
| 16 | + description: "Unix socket path for the LIP daemon" |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + default: "/tmp/lip-ci.sock" |
| 20 | + confidence: |
| 21 | + description: "Confidence score for imported symbols (1-100)" |
| 22 | + required: false |
| 23 | + type: number |
| 24 | + default: 100 |
| 25 | + |
| 26 | + workflow_dispatch: |
| 27 | + inputs: |
| 28 | + scip-tool: |
| 29 | + description: "SCIP indexer to run" |
| 30 | + required: true |
| 31 | + type: choice |
| 32 | + options: |
| 33 | + - rust |
| 34 | + - typescript |
| 35 | + - python |
| 36 | + scip-file-path: |
| 37 | + description: "Path to the SCIP index file" |
| 38 | + required: false |
| 39 | + type: string |
| 40 | + default: ".scip/index.scip" |
| 41 | + daemon-socket: |
| 42 | + description: "Unix socket path for the LIP daemon" |
| 43 | + required: false |
| 44 | + type: string |
| 45 | + default: "/tmp/lip-ci.sock" |
| 46 | + confidence: |
| 47 | + description: "Confidence score for imported symbols (1-100)" |
| 48 | + required: false |
| 49 | + type: number |
| 50 | + default: 100 |
| 51 | + |
| 52 | +env: |
| 53 | + CARGO_TERM_COLOR: always |
| 54 | + CARGO_INCREMENTAL: 0 |
| 55 | + |
| 56 | +jobs: |
| 57 | + scip-import: |
| 58 | + name: SCIP Import (${{ inputs.scip-tool }}) |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + |
| 63 | + # ── Install lip CLI ────────────────────────────────────────────────────── |
| 64 | + - uses: actions/cache@v4 |
| 65 | + id: lip-cache |
| 66 | + with: |
| 67 | + path: ~/.cargo/bin/lip |
| 68 | + key: lip-cli-${{ runner.os }}-${{ hashFiles('.github/workflows/scip-import.yml') }} |
| 69 | + |
| 70 | + - name: Install lip CLI |
| 71 | + if: steps.lip-cache.outputs.cache-hit != 'true' |
| 72 | + run: cargo install lip-cli --locked |
| 73 | + |
| 74 | + # ── Start LIP daemon ───────────────────────────────────────────────────── |
| 75 | + - name: Start LIP daemon |
| 76 | + run: | |
| 77 | + lip daemon --socket ${{ inputs.daemon-socket }} & |
| 78 | + DAEMON_PID=$! |
| 79 | + echo "DAEMON_PID=$DAEMON_PID" >> "$GITHUB_ENV" |
| 80 | + # Wait for socket to appear |
| 81 | + for i in $(seq 1 30); do |
| 82 | + [ -S "${{ inputs.daemon-socket }}" ] && break |
| 83 | + sleep 0.2 |
| 84 | + done |
| 85 | + if [ ! -S "${{ inputs.daemon-socket }}" ]; then |
| 86 | + echo "::error::Daemon socket did not appear within 6s" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | +
|
| 90 | + # ── Install and run SCIP indexer ───────────────────────────────────────── |
| 91 | + - name: Install Rust toolchain |
| 92 | + if: inputs.scip-tool == 'rust' |
| 93 | + uses: dtolnay/rust-toolchain@stable |
| 94 | + with: |
| 95 | + components: rust-analyzer |
| 96 | + |
| 97 | + - name: Run scip-rust indexer |
| 98 | + if: inputs.scip-tool == 'rust' |
| 99 | + run: | |
| 100 | + mkdir -p "$(dirname '${{ inputs.scip-file-path }}')" |
| 101 | + rust-analyzer scip . |
| 102 | + # rust-analyzer writes to index.scip in cwd; move if needed |
| 103 | + if [ "${{ inputs.scip-file-path }}" != "index.scip" ] && [ -f index.scip ]; then |
| 104 | + mv index.scip "${{ inputs.scip-file-path }}" |
| 105 | + fi |
| 106 | +
|
| 107 | + - name: Setup Node.js |
| 108 | + if: inputs.scip-tool == 'typescript' |
| 109 | + uses: actions/setup-node@v4 |
| 110 | + with: |
| 111 | + node-version: "20" |
| 112 | + |
| 113 | + - name: Run scip-typescript indexer |
| 114 | + if: inputs.scip-tool == 'typescript' |
| 115 | + run: | |
| 116 | + npm install -g @sourcegraph/scip-typescript |
| 117 | + mkdir -p "$(dirname '${{ inputs.scip-file-path }}')" |
| 118 | + scip-typescript index --output "${{ inputs.scip-file-path }}" |
| 119 | +
|
| 120 | + - name: Setup Python |
| 121 | + if: inputs.scip-tool == 'python' |
| 122 | + uses: actions/setup-python@v5 |
| 123 | + with: |
| 124 | + python-version: "3.12" |
| 125 | + |
| 126 | + - name: Run scip-python indexer |
| 127 | + if: inputs.scip-tool == 'python' |
| 128 | + run: | |
| 129 | + pip install scip-python |
| 130 | + mkdir -p "$(dirname '${{ inputs.scip-file-path }}')" |
| 131 | + scip-python index --output "${{ inputs.scip-file-path }}" |
| 132 | +
|
| 133 | + # ── Import into daemon ─────────────────────────────────────────────────── |
| 134 | + - name: Import SCIP index into LIP daemon |
| 135 | + run: | |
| 136 | + lip import \ |
| 137 | + --from-scip "${{ inputs.scip-file-path }}" \ |
| 138 | + --push-to-daemon "${{ inputs.daemon-socket }}" \ |
| 139 | + --confidence ${{ inputs.confidence }} |
| 140 | +
|
| 141 | + # ── Verify import ──────────────────────────────────────────────────────── |
| 142 | + - name: Verify index status |
| 143 | + run: | |
| 144 | + echo '[{"type":"query_index_status"}]' | \ |
| 145 | + lip query --socket "${{ inputs.daemon-socket }}" batch |
| 146 | +
|
| 147 | + # ── Cleanup ────────────────────────────────────────────────────────────── |
| 148 | + - name: Stop daemon |
| 149 | + if: always() |
| 150 | + run: | |
| 151 | + if [ -n "$DAEMON_PID" ]; then |
| 152 | + kill "$DAEMON_PID" 2>/dev/null || true |
| 153 | + wait "$DAEMON_PID" 2>/dev/null || true |
| 154 | + fi |
0 commit comments