Skip to content

Commit

Permalink
migrate to gh actions, add tests and publish wheel (#44)
Browse files Browse the repository at this point in the history
* migrate to gh actions, add tests and publish wheel
* downgrade ubuntu
* drop explicit support for py3.4 and py3.5 since tests are using fstrings
* revert back to actual pypi
* remove tests in setup.py
* chore: py3 only classifier
  • Loading branch information
thatlittleboy authored Aug 3, 2024
1 parent ed92246 commit 23eea4a
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 59 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Upload to PyPI

on:
release:
types: [created]

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

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Set up Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine
- name: Build and Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
rm -f dist/*
python setup.py sdist bdist_wheel
twine upload dist/*
51 changes: 51 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tests

on:
# only run tests when src code changes
push:
branches:
- master
paths:
- "markdownextradata/**"
- "test/**"
- ".github/workflows/tests.yml"
pull_request:
branches:
- master
paths:
- "markdownextradata/**"
- "test/**"
- ".github/workflows/tests.yml"

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

jobs:
run-pytest:
name: Run pytest tests
# NOTE: we can change back to ubuntu-latest if we drop support for py3.6
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Set up Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install mkdocs pyyaml pytest click
python -m pip install -e .
- name: Run pytest
run: |
pytest test -s
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

38 changes: 9 additions & 29 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
import os
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand


def read(fname):
file_path = os.path.join(os.path.dirname(__file__), fname)
with open(file_path) as file:
content = file.read()
return content if content else 'no content read'

class PyTest(TestCommand):
user_options = []

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []

def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)

setup(
name='mkdocs-markdownextradata-plugin',
version='0.2.4',
version='0.2.5',
description='A MkDocs plugin that injects the mkdocs.yml extra variables into the markdown template',
long_description=read('README.md'),
long_description_content_type='text/markdown',
Expand All @@ -33,14 +20,7 @@ def run_tests(self):
author='Ross Crawford-d\'Heureuse',
author_email='[email protected]',
license='MIT',
tests_require=[
'pytest',
'mkdocs',
'pyyaml',
'click',
],
cmdclass = {'test': PyTest},
python_requires='>=2.7.9,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
python_requires='>=3.6',
install_requires=[
'mkdocs',
'pyyaml',
Expand All @@ -51,13 +31,13 @@ def run_tests(self):
'Intended Audience :: Information Technology',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
packages=find_packages(exclude=['*.tests']),
entry_points={
Expand Down

0 comments on commit 23eea4a

Please sign in to comment.