refactor: Update CI workflow to include additional package installati… #126
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: ci | |
on: | |
pull_request: | |
branches: | |
- "main" | |
- "deps/*" | |
paths-ignore: | |
- "LICENSE" | |
- "SECURITY.md" | |
- "makefile" | |
- ".gitingore" | |
#- ".github/workflows/*" | |
push: | |
branches: | |
- "main" | |
- "release/*" | |
- "deps/*" | |
paths-ignore: | |
- "LICENSE" | |
- "SECURITY.md" | |
- "makefile" | |
- ".gitingore" | |
#- ".github/workflows/*" | |
env: | |
PKG_CONFIG_ALLOW_CROSS: 1 | |
PY_SQLX_VERSION: 0.0.1 # change when the run "release - check package version" | |
jobs: | |
rust-test: | |
# ignore because the pyo3 test not working | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install rust stable | |
uses: dtolnay/rust-toolchain@stable | |
- name: cache rust | |
uses: Swatinem/rust-cache@v2 | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- run: pip install -e . | |
env: | |
RUST_BACKTRACE: 1 | |
- name: run test | |
run: | | |
echo "cargo test -p pysqlx-core -> ignore because the pyo3 test not working" | |
#cargo test -p pysqlx-core | |
build-sdist: | |
name: build sdist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- run: pip install -U toml httpx | |
- name: production - check package version | |
if: github.ref == 'refs/heads/main' | |
run: | | |
python .github/prod.py | |
- name: release - check package version | |
if: contains(github.ref, 'release') | |
run: | | |
python .github/release.py | |
- uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
rust-toolchain: stable | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pypi_files_sdist | |
path: dist | |
build: | |
name: build on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }}) | |
strategy: | |
fail-fast: false | |
max-parallel: 16 | |
matrix: | |
os: [ubuntu, macos, windows] | |
target: [x86_64, aarch64] | |
manylinux: [auto] | |
include: | |
# manylinux for various platforms, plus x86_64 pypy | |
- os: ubuntu | |
manylinux: auto | |
target: i686 | |
- os: ubuntu | |
manylinux: auto | |
target: aarch64 | |
- os: ubuntu | |
manylinux: auto | |
target: armv7 | |
interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 | |
- os: ubuntu | |
manylinux: auto | |
target: ppc64le | |
interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 | |
- os: ubuntu | |
manylinux: auto | |
target: s390x | |
interpreter: 3.8 3.9 3.10 3.11 3.12 3.13 | |
- os: ubuntu | |
manylinux: auto | |
target: x86_64 | |
interpreter: pypy3.9 pypy3.10 | |
# musllinux | |
- os: ubuntu | |
manylinux: musllinux_1_1 | |
target: x86_64 | |
- os: ubuntu | |
manylinux: musllinux_1_1 | |
target: aarch64 | |
# macos; | |
# all versions x86_64 | |
# arm pypy and older pythons which can't be run on the arm hardware for PGO | |
- os: macos | |
target: x86_64 | |
- os: macos | |
target: aarch64 | |
interpreter: 3.8 3.9 pypy3.9 pypy3.10 | |
# windows | |
- os: windows | |
target: i686 | |
python-architecture: x86 | |
interpreter: 3.8 3.9 3.10 3.11 3.12 | |
exclude: | |
# See above; disabled for now. | |
- os: windows | |
target: aarch64 | |
- os: windows | |
target: x86_64 | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
architecture: ${{ matrix.python-architecture || 'x64' }} | |
- run: pip install -U toml httpx twine | |
- name: production - check package version | |
if: github.ref == 'refs/heads/main' | |
run: | | |
python .github/prod.py | |
- name: release - check package version | |
if: contains(github.ref, 'release') | |
run: | | |
python .github/release.py | |
- name: build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: ${{ matrix.manylinux }} | |
args: > | |
--release | |
--out dist | |
--interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' }} | |
rust-toolchain: stable | |
before-script-linux: | | |
# Detect the Linux distribution | |
if [ -f /etc/os-release ]; then | |
. /etc/os-release | |
DISTRO=$ID | |
else | |
echo "Unable to detect the Linux distribution." | |
exit 1 | |
fi | |
echo "OpenSSL Version-$(openssl version)" | |
# Install packages based on the detected distro | |
case $DISTRO in | |
arch) | |
echo "Detected Arch Linux" | |
pacman -S pkgconf openssl | |
;; | |
debian|ubuntu) | |
echo "Detected Debian or Ubuntu" | |
apt update && apt upgrade -y | |
apt install -y pkg-config libssl-dev openssl perl | |
apt install -y build-essential gcc make libpcre3-dev wget zlib1g-dev libssl-dev | |
;; | |
fedora) | |
echo "Detected Fedora" | |
dnf install -y pkgconf perl-FindBin perl-IPC-Cmd openssl-devel | |
;; | |
alpine) | |
echo "Detected Alpine Linux" | |
apk add pkgconf openssl-dev | |
;; | |
opensuse|suse) | |
echo "Detected openSUSE" | |
zypper install -y libopenssl-devel | |
;; | |
centos) | |
echo "Detected CentOS" | |
yum update -y | |
yum install -y make gcc perl-core pcre-devel wget zlib-devel openssl-devel | |
yum install -y openssl | |
;; | |
*) | |
echo "Unsupported Linux distribution: $DISTRO" | |
exit 1 | |
;; | |
esac | |
echo "Installation complete!" | |
# sccache is not supported on Windows | |
sccache: true | |
docker-options: -e CI | |
- run: ${{ (matrix.os == 'windows' && 'dir') || 'ls -lh' }} dist/ | |
- run: twine check --strict dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pypi_files_${{ matrix.os }}_${{ matrix.target }}_${{ matrix.interpreter || 'all' }}_${{ matrix.manylinux }} | |
path: dist | |
build-pgo: | |
name: pgo build on ${{ matrix.os }} / ${{ matrix.interpreter }} | |
strategy: | |
fail-fast: ${{ github.ref != 'refs/heads/main' }} | |
max-parallel: 16 | |
matrix: | |
os: [ubuntu, windows, macos] | |
interpreter: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
include: | |
# standard runners with override for macos arm | |
- os: ubuntu | |
runs-on: ubuntu-latest | |
- os: windows | |
ls: dir | |
runs-on: windows-latest | |
- os: macos | |
runs-on: macos-latest-xlarge | |
exclude: | |
# macos arm only supported from 3.10 and up | |
- os: macos | |
interpreter: '3.8' | |
- os: macos | |
interpreter: '3.9' | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.interpreter }} | |
allow-prereleases: true | |
- name: install rust stable | |
id: rust-toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: llvm-tools | |
- run: pip install -U toml httpx twine | |
- name: production - check package version | |
if: github.ref == 'refs/heads/main' | |
run: | | |
python .github/prod.py | |
- name: release - check package version | |
if: contains(github.ref, 'release') | |
run: | | |
python .github/release.py | |
- name: build pgo-optimized wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
#target: ${{ matrix.target }} | |
manylinux: 'auto' | |
args: > | |
--release | |
--out dist | |
--interpreter ${{ matrix.interpreter }} | |
rust-toolchain: stable | |
before-script-linux: | | |
cat /etc/*-release | |
docker-options: -e CI | |
- run: ${{ matrix.ls || 'ls -lh' }} dist/ | |
- run: twine check --strict dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pypi_files_${{ matrix.os }}_${{ matrix.interpreter }} | |
path: dist | |
release: | |
name: Release | |
if: contains(github.ref, 'main') || contains(github.ref, 'release') && !cancelled() && success() | |
needs: [rust-test, build-sdist, build, build-pgo] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: install deps | |
run: pip install -U twine toml httpx | |
- name: production - check package version | |
if: github.ref == 'refs/heads/main' | |
run: | | |
python .github/prod.py | |
- name: release - check package version | |
if: contains(github.ref, 'release') | |
run: | | |
python .github/release.py | |
- name: get dist artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: pypi_files_* | |
merge-multiple: true | |
path: dist | |
- run: twine check --strict dist/* | |
- name: upload to pypi | |
run: twine upload dist/* --verbose | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
- name: create release | |
if: github.ref == 'refs/heads/main' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.PY_SQLX_VERSION }} | |
release_name: ${{ env.PY_SQLX_VERSION }} | |
body: | | |
Changes in this Release | |
${{ github.event.head_commit.message }} | |
draft: false | |
prerelease: false |