Skip to content

Merge pull request #14 from deedy5/ci #252

Merge pull request #14 from deedy5/ci

Merge pull request #14 from deedy5/ci #252

Workflow file for this run

# This file is autogenerated by maturin v1.5.1
# To update, run
#
# maturin generate-ci github -o .github/workflows/CI.yml --pytest --zig
#
name: CI
on:
push:
branches:
- main
- '*'
tags:
- '*'
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
rust-toolchain: stable
target: ${{ matrix.platform.target }}
args: --release --out dist --zig
sccache: 'true'
manylinux: 2_28
env:
CFLAGS_aarch64_unknown_linux_gnu: "-D__ARM_ARCH=8"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist
- name: pytest
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
shell: bash
run: |
set -e
pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall
pip install pytest
pytest
- name: pytest
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
uses: uraimo/run-on-arch-action@v2.7.2
with:
arch: ${{ matrix.platform.target }}
distro: ubuntu22.04
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip
pip3 install -U pip pytest
run: |
set -e
pip3 install pyreqwest_impersonate --no-index --find-links dist --force-reinstall
pytest
musllinux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
rust-toolchain: stable
target: ${{ matrix.platform.target }}
args: --release --out dist --zig
sccache: 'true'
manylinux: musllinux_1_2
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}-musllinux_1_2
path: dist
- name: pytest
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/musllinux_1_2_${{ matrix.platform.target }}:latest
options: -v ${{ github.workspace }}:/io -w /io
run: |
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -U pip wheel pytest
python3 -m pip install pyreqwest_impersonate --no-index --find-links dist/ --force-reinstall
python3 -m pytest
- name: pytest
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
uses: uraimo/run-on-arch-action@v2.7.2
with:
arch: ${{ matrix.platform.target }}
distro: alpine_latest
githubToken: ${{ github.token }}
install: |
apk add py3-pip
python3 -m venv /opt/venv
/opt/venv/bin/pip3 install -U pip pytest
run: |
source /opt/venv/bin/activate
pip3 install pyreqwest_impersonate --no-index --find-links dist --force-reinstall
pytest
windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: ${{ matrix.platform.target }}
- name: Install nasm
run: choco install nasm
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
rust-toolchain: stable
target: ${{ matrix.platform.target }}
args: --release --out dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist
- name: pytest
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
shell: bash
run: |
set -e
pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall
pip install pytest
pytest
macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-12
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
rust-toolchain: stable
target: ${{ matrix.platform.target }}
args: --release --out dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist
- name: pytest
shell: bash
run: |
set -e
pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall
pip install pytest
pytest
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, musllinux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
benchmark:
permissions:
contents: write
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [release]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
sleep 30 # Wait for the package to be available on PyPI
python -m pip install --upgrade pip
pip install -r benchmark/requirements.txt
- name: Start Uvicorn server
run: |
uvicorn benchmark.server:app --host 0.0.0.0 --port 8000 &
sleep 10
- name: Run benchmark
run: python benchmark/benchmark.py
- name: Generate image and commit to the new branch
run: |
python benchmark/generate_image.py
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git add \*.jpg
git diff --quiet && git diff --staged --quiet || git commit -m "Update generated image"
# Create a new branch and switch to it
git checkout -b update-generated-image
# Attempt to push changes to the new branch
git push https://${{ secrets.PUSH_TOKEN }}@github.com/deedy5/pyreqwest_impersonate.git update-generated-image || echo "No changes to push"
- name: Merge changes into main and delete temporary branch
run: |
# Fetch the latest changes from the remote repository
git fetch origin
# Merge the temporary branch into main
git checkout main
git merge update-generated-image
# Push the changes to the main branch
git push https://${{ secrets.PUSH_TOKEN }}@github.com/deedy5/pyreqwest_impersonate.git main
# Delete the temporary branch
git push origin --delete update-generated-image