feat: sync contextforge sdk to upstream rc1 #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Record pipeline run | |
| on: | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| record: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Locate and download pipeline artifacts | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| REPOSITORY: ${{ github.repository }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python <<'PY' | |
| import json | |
| import os | |
| import urllib.request | |
| from pathlib import Path | |
| token = os.environ["GH_TOKEN"] | |
| repository = os.environ["REPOSITORY"] | |
| head_sha = os.environ["HEAD_SHA"] | |
| def request(path: str) -> dict: | |
| req = urllib.request.Request( | |
| f"https://api.github.com{path}", | |
| headers={ | |
| "Accept": "application/vnd.github+json", | |
| "Authorization": f"Bearer {token}", | |
| "X-GitHub-Api-Version": "2022-11-28", | |
| }, | |
| ) | |
| with urllib.request.urlopen(req, timeout=60) as resp: | |
| return json.loads(resp.read().decode("utf-8")) | |
| runs = request(f"/repos/{repository}/actions/runs?head_sha={head_sha}&per_page=30") | |
| workflow_runs = runs.get("workflow_runs", []) | |
| target_run_id = None | |
| for run in workflow_runs: | |
| run_id = run.get("id") | |
| if not run_id: | |
| continue | |
| artifacts = request(f"/repos/{repository}/actions/runs/{run_id}/artifacts") | |
| names = {artifact.get("name", "") for artifact in artifacts.get("artifacts", [])} | |
| if "coordinator-report" in names: | |
| target_run_id = str(run_id) | |
| break | |
| if not target_run_id: | |
| print("No prior workflow run for this PR head SHA published a coordinator-report artifact.") | |
| raise SystemExit(0) | |
| Path(".pipeline_run_id").write_text(target_run_id, encoding="utf-8") | |
| PY | |
| if [[ -f .pipeline_run_id ]]; then | |
| PIPELINE_RUN_ID="$(cat .pipeline_run_id)" | |
| gh run download "$PIPELINE_RUN_ID" -R "$REPOSITORY" -n coordinator-report -D . | |
| gh run download "$PIPELINE_RUN_ID" -R "$REPOSITORY" -n verify-feedback -D . || true | |
| fi | |
| - name: Stop early when no coordinator report is available | |
| if: ${{ hashFiles('coordinator-report.md') == '' }} | |
| run: | | |
| echo "Skipping scorebook update: no real coordinator-report.md artifact was available for this merged PR." | |
| echo "This is expected until a manual or automated review executor uploads pipeline artifacts for the PR head SHA." | |
| - name: Record run in scorebook | |
| if: ${{ hashFiles('coordinator-report.md') != '' }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| args=( | |
| --pr "${{ github.event.pull_request.number }}" | |
| --coordinator-report coordinator-report.md | |
| ) | |
| if [[ -f verify-feedback.json ]]; then | |
| args+=(--verify-feedback verify-feedback.json) | |
| fi | |
| python scripts/record_run.py "${args[@]}" | |
| - name: Commit updated scorebook | |
| if: ${{ hashFiles('coordinator-report.md') != '' }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add data/pipeline-runs.jsonl | |
| git diff --cached --quiet || git commit -m "chore: record pipeline scorebook entry" | |
| git push |