mirror of
https://github.com/soypat/lneto.git
synced 2026-09-05 06:19:05 +00:00
remove old benchmarking CI
This commit is contained in:
@@ -1,90 +0,0 @@
|
|||||||
name: Benchmark Comment
|
|
||||||
|
|
||||||
# Rationale: This more privileged workflow runs in the base repo's
|
|
||||||
# context (with a write token) only after the 'untrusted' CI workflow finishes.
|
|
||||||
# It does NOT check out or execute PR code; it only consumes the benchmark
|
|
||||||
# report artifact as inert, validated data.
|
|
||||||
on:
|
|
||||||
workflow_run:
|
|
||||||
workflows: [CI]
|
|
||||||
types: [completed]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
comment:
|
|
||||||
# Only for PR-triggered CI runs that succeeded to suppress noise
|
|
||||||
if: >
|
|
||||||
github.event.workflow_run.event == 'pull_request' &&
|
|
||||||
github.event.workflow_run.conclusion == 'success'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write # needed to comment
|
|
||||||
steps:
|
|
||||||
- name: Download generated benchmark report
|
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.1
|
|
||||||
with:
|
|
||||||
name: bench-report
|
|
||||||
path: bench-report
|
|
||||||
run-id: ${{ github.event.workflow_run.id }}
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Validate report and upsert PR comment
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
|
||||||
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
||||||
HEAD_OWNER: ${{ github.event.workflow_run.head_repository.owner.login }}
|
|
||||||
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
report="bench-report/bench-report.md"
|
|
||||||
marker='<!-- lneto-bench -->'
|
|
||||||
|
|
||||||
# Treat the artifact as untrusted input: it was produced by a job that
|
|
||||||
# ran PR code. Basic validation before posting. TODO: Make more robust.
|
|
||||||
test -f "$report"
|
|
||||||
size="$(wc -c < "$report")"
|
|
||||||
if [ "$size" -le 0 ] || [ "$size" -gt 1000000 ]; then
|
|
||||||
echo "::error::benchmark report has unexpected size: ${size} bytes"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if ! grep -qF "$marker" "$report"; then
|
|
||||||
echo "::error::benchmark report missing marker ${marker}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Prefer the PR number from the workflow_run payload, which ties this
|
|
||||||
# privileged workflow to the PR-triggered CI run. Fall back to the
|
|
||||||
# run's head SHA/branch only when GitHub does not populate it.
|
|
||||||
pr="$PR_NUMBER"
|
|
||||||
if [ -z "$pr" ]; then
|
|
||||||
pr="$(gh api "repos/${REPO}/commits/${HEAD_SHA}/pulls" \
|
|
||||||
--jq 'map(select(.state == "open")) | .[0].number // empty')"
|
|
||||||
fi
|
|
||||||
if [ -z "$pr" ]; then
|
|
||||||
pr="$(gh api --method GET "repos/${REPO}/pulls" \
|
|
||||||
-f state=open \
|
|
||||||
-f head="${HEAD_OWNER}:${HEAD_BRANCH}" \
|
|
||||||
--jq '.[0].number // empty')"
|
|
||||||
fi
|
|
||||||
if [ -z "$pr" ]; then
|
|
||||||
echo "No open PR found for ${HEAD_SHA}; nothing to comment."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
comment_id="$(
|
|
||||||
gh api "repos/${REPO}/issues/${pr}/comments" --paginate \
|
|
||||||
--jq ".[] | select(.body | contains(\"${marker}\")) | .id" | head -n1
|
|
||||||
)"
|
|
||||||
if [ -n "$comment_id" ]; then
|
|
||||||
gh api --method PATCH "repos/${REPO}/issues/comments/${comment_id}" \
|
|
||||||
--input - < <(jq -n --rawfile body "$report" '{body: $body}')
|
|
||||||
else
|
|
||||||
gh api --method POST "repos/${REPO}/issues/${pr}/comments" \
|
|
||||||
--input - < <(jq -n --rawfile body "$report" '{body: $body}')
|
|
||||||
fi
|
|
||||||
@@ -100,41 +100,6 @@ jobs:
|
|||||||
- name: Test (race + shuffle)
|
- name: Test (race + shuffle)
|
||||||
run: go test -race -shuffle=on -count=1 -timeout=10m ./...
|
run: go test -race -shuffle=on -count=1 -timeout=10m ./...
|
||||||
|
|
||||||
benchmark:
|
|
||||||
needs: [test]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
||||||
|
|
||||||
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
|
||||||
with:
|
|
||||||
go-version: "1.26"
|
|
||||||
|
|
||||||
- name: Run benchmarks
|
|
||||||
run: go test -bench=. -benchmem -count=5 -shuffle=on -run='^$' -timeout=15m ./... | tee bench-results.txt
|
|
||||||
|
|
||||||
- name: Generate benchmark report
|
|
||||||
run: |
|
|
||||||
go run ./internal/benchci -current bench-results.txt -out bench-report.md
|
|
||||||
cat bench-report.md >> "$GITHUB_STEP_SUMMARY"
|
|
||||||
|
|
||||||
- name: Upload generated benchmark report
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
||||||
with:
|
|
||||||
name: bench-report
|
|
||||||
path: bench-report.md
|
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
- name: Upload raw benchmark results
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
||||||
with:
|
|
||||||
name: bench-results
|
|
||||||
path: bench-results.txt
|
|
||||||
retention-days: 30
|
|
||||||
memci:
|
memci:
|
||||||
needs: [test]
|
needs: [test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
Reference in New Issue
Block a user