Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ci and release github actions for easier maintenance #120

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build and upload to PyPI

on: [push]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Set test tag
if: ${{ !startsWith(github.event.ref, 'refs/tags/v') }}
run: git tag -f v0.0.0-dev0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't forget to remove it before merging.


- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SKIP: '*musllinux*'

- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Set test tag
if: ${{ !startsWith(github.event.ref, 'refs/tags/v') }}
run: git tag -f v0.0.0-dev0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.


- name: Build sdist
run: pipx run build --sdist
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's maybe avoid pipx,

pip install build
python -m build --sdist

is the more standard way.


- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

# upload to Test PyPI on regular commits
- uses: pypa/[email protected]
if: ${{ !startsWith(github.event.ref, 'refs/tags/v') }}
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

# upload to PyPI on every tag starting with 'v'
- uses: pypa/[email protected]
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
with:
password: ${{ secrets.PYPI_API_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install tox

- name: Run test
run: |
tox -e py
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
*.pyc
*.so
/build
/dist
MANIFEST
hiredis/version.py
*.egg-info
.eggs/
.tox/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# hiredis-py

[![Build Status](https://travis-ci.org/redis/hiredis-py.svg?branch=master)](https://travis-ci.org/redis/hiredis-py)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/muso9gbe316tjsac/branch/master?svg=true)](https://ci.appveyor.com/project/duyue/hiredis-py/)
[![Build Status](https://github.com/redis/hiredis-py/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/redis/hiredis-py/actions)
[![Wheel Build Status](https://github.com/redis/hiredis-py/actions/workflows/build.yaml/badge.svg?branch=master)](https://github.com/redis/hiredis-py/actions)

Python extension that wraps protocol parsing code in [hiredis][hiredis].
It primarily speeds up parsing of multi bulk replies.
Expand Down
5 changes: 4 additions & 1 deletion hiredis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from .hiredis import Reader, HiredisError, ProtocolError, ReplyError
from .version import __version__
try:
from .version import version as __version__
except ImportError:
__version__ = '0.0.0-dev'

__all__ = [
"Reader", "HiredisError", "ProtocolError", "ReplyError",
Expand Down
1 change: 0 additions & 1 deletion hiredis/version.py

This file was deleted.

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "hiredis/version.py"
8 changes: 2 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
from distutils.core import setup, Extension
import sys, importlib, os, glob, io

def version():
loader = importlib.machinery.SourceFileLoader("hiredis.version", "hiredis/version.py")
module = loader.load_module()
return module.__version__

ext = Extension("hiredis.hiredis",
sources=sorted(glob.glob("src/*.c") +
["vendor/hiredis/%s.c" % src for src in ("alloc", "read", "sds")]),
Expand All @@ -19,7 +14,6 @@ def version():

setup(
name="hiredis",
version=version(),
description="Python wrapper for hiredis",
long_description=io.open('README.md', 'rt', encoding='utf-8').read(),
long_description_content_type='text/markdown',
Expand All @@ -32,6 +26,8 @@ def version():
package_data={"hiredis": ["hiredis.pyi", "py.typed"]},
ext_modules=[ext],
python_requires=">=3.6",
use_scm_version=True,
setup_requires=['setuptools_scm'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[testenv]
usedevelop = True
commands = python test.py