pyo3/.github/workflows/gh-pages.yml

138 lines
3.9 KiB
YAML
Raw Normal View History

2022-03-25 09:46:57 +00:00
name: gh-pages
on:
push:
branches:
2021-03-16 22:14:57 +00:00
- main
2021-05-05 03:27:12 +00:00
pull_request:
release:
2020-09-16 21:25:43 +00:00
types: [published]
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
jobs:
2022-03-25 09:46:57 +00:00
guide-build:
runs-on: ubuntu-latest
2020-09-16 19:43:44 +00:00
outputs:
tag_name: ${{ steps.prepare_tag.outputs.tag_name }}
steps:
2022-06-02 08:18:35 +00:00
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
2022-07-03 02:48:33 +00:00
mdbook-version: "0.4.19"
- name: Prepare tag
id: prepare_tag
run: |
TAG_NAME="${GITHUB_REF##*/}"
echo "::set-output name=tag_name::${TAG_NAME}"
# This builds the book in target/guide.
- name: Build the guide
run: |
pip install nox
nox -s build-guide
env:
PYO3_VERSION_TAG: ${{ steps.prepare_tag.outputs.tag_name }}
- name: Deploy docs and the guide
2022-08-27 20:15:12 +00:00
if: ${{ github.event_name == 'release' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/guide/
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:
2022-06-02 08:18:35 +00:00
- uses: actions/checkout@v3
2022-03-25 09:46:57 +00:00
- uses: dtolnay/rust-toolchain@stable
2022-03-25 09:46:57 +00:00
- uses: actions/cache@v3
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: |
for bench in call dict gil list pyclass pyobject set tuple; do
cargo bench --features hashbrown --bench "bench_$bench" -- --output-format bencher | tee -a output.txt
done
# Download previous benchmark result from cache (if exists)
- name: Download previous benchmark data
uses: actions/cache@v3
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:
2022-06-02 08:18:35 +00:00
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: dtolnay/rust-toolchain@stable
2022-03-25 09:46:57 +00:00
- uses: actions/cache@v3
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
uses: actions/cache@v3
2022-03-25 09:46:57 +00:00
with:
path: ./cache
key: ${{ runner.os }}-pytest-benchmark
- name: Run benchmarks
run: |
pip install nox
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' }}