From 3fd2bb08139512b7b476dc0e882fa94c5425ac26 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Feb 2026 23:13:13 -0700 Subject: [PATCH 1/2] fix: benchmark uses stale native addon from npm Download the just-built native artifact from the triggering Publish workflow and overlay it on top of what npm ci installed. This ensures benchmarks test the freshly compiled addon rather than the last stable npm release. Both new steps are guarded by `if: github.event_name == 'workflow_run'` so manual workflow_dispatch runs skip them and fall back to npm. --- .github/workflows/benchmark.yml | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7933c256..6ea24729 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -15,6 +15,7 @@ jobs: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' permissions: + actions: read contents: write pull-requests: write @@ -33,6 +34,27 @@ jobs: - name: Install dependencies run: npm ci --prefer-offline --no-audit --no-fund + - name: Download native addon from Publish + if: github.event_name == 'workflow_run' + uses: actions/download-artifact@v4 + with: + name: native-linux-x64 + path: ${{ runner.temp }}/native-artifact + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Install native addon from Publish + if: github.event_name == 'workflow_run' + run: | + PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" + mkdir -p "$PKG_DIR" + cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" + # Ensure package.json exists so require() resolves + if [ ! -f "$PKG_DIR/package.json" ]; then + echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" + fi + echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + - name: Run build benchmark run: node scripts/benchmark.js 2>/dev/null > benchmark-result.json @@ -85,6 +107,7 @@ jobs: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' permissions: + actions: read contents: write pull-requests: write @@ -103,6 +126,27 @@ jobs: - name: Install dependencies run: npm ci --prefer-offline --no-audit --no-fund + - name: Download native addon from Publish + if: github.event_name == 'workflow_run' + uses: actions/download-artifact@v4 + with: + name: native-linux-x64 + path: ${{ runner.temp }}/native-artifact + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Install native addon from Publish + if: github.event_name == 'workflow_run' + run: | + PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" + mkdir -p "$PKG_DIR" + cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" + # Ensure package.json exists so require() resolves + if [ ! -f "$PKG_DIR/package.json" ]; then + echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" + fi + echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + - name: Cache HuggingFace models uses: actions/cache@v4 with: @@ -167,6 +211,7 @@ jobs: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' permissions: + actions: read contents: write pull-requests: write @@ -185,6 +230,27 @@ jobs: - name: Install dependencies run: npm ci --prefer-offline --no-audit --no-fund + - name: Download native addon from Publish + if: github.event_name == 'workflow_run' + uses: actions/download-artifact@v4 + with: + name: native-linux-x64 + path: ${{ runner.temp }}/native-artifact + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Install native addon from Publish + if: github.event_name == 'workflow_run' + run: | + PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" + mkdir -p "$PKG_DIR" + cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" + # Ensure package.json exists so require() resolves + if [ ! -f "$PKG_DIR/package.json" ]; then + echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" + fi + echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + - name: Run query benchmark run: node scripts/query-benchmark.js 2>/dev/null > query-benchmark-result.json @@ -237,6 +303,7 @@ jobs: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' permissions: + actions: read contents: write pull-requests: write @@ -255,6 +322,27 @@ jobs: - name: Install dependencies run: npm ci --prefer-offline --no-audit --no-fund + - name: Download native addon from Publish + if: github.event_name == 'workflow_run' + uses: actions/download-artifact@v4 + with: + name: native-linux-x64 + path: ${{ runner.temp }}/native-artifact + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Install native addon from Publish + if: github.event_name == 'workflow_run' + run: | + PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" + mkdir -p "$PKG_DIR" + cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" + # Ensure package.json exists so require() resolves + if [ ! -f "$PKG_DIR/package.json" ]; then + echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" + fi + echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + - name: Run incremental benchmark run: node scripts/incremental-benchmark.js 2>/dev/null > incremental-benchmark-result.json From ab1be1623e9e13171b4175c3f2db3d61476a8374 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Feb 2026 23:37:33 -0700 Subject: [PATCH 2/2] fix: add error handling and traceability to native addon install - Validate codegraph-core.node exists before copying (fail with ::error annotation and directory listing if missing) - Use explicit file path instead of *.node glob to avoid copying unintended files - Log sha256 hash of installed addon for traceability --- .github/workflows/benchmark.yml | 44 +++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 6ea24729..59bbfd72 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -46,14 +46,21 @@ jobs: - name: Install native addon from Publish if: github.event_name == 'workflow_run' run: | + ARTIFACT_DIR="${{ runner.temp }}/native-artifact" + NODE_FILE="$ARTIFACT_DIR/codegraph-core.node" + if [ ! -f "$NODE_FILE" ]; then + echo "::error::Native addon not found at $NODE_FILE" + ls -la "$ARTIFACT_DIR" || true + exit 1 + fi PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" mkdir -p "$PKG_DIR" - cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" - # Ensure package.json exists so require() resolves + cp "$NODE_FILE" "$PKG_DIR/codegraph-core.node" if [ ! -f "$PKG_DIR/package.json" ]; then echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" fi echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + echo " sha256: $(sha256sum "$PKG_DIR/codegraph-core.node" | cut -d' ' -f1)" - name: Run build benchmark run: node scripts/benchmark.js 2>/dev/null > benchmark-result.json @@ -138,14 +145,21 @@ jobs: - name: Install native addon from Publish if: github.event_name == 'workflow_run' run: | + ARTIFACT_DIR="${{ runner.temp }}/native-artifact" + NODE_FILE="$ARTIFACT_DIR/codegraph-core.node" + if [ ! -f "$NODE_FILE" ]; then + echo "::error::Native addon not found at $NODE_FILE" + ls -la "$ARTIFACT_DIR" || true + exit 1 + fi PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" mkdir -p "$PKG_DIR" - cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" - # Ensure package.json exists so require() resolves + cp "$NODE_FILE" "$PKG_DIR/codegraph-core.node" if [ ! -f "$PKG_DIR/package.json" ]; then echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" fi echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + echo " sha256: $(sha256sum "$PKG_DIR/codegraph-core.node" | cut -d' ' -f1)" - name: Cache HuggingFace models uses: actions/cache@v4 @@ -242,14 +256,21 @@ jobs: - name: Install native addon from Publish if: github.event_name == 'workflow_run' run: | + ARTIFACT_DIR="${{ runner.temp }}/native-artifact" + NODE_FILE="$ARTIFACT_DIR/codegraph-core.node" + if [ ! -f "$NODE_FILE" ]; then + echo "::error::Native addon not found at $NODE_FILE" + ls -la "$ARTIFACT_DIR" || true + exit 1 + fi PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" mkdir -p "$PKG_DIR" - cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" - # Ensure package.json exists so require() resolves + cp "$NODE_FILE" "$PKG_DIR/codegraph-core.node" if [ ! -f "$PKG_DIR/package.json" ]; then echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" fi echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + echo " sha256: $(sha256sum "$PKG_DIR/codegraph-core.node" | cut -d' ' -f1)" - name: Run query benchmark run: node scripts/query-benchmark.js 2>/dev/null > query-benchmark-result.json @@ -334,14 +355,21 @@ jobs: - name: Install native addon from Publish if: github.event_name == 'workflow_run' run: | + ARTIFACT_DIR="${{ runner.temp }}/native-artifact" + NODE_FILE="$ARTIFACT_DIR/codegraph-core.node" + if [ ! -f "$NODE_FILE" ]; then + echo "::error::Native addon not found at $NODE_FILE" + ls -la "$ARTIFACT_DIR" || true + exit 1 + fi PKG_DIR="node_modules/@optave/codegraph-linux-x64-gnu" mkdir -p "$PKG_DIR" - cp "${{ runner.temp }}/native-artifact"/*.node "$PKG_DIR/codegraph-core.node" - # Ensure package.json exists so require() resolves + cp "$NODE_FILE" "$PKG_DIR/codegraph-core.node" if [ ! -f "$PKG_DIR/package.json" ]; then echo '{"name":"@optave/codegraph-linux-x64-gnu","main":"codegraph-core.node"}' > "$PKG_DIR/package.json" fi echo "Installed native addon from Publish workflow run ${{ github.event.workflow_run.id }}" + echo " sha256: $(sha256sum "$PKG_DIR/codegraph-core.node" | cut -d' ' -f1)" - name: Run incremental benchmark run: node scripts/incremental-benchmark.js 2>/dev/null > incremental-benchmark-result.json