Fix ZRAM kmod not installed in CI (#34) #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- '**' | |
tags: | |
- 'v*' | |
pull_request: | |
paths-ignore: | |
- 'README*' | |
- 'logo.*' | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Publish to PyPI' | |
default: false | |
required: true | |
type: boolean | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{matrix.arch}} for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-20.04, windows-2019, macos-11 ] | |
arch: [ auto ] | |
rust_target: [ '' ] | |
include: | |
- os: ubuntu-20.04 | |
arch: aarch64 | |
rust_target: '' | |
# FIXME: disabled due to linker issue | |
# - os: windows-2022 | |
# arch: ARM64 | |
# rust_target: 'aarch64-pc-windows-msvc' | |
- os: macos-11 | |
arch: arm64 | |
rust_target: 'aarch64-apple-darwin' | |
steps: | |
- name: Enable zram | |
# prevent OOM killer from killing cargo (especially aarch64) | |
# PERCENTAGE=100 is safe: https://fedoraproject.org/wiki/Changes/Scale_ZRAM_to_full_memory_size | |
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.arch == 'aarch64' }} | |
run: | | |
sudo apt-get update -yq | |
sudo apt-get install -yq "linux-modules-extra-$(uname -r)" zram-tools | |
echo -e 'CORES=1\nPERCENTAGE=100' | sudo tee -a /etc/default/zramswap | |
sudo systemctl restart zramswap | |
swapon | |
- name: Add Rust cross target | |
if: ${{ matrix.rust_target != '' }} | |
run: rustup target add ${{ matrix.rust_target }} | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v2 | |
if: ${{ matrix.arch == 'aarch64' }} | |
name: Set up QEMU | |
- uses: pypa/cibuildwheel@v2.16.5 | |
env: | |
CIBW_BUILD_VERBOSITY: "1" | |
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel" | |
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"' | |
CIBW_ARCHS: ${{matrix.arch}} | |
CIBW_SKIP: 'cp36-* *musllinux*' | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
- name: Build sdist | |
run: python -m pip install -r requirements.txt && python setup.py sdist | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: dist/*.tar.gz | |
upload_pypi: | |
needs: [ build_wheels, build_sdist ] | |
runs-on: ubuntu-20.04 | |
if: ${{ startsWith(github.ref, 'refs/tags/v') || inputs.publish }} | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@v1.5.1 | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_token }} |