Skip to content

WIP: make arrow examples executable #274

WIP: make arrow examples executable

WIP: make arrow examples executable #274

Workflow file for this run

name: docs
# Runs the examples, builds the documentation site from their output, and deploys it.
#
# examples one leg per example, a job of its own in the PR's list of checks, named
# "<example> (README)": it executes examples/<example>/README.md with
# tools/execute_markdown.py, against this checkout of benchx, and uploads
# docs-<example>, the page that the site shows. A failing example is a red check.
# build needs every example. Puts the pages in docs/generated/examples/, builds the site (strict).
# deploy needs build. Only for a push to main, or a run by hand on main.
#
# It runs for every pull request. A push to main deploys only when it changes one of the paths
# below: the pages show the output of benchx, so the package and what it depends on count. To add
# an example, see examples/README.md.
on:
push:
branches: [main]
paths:
- "docs/**"
- "src/benchx/**"
- "pyproject.toml"
- "uv.lock"
- "tools/gen_docs.py"
- "tools/execute_markdown.py"
- "examples/**"
- "zensical.toml"
- "README.md"
- ".github/workflows/docs.yml"
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
examples:
name: ${{ matrix.example }} (README)
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
# `requires`: what the example needs beyond benchx and pyperf, for `uv pip install`.
# arrow-demo and archery-local build a C++ suite with CMake: the runner has cmake and a C++
# compiler, and CMake fetches Google Benchmark.
matrix:
include:
- example: pyperf-suite
- example: matmul-params
requires: numpy torch --index-url https://download.pytorch.org/whl/cpu
- example: arrow-demo
- example: archery-local
env:
EXAMPLE: ${{ matrix.example }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: true
cache-dependency-glob: uv.lock
# The examples run plain `python` and `bx`, and the benchmark workers use the same
# `python`, so the environment goes on the PATH. benchx is installed in editable mode, which
# is where it reads its schemas from. The `test` extra brings pyperf and the runner's
# markdown-it-py; the `parquet` extra is for the stores of the examples, which are Parquet.
- name: Install benchx
run: |
uv python install 3.13
uv sync --extra parquet --extra test --python 3.13
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
- name: Install what the example needs
if: matrix.requires
env:
REQUIRES: ${{ matrix.requires }}
run: uv pip install $REQUIRES
- name: Show what is under test
run: |
echo "python: $(python --version) ($(command -v python))"
echo "bx: $(command -v bx)"
echo "benchx: $(python -c 'import benchx; print(benchx.__file__)')"
echo "pyperf: $(python -c 'import pyperf; print(pyperf.__version__)')"
echo "commit: $(git rev-parse --short HEAD)"
# From the root of the checkout, so that annotations carry a path relative to the
# repository and the page does not show the runner's paths. The page and the logs go
# outside the checkout.
- name: Execute examples/${{ matrix.example }}/README.md
run: |
python tools/execute_markdown.py \
--source "examples/$EXAMPLE/README.md" \
--output "$RUNNER_TEMP/pages/$EXAMPLE.md" \
--logs "$RUNNER_TEMP/logs/$EXAMPLE"
- name: Upload logs
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: logs-${{ matrix.example }}
path: ${{ runner.temp }}/logs/${{ matrix.example }}/
if-no-files-found: warn
retention-days: 14
- name: Upload the example's output
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: results-${{ matrix.example }}
path: examples/${{ matrix.example }}/out/
if-no-files-found: ignore
retention-days: 14
# The contract with `build`: docs-<example> holds <example>.md.
- name: Upload the page
if: success()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: docs-${{ matrix.example }}
path: ${{ runner.temp }}/pages/${{ matrix.example }}.md
if-no-files-found: error
retention-days: 14
build:
needs: examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
# generated/<example>.md, one page for each docs-<example> artifact of this run.
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: docs-*
path: generated
merge-multiple: true
# --executed: every example in examples/ must have its executed page, or this stops.
- name: Generate derived pages (landing page, schema reference, example pages)
run: uv run --python 3.12 --with-requirements docs/requirements.txt python tools/gen_docs.py --executed generated
- name: Build site
run: uv run --python 3.12 --with-requirements docs/requirements.txt zensical build --strict --clean
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: site
deploy:
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
- id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5