Skip to content

Commit

Permalink
feat: add Python binding
Browse files Browse the repository at this point in the history
ci: set up GitHub Release Action

chore: Release resp-benchmark-rust-lib version 0.1.2
  • Loading branch information
suxb201 committed Aug 8, 2024
1 parent b2b2bc4 commit 1578662
Show file tree
Hide file tree
Showing 28 changed files with 1,114 additions and 1,868 deletions.
7 changes: 0 additions & 7 deletions .github/release-drafter.yml

This file was deleted.

165 changes: 165 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: CI

on:
push:
branches:
- main
- master
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: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
- runner: ubuntu-latest
target: s390x
- runner: ubuntu-latest
target: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

musllinux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: musllinux_1_2
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: dist

windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

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.x
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist

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-*/*
119 changes: 10 additions & 109 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,122 +1,23 @@
name: release
name: Release

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
draft:
name: draft
release:
runs-on: ubuntu-latest
steps:
- name: draft release
id: "draft"
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
upload_url: ${{ steps.draft.outputs.upload_url }}

build-and-upload:
needs: draft
name: build - ${{ matrix.platform.release_for }}
strategy:
matrix:
platform:
- release_for: linux-amd64
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: resp-benchmark
name: resp-benchmark-linux-amd64.tar.gz
command: build

- release_for: linux-arm64
os: ubuntu-20.04
target: aarch64-unknown-linux-gnu
bin: resp-benchmark
name: resp-benchmark-linux-arm64.tar.gz
command: build

- release_for: windows-amd64
os: windows-latest
target: x86_64-pc-windows-msvc
bin: resp-benchmark.exe
name: resp-benchmark-windows-amd64.zip
command: build

- release_for: windows-arm64
os: windows-latest
target: aarch64-pc-windows-msvc
bin: resp-benchmark.exe
name: resp-benchmark-windows-arm64.zip
command: build

- release_for: macos-amd64
os: macos-latest
target: x86_64-apple-darwin
bin: resp-benchmark
name: resp-benchmark-macos-amd64.tar.gz
command: build

- release_for: macos-arm64
os: macos-latest
target: aarch64-apple-darwin
bin: resp-benchmark
name: resp-benchmark-macos-arm64.tar.gz
command: build
- uses: actions/checkout@v4

runs-on: ${{ matrix.platform.os }}
steps:
- name: checkout
uses: actions/checkout@v3

- name: cache cargo registry
uses: actions/cache@v3
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
components: rustfmt

- name: cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Install cargo-release
run: cargo install cargo-release

- name: cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "--locked --release"
strip: true
- name: Package as archive
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ${{ matrix.platform.name }} ${{ matrix.platform.bin }} ../../../workloads
else
tar czvf ${{ matrix.platform.name }} ${{ matrix.platform.bin }} ../../../workloads
fi
- name: upload
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.draft.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.target }}/release/${{ matrix.platform.name }}
asset_name: ${{ matrix.platform.name }}
asset_content_type: ${{ matrix.platform.os == 'windows-latest' && 'application/zip' || 'application/gzip' }}
- name: Run cargo release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo release patch --no-publish --execute --no-confirm
72 changes: 71 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,72 @@
target/
/target

# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
.venv/
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
include/
man/
venv/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
pip-selfcheck.json

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

.DS_Store

# Sphinx documentation
docs/_build/

# PyCharm
.idea/

# VSCode
.vscode/

# Pyenv
.python-version
Loading

0 comments on commit 1578662

Please sign in to comment.