Skip to content

docs(benchmarks): document methodology, hardware baseline, and regression policy #353

docs(benchmarks): document methodology, hardware baseline, and regression policy

docs(benchmarks): document methodology, hardware baseline, and regression policy #353

Workflow file for this run

name: Docs
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
error-table-freshness:
name: Error table up to date
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4.2.2
with:
# Check out the PR head so we can push a fixup commit back.
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.head_ref || github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version: "3.11"
- name: Regenerate error cross-reference table
run: python scripts/generate_error_table.py
- name: Commit regenerated table if changed
if: github.event_name == 'pull_request'
run: |
# If PR head repo is a fork (different full_name), we cannot push back from the workflow.
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "PR is from a fork (${{ github.event.pull_request.head.repo.full_name }})."
echo "This workflow cannot push changes to forks. Please run 'python scripts/generate_error_table.py' locally and push the updated docs/errors.md,"
echo "or maintainers can run the regeneration and push to the branch in this repo."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --quiet docs/errors.md; then
git add docs/errors.md
git commit -m "docs: regenerate error cross-reference table [skip ci]"
git push
else
echo "docs/errors.md is already up to date."
fi
- name: Comment on fork PR if error table is stale
if: |
github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name != github.repository
run: |
if ! git diff --quiet docs/errors.md; then
BODY='## :warning: Error table needs regeneration
The `docs/errors.md` error cross-reference table is out of date with the contract source.
Please run the following command locally and push the updated file:
```
python scripts/generate_error_table.py
```
This will regenerate `docs/errors.md` to match the current contract errors.
<!-- error-table-freshness-check -->'
# Look for an existing comment by this workflow (identified by the marker) to edit it
# instead of posting a duplicate comment on every CI run.
EXISTING_ID=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
--jq '.[] | select(.body | contains("<!-- error-table-freshness-check -->")) | .id' | tail -1)
if [ -n "$EXISTING_ID" ]; then
gh pr comment ${{ github.event.pull_request.number }} --edit-comment "$EXISTING_ID" --body "$BODY"
else
gh pr comment ${{ github.event.pull_request.number }} --body "$BODY"
fi
else
echo "docs/errors.md is already up to date."
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail if table still differs on main push
# On direct pushes to main the table must already be committed.
if: github.event_name == 'push'
run: |
if ! git diff --exit-code docs/errors.md; then
echo "FAIL: docs/errors.md is stale. Run 'python scripts/generate_error_table.py' and commit."
exit 1
fi
error-table-tests:
name: generate_error_table.py tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version: "3.11"
- name: Install pytest and coverage
run: pip install pytest pytest-cov
- name: Run script tests with coverage
run: |
python -m pytest scripts/test_generate_error_table.py -v --tb=short \
--cov=scripts.generate_error_table \
--cov-report=term-missing \
--cov-fail-under=95