2022-03-25 09:46:57 +00:00
|
|
|
name: gh-pages
|
2020-08-11 21:32:59 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-03-16 22:14:57 +00:00
|
|
|
- main
|
2021-05-05 03:27:12 +00:00
|
|
|
pull_request:
|
2020-08-11 21:32:59 +00:00
|
|
|
release:
|
2020-09-16 21:25:43 +00:00
|
|
|
types: [published]
|
2020-08-11 21:32:59 +00:00
|
|
|
|
2022-03-15 12:47:39 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-09-01 19:59:28 +00:00
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
|
2020-08-11 21:32:59 +00:00
|
|
|
jobs:
|
2022-03-25 09:46:57 +00:00
|
|
|
guide-build:
|
2020-08-11 21:32:59 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-16 19:43:44 +00:00
|
|
|
outputs:
|
|
|
|
tag_name: ${{ steps.prepare_tag.outputs.tag_name }}
|
2020-08-11 21:32:59 +00:00
|
|
|
steps:
|
2023-09-04 20:47:53 +00:00
|
|
|
- uses: actions/checkout@v4
|
2020-08-11 21:32:59 +00:00
|
|
|
|
2022-11-02 01:39:34 +00:00
|
|
|
- uses: dtolnay/rust-toolchain@nightly
|
2021-05-05 03:26:03 +00:00
|
|
|
|
2020-08-11 21:32:59 +00:00
|
|
|
- name: Setup mdBook
|
2024-03-08 14:10:47 +00:00
|
|
|
uses: taiki-e/install-action@v2
|
2020-08-11 21:32:59 +00:00
|
|
|
with:
|
2024-03-08 14:10:47 +00:00
|
|
|
tool: mdbook,lychee
|
2021-04-02 14:38:49 +00:00
|
|
|
|
|
|
|
- name: Prepare tag
|
|
|
|
id: prepare_tag
|
|
|
|
run: |
|
|
|
|
TAG_NAME="${GITHUB_REF##*/}"
|
|
|
|
echo "::set-output name=tag_name::${TAG_NAME}"
|
2020-08-11 21:32:59 +00:00
|
|
|
|
2024-03-08 14:10:47 +00:00
|
|
|
# This builds the book in target/guide/.
|
2020-08-11 21:32:59 +00:00
|
|
|
- name: Build the guide
|
2022-06-08 13:30:11 +00:00
|
|
|
run: |
|
2023-05-01 15:53:57 +00:00
|
|
|
python -m pip install --upgrade pip && pip install nox
|
2024-03-08 14:10:47 +00:00
|
|
|
nox -s check-guide
|
2021-04-02 14:38:49 +00:00
|
|
|
env:
|
|
|
|
PYO3_VERSION_TAG: ${{ steps.prepare_tag.outputs.tag_name }}
|
2020-08-11 21:32:59 +00:00
|
|
|
|
2021-12-22 11:09:16 +00:00
|
|
|
- name: Deploy docs and the guide
|
2022-08-27 20:15:12 +00:00
|
|
|
if: ${{ github.event_name == 'release' }}
|
2024-04-11 21:08:44 +00:00
|
|
|
uses: peaceiris/actions-gh-pages@v4
|
2020-08-11 21:32:59 +00:00
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
2022-06-08 13:30:11 +00:00
|
|
|
publish_dir: ./target/guide/
|
2020-08-11 21:32:59 +00:00
|
|
|
destination_dir: ${{ steps.prepare_tag.outputs.tag_name }}
|
2021-07-20 07:53:43 +00:00
|
|
|
full_commit_message: "Upload documentation for ${{ steps.prepare_tag.outputs.tag_name }}"
|
2022-03-25 09:46:57 +00:00
|
|
|
|
|
|
|
cargo-benchmark:
|
|
|
|
if: ${{ github.ref_name == 'main' }}
|
|
|
|
name: Cargo benchmark
|
|
|
|
needs: guide-build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-04 20:47:53 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-11 20:04:18 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2022-11-02 01:39:34 +00:00
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
2022-03-25 09:46:57 +00:00
|
|
|
|
2024-01-22 20:07:15 +00:00
|
|
|
- uses: actions/cache@v4
|
2022-03-25 09:46:57 +00:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
target
|
|
|
|
key: cargo-${{ runner.os }}-bench-${{ hashFiles('**/Cargo.toml') }}
|
|
|
|
continue-on-error: true
|
|
|
|
|
|
|
|
- name: Run benchmarks
|
|
|
|
run: |
|
2023-07-29 05:28:39 +00:00
|
|
|
python -m pip install --upgrade pip && pip install nox
|
|
|
|
for bench in pyo3-benches/benches/*.rs; do
|
|
|
|
bench_name=$(basename "$bench" .rs)
|
|
|
|
nox -s bench -- --bench "$bench_name" -- --output-format bencher | tee -a output.txt
|
2022-03-25 09:46:57 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Download previous benchmark result from cache (if exists)
|
|
|
|
- name: Download previous benchmark data
|
2024-01-22 20:07:15 +00:00
|
|
|
uses: actions/cache@v4
|
2022-03-25 09:46:57 +00:00
|
|
|
with:
|
|
|
|
path: ./cache
|
|
|
|
key: ${{ runner.os }}-benchmark
|
|
|
|
|
|
|
|
# Run `github-action-benchmark` action
|
|
|
|
- name: Store benchmark result
|
|
|
|
uses: benchmark-action/github-action-benchmark@v1
|
|
|
|
with:
|
|
|
|
name: pyo3-bench
|
|
|
|
# What benchmark tool the output.txt came from
|
|
|
|
tool: "cargo"
|
|
|
|
# Where the output from the benchmark tool is stored
|
|
|
|
output-file-path: output.txt
|
|
|
|
# GitHub API token to make a commit comment
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
auto-push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
|
|
|
|
pytest-benchmark:
|
|
|
|
if: ${{ github.ref_name == 'main' }}
|
|
|
|
name: Pytest benchmark
|
|
|
|
needs: cargo-benchmark
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-04 20:47:53 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-11 20:04:18 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2022-11-02 01:39:34 +00:00
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
2022-03-25 09:46:57 +00:00
|
|
|
|
2024-01-22 20:07:15 +00:00
|
|
|
- uses: actions/cache@v4
|
2022-03-25 09:46:57 +00:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cargo/registry
|
|
|
|
~/.cargo/git
|
|
|
|
target
|
|
|
|
key: cargo-${{ runner.os }}-pytest-bench-${{ hashFiles('**/Cargo.toml') }}
|
|
|
|
continue-on-error: true
|
|
|
|
|
|
|
|
- name: Download previous benchmark data
|
2024-01-22 20:07:15 +00:00
|
|
|
uses: actions/cache@v4
|
2022-03-25 09:46:57 +00:00
|
|
|
with:
|
|
|
|
path: ./cache
|
|
|
|
key: ${{ runner.os }}-pytest-benchmark
|
|
|
|
|
|
|
|
- name: Run benchmarks
|
|
|
|
run: |
|
2023-05-01 15:53:57 +00:00
|
|
|
python -m pip install --upgrade pip && pip install nox
|
2022-03-25 09:46:57 +00:00
|
|
|
nox -f pytests/noxfile.py -s bench -- --benchmark-json $(pwd)/output.json
|
|
|
|
- name: Store benchmark result
|
|
|
|
uses: benchmark-action/github-action-benchmark@v1
|
|
|
|
with:
|
|
|
|
name: pytest-bench
|
|
|
|
tool: "pytest"
|
|
|
|
output-file-path: output.json
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
auto-push: ${{ github.event_name != 'pull_request' }}
|