Skip to content

Commit

Permalink
chore(workflows): update workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
caizhengxin committed Sep 14, 2024
1 parent 2aac2ac commit 043f139
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 17 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# @Author: jankincai
# @Date: 2024-09-13 10:48:33
# @Last Modified by: jankincai
# @Last Modified time: 2024-09-14 11:21:11

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
push:
branches: [ "master" ]

release:
types: [published]

permissions:
contents: read

jobs:
deploy:
name: Build and publish Python to PyPI and TestPyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
sudo apt install libpcap-dev
- name: Build package
run: python -m build -s
- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# @Author: jankincai
# @Date: 2024-09-12 10:45:37
# @Last Modified by: jankincai
# @Last Modified time: 2024-09-12 10:56:55
# @Last Modified time: 2024-09-14 11:16:35

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package
name: Tests

on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master", "develop" ]

jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.6"]

steps:
- uses: actions/checkout@v4
Expand All @@ -30,11 +32,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install flake8 pytest tox
sudo apt install libpcap-dev
- name: Lint with flake8
run: |
flake8 pylibpcap
run: flake8 pylibpcap
- name: Test with pytest
run: |
pytest
python -m pip install -e .
pytest .
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# @Author: jankincai
# @Date: 2024-09-12 10:45:37
# @Last Modified by: jankincai
# @Last Modified time: 2024-09-12 17:18:27

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Tests

on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master", "develop" ]

jobs:
build:

runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest tox
sudo apt install libpcap-dev
- name: Lint with flake8
run: flake8 pylibpcap
- name: Run tox targets for ${{ matrix.python-version }}
run: python -m tox
# - name: Test with pytest
# run: |
# pytest .
11 changes: 4 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: JanKinCai
# @Date: 2019-11-09 10:08:53
# @Last Modified by: jankincai
# @Last Modified time: 2024-09-12 10:31:22
# @Last Modified time: 2024-09-14 10:04:08
import os
import glob

Expand All @@ -12,10 +12,6 @@
from Cython.Distutils import build_ext


with open('README.md') as f:
long_description = f.read()


def read_requirements(path):
"""read requirements
Expand Down Expand Up @@ -59,7 +55,7 @@ def read_requirements(path):

setup(
name="python-libpcap",
version="0.5.0",
version="0.5.1",
author="JanKinCai",
author_email="[email protected]",
maintainer="JanKinCai",
Expand All @@ -68,7 +64,8 @@ def read_requirements(path):
download_url="https://github.com/caizhengxin/python-libpcap.git",
license="BSD",
description="Cython libpcap",
long_description=long_description,
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
keywords=[
"python-libpcap",
"pylibpcap",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36, flake8
envlist = py36, py37, py38, py39, py310, py311, py312, flake8
requires = Cython

[testenv]
Expand Down

0 comments on commit 043f139

Please sign in to comment.