Skip to content

Commit

Permalink
refactor: ♻️ tooling, packaging, and CI/CD overhaul, and update to Hy…
Browse files Browse the repository at this point in the history
…perscan 5.4.2
  • Loading branch information
darvid committed Aug 7, 2023
1 parent 80b5834 commit 1b823c9
Show file tree
Hide file tree
Showing 25 changed files with 2,148 additions and 2,200 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.vscode
build
dist
wheelhouse
59 changes: 59 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Lint

on:
- pull_request_target

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest

# setting any permission will set everything else to none for GITHUB_TOKEN
permissions:
pull-requests: none

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11

- name: Install dependencies
run: |
pip install pytest ruff black
- name: Format with clang-format
uses: DoozyX/clang-format-lint-action@v0.11
with:
source: "./src"
extensions: "c"
clangFormatVersion: 9
inplace: True

- name: Format with black
uses: psf/black@stable
with:
options: "--verbose"
src: "./src"
version: "~= 23.0"

- name: Format with ruff
uses: chartboost/ruff-action@v1
with:
src: "./src"
args: check --fix

- name: Commit formatting changes
uses: EndBug/add-and-commit@v4
with:
message: "style: autoformatting"
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
101 changes: 0 additions & 101 deletions .github/workflows/main.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Semantic release
on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write
if: github.repository == 'darvid/python-hyperscan'

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/download-artifact@v3
with:
name: wheelhouse
path: wheelhouse

- name: Semantic release
id: release
uses: python-semantic-release/python-semantic-release@v8.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.release.outputs.released == 'true'

- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/upload-to-gh-release@main
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
115 changes: 115 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build wheels
on:
push:
branches:
- main
- "v[0-9]+.[0-9]+"
tags:
- "v*"
pull_request:
branches:
- main
- "v[0-9]+.[0-9]+"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build_wheels:
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}
runs-on: ${{ matrix.os }}
if: github.repository == 'darvid/python-hyperscan'

strategy:
fail-fast: false
matrix:
include:
# TODO: Windows support
# Linux 64 bit manylinux2014
- os: ubuntu-latest
python: 3.8
python_id: 38
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 3.9
python_id: 39
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 3.10
python_id: 310
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 3.11
python_id: 311
platform_id: manylinux_x86_64

# Linux 64 bit musllinux
- os: ubuntu-latest
python: 3.8
python_id: 38
platform_id: musslinux_1_1
- os: ubuntu-latest
python: 3.9
python_id: 39
platform_id: musslinux_1_1
- os: ubuntu-latest
python: 3.10
python_id: 310
platform_id: musslinux_1_1
- os: ubuntu-latest
python: 3.11
python_id: 311
platform_id: musslinux_1_1

# MacOS x86_64
- os: macos-latest
python: 3.8
python_id: 38
platform_id: macosx_x86_64
- os: macos-latest
python: 3.9
python_id: 39
platform_id: macosx_x86_64
- os: macos-latest
python: 3.10
python_id: 310
platform_id: macosx_x86_64
- os: macos-latest
python: 3.11
python_id: 311
platform_id: macosx_x86_64

steps:
- name: Checkout python-hyperscan
uses: actions/checkout@v3

- uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python }}
cache: true

- name: Python Semantic Release
uses: python-semantic-release/python-semantic-release@v8.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
push: "false"

- name: Build source distribution
run: |
pdm build --no-wheel
- name: Build and test wheels
env:
CIBW_BUILD: cp${{ matrix.python_id }}-${{ matrix.platform_id }}
CIBW_BUILD_VERBOSITY: 1
run: bash ./build_tools/wheels/build_wheels.sh

- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: |
dist/*.tar.gz
wheelhouse/*.whl
Loading

0 comments on commit 1b823c9

Please sign in to comment.