Skip to content

Commit 151d433

Browse files
authored
Implement GitHub Actions for tests, releases (#76)
* Create run-tests.yml First pass at GitHub Actions workflow for testing * Update README.md - remove Travis Badge - update Python Version badge * Delete .travis.yml * Update run-tests.yml Use coverage/coveralls * Create publish-package.yml * Delete appveyor.yml * implement scm_version * Update run-tests.yml add manual trigger (workflow_dispatch) * Update run-tests.yml add GITHUB_TOKEN env to test run step * Update run-tests.yml fix env bug
1 parent baa9560 commit 151d433

11 files changed

+121
-102
lines changed

.github/workflows/publish-package.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build and Publish Python Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9].*'
7+
8+
jobs:
9+
create_release:
10+
name: Create GitHub Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Create release
14+
uses: actions/create-release@v1
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
with:
18+
tag_name: ${{ github.ref }}
19+
release_name: ${{ github.ref }}
20+
draft: false
21+
prerelease: true
22+
23+
deploy:
24+
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Set up Python
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: '3.x'
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install setuptools wheel twine
37+
- name: Build and publish
38+
env:
39+
TWINE_USERNAME: __token__
40+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
41+
run: |
42+
python setup.py sdist bdist_wheel
43+
twine upload dist/*

.github/workflows/run-tests.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
inputs:
10+
reason:
11+
description: 'Reason for running workflow'
12+
required: true
13+
14+
jobs:
15+
build:
16+
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
python-version: ['3.6', '3.7', '3.8', '3.9']
21+
22+
steps:
23+
- name: Log reason (manual run only)
24+
if: github.event_name == 'workflow_dispatch'
25+
run: |
26+
echo "Reason for triggering: ${{ github.event.inputs.reason }}"
27+
28+
- uses: actions/checkout@v2
29+
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
python -m pip install flake8 coveralls
39+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
40+
41+
- name: Lint with flake8
42+
run: |
43+
flake8 --count --show-source --statistics
44+
45+
- name: Run test suite & upload coverage
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
coverage run setup.py test
50+
coveralls

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ docs/_build/
5858

5959
# PyBuilder
6060
target/
61+
62+
# scm version
63+
src/_version.py

.travis.yml

-23
This file was deleted.

MANIFEST.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include README.md
22
include LICENSE.txt
3-
include appveyor.yml
4-
include .travis.yml
3+
recursive-include src/ *.py
54
recursive-include tests/ *.py
65
recursive-include tests/data/ *.glif

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
[![Build Status](https://travis-ci.org/unified-font-object/ufoNormalizer.svg)](https://travis-ci.org/unified-font-object/ufoNormalizer)
2-
[![Build status](https://ci.appveyor.com/api/projects/status/pc4l0dryn5hevcw4?svg=true)](https://ci.appveyor.com/project/miguelsousa/ufonormalizer)
31
[![Coverage Status](https://coveralls.io/repos/unified-font-object/ufoNormalizer/badge.svg?branch=master&service=github)](https://coveralls.io/github/unified-font-object/ufoNormalizer?branch=master)
4-
![Python Versions](https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5-blue.svg)
2+
![Python Versions](https://img.shields.io/badge/python-3.6%2C%203.7%2C%203.8%2C%203.9-blue.svg)
53
[![PyPI Version](https://img.shields.io/pypi/v/ufonormalizer.svg)](https://pypi.python.org/pypi/ufonormalizer)
64

75
# ufoNormalizer

appveyor.yml

-35
This file was deleted.

pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
3+
4+
[tool.setuptools_scm]
5+
write_to = 'src/_version.py'
6+
write_to_template = '__version__ = "{version}"'

setup.cfg

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
1-
[bumpversion]
2-
current_version = 0.4.3.dev0
3-
commit = True
4-
tag = False
5-
tag_name = {new_version}
6-
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
7-
serialize =
8-
{major}.{minor}.{patch}.{release}{dev}
9-
{major}.{minor}.{patch}
10-
11-
[bumpversion:part:release]
12-
optional_value = final
13-
values =
14-
dev
15-
final
16-
17-
[bumpversion:part:dev]
18-
19-
[bumpversion:file:src/ufonormalizer.py]
20-
search = __version__ = "{current_version}"
21-
replace = __version__ = "{new_version}"
22-
23-
[wheel]
24-
universal = 1
25-
261
[sdist]
272
formats = zip
283

294
[metadata]
305
license_file = LICENSE.txt
316

7+
[options]
8+
setup_requires = setuptools_scm

setup.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
11
from setuptools import setup
2-
from io import open
3-
import ast
4-
5-
6-
with open('src/ufonormalizer.py', 'r', encoding='utf-8') as f:
7-
for line in f:
8-
if line.startswith(u'__version__'):
9-
version = ast.parse(line).body[0].value.s
10-
break
11-
else:
12-
raise RuntimeError("No __version__ string found!")
132

143

154
setup(
165
name="ufonormalizer",
17-
version=version,
186
description=("Script to normalize the XML and other data "
197
"inside of a UFO."),
208
author="Tal Leming",
219
author_email="[email protected]",
2210
url="https://github.com/unified-font-object/ufoNormalizer",
2311
package_dir={"": "src"},
24-
py_modules=['ufonormalizer'],
12+
py_modules=['ufonormalizer', '_version'],
2513
entry_points={
2614
'console_scripts': [
2715
"ufonormalizer = ufonormalizer:main",
2816
]
2917
},
18+
use_scm_version={
19+
"write_to": 'src/_version.py',
20+
"write_to_template": '__version__ = "{version}"',
21+
},
22+
setup_requires=['setuptools_scm'],
3023
test_suite="tests",
3124
license="OpenSource, BSD-style",
3225
platforms=["Any"],
@@ -46,4 +39,5 @@
4639
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
4740
],
4841
python_requires='>=3.6',
42+
zip_safe=True,
4943
)

src/ufonormalizer.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@
1515
from io import open
1616
import logging
1717

18+
try:
19+
from _version import __version__
20+
except ImportError:
21+
try:
22+
from setuptools_scm import get_version
23+
__version__ = get_version()
24+
except ImportError:
25+
__version__ = 'unknown'
1826

1927
"""
2028
- filter out unknown attributes and subelements
2129
- add doctests for the image purging
2230
- things that need to be improved are marked with "# TO DO"
2331
"""
2432

25-
__version__ = "0.4.3.dev0"
2633
description = f"""
2734
UFO Normalizer (version {__version__}):
2835

0 commit comments

Comments
 (0)