Skip to content

Merge pull request #29 from piercefreeman/feature/branching-queries #142

Merge pull request #29 from piercefreeman/feature/branching-queries

Merge pull request #29 from piercefreeman/feature/branching-queries #142

Workflow file for this run

name: Library Tests and Release
on:
push:
branches: [main]
tags:
- "v*"
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.11", "3.12"]
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: iceaxe
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: iceaxe_test_db
ports:
- 5438:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install
- name: Run tests
run: |
poetry run pytest -v --continue-on-collection-errors
env:
ICEAXE_LOG_LEVEL: DEBUG
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install
- name: Run lint
run: make lint
full-build:
needs: [test, lint]
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Full Build') || startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Clean build artifacts
run: |
rm -rf build/
rm -rf iceaxe/*.so
rm -rf *.egg-info/
find . -type f -name "*.so" -delete
find . -type f -name "*.o" -delete
find . -type f -name "*.c" -delete
- name: Update version in pyproject.toml
if: startsWith(github.ref, 'refs/tags/v')
run: |
VERSION=${GITHUB_REF#refs/tags/v}
poetry version $VERSION
shell: bash
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build SDist
if: matrix.os == 'ubuntu-latest'
run: poetry build --format sdist
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_BUILD: cp311-* cp312-*
CIBW_SKIP: "*-musllinux*"
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_ENVIRONMENT: "CFLAGS='-std=c99'"
CIBW_BEFORE_BUILD: |
rm -rf {project}/build/
rm -rf {project}/*.egg-info/
find {project} -type f -name "*.so" -delete
find {project} -type f -name "*.o" -delete
find {project} -type f -name "*.c" -delete
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
path: |
dist/
wheelhouse/
release:
needs: [full-build]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/iceaxe
permissions:
id-token: write
steps:
- name: Download Ubuntu build
uses: actions/download-artifact@v4
with:
name: dist-ubuntu-latest
path: dist-raw/ubuntu
- name: Download macOS build
uses: actions/download-artifact@v4
with:
name: dist-macos-latest
path: dist-raw/macos
- name: Prepare distribution files
run: |
mkdir -p dist
cp -r dist-raw/ubuntu/dist/* dist/ 2>/dev/null || true
cp -r dist-raw/ubuntu/wheelhouse/* dist/ 2>/dev/null || true
cp -r dist-raw/macos/dist/* dist/ 2>/dev/null || true
cp -r dist-raw/macos/wheelhouse/* dist/ 2>/dev/null || true
echo "Content of dist directory:"
ls -la dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1