Skip to content

Commit 6ce54cf

Browse files
mbarkhaufruch
andauthored
Add GitHub Actions (#27)
Add GH Actions to run nox tests and build dist files Co-authored-by: Israel Fruchter <[email protected]>
1 parent 4715eaf commit 6ce54cf

File tree

4 files changed

+123
-5
lines changed

4 files changed

+123
-5
lines changed

.github/workflows/nox-test.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
name: Run nox Tests
3+
4+
on:
5+
push:
6+
pull_request:
7+
types: [opened]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
name: Lint
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Setup git submodule
16+
run: git submodule update --init --recursive
17+
- name: Setup python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.8'
21+
architecture: x64
22+
- name: Setup virtualenv
23+
run: |
24+
# Always install nox into Python 3, regardless of the Python version used.
25+
python3 -m venv noxenv
26+
noxenv/bin/pip install nox
27+
- name: Run lint
28+
run: |
29+
export NOXSESSION="lint"
30+
noxenv/bin/nox
31+
32+
test:
33+
runs-on: ubuntu-latest
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
python-version: [ '2.7', '3.6', '3.7', '3.8', '3.9' ]
38+
name: Test Python ${{ matrix.python-version }}
39+
steps:
40+
- uses: actions/checkout@v2
41+
- name: Setup git submodule
42+
run: git submodule update --init --recursive
43+
- name: Setup python
44+
uses: actions/setup-python@v2
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
architecture: x64
48+
- name: Setup virtualenv
49+
run: |
50+
# Always install nox into Python 3, regardless of the Python version used.
51+
python3 -m venv noxenv
52+
noxenv/bin/pip install nox
53+
- name: Run nox tests
54+
run: |
55+
export NOXSESSION="unit-${{ matrix.python-version }}"
56+
noxenv/bin/nox

.github/workflows/pypi-publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Build and Publish Python Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
env:
11+
CIBW_SKIP: "cp27-* cp35-* pp*"
12+
13+
jobs:
14+
build_wheels:
15+
name: Build wheels on ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-18.04, windows-latest, macos-latest]
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Setup git submodule
24+
run: git submodule update --init --recursive
25+
26+
- name: Checkout cmark-gfm
27+
uses: actions/checkout@v2
28+
with:
29+
repository: github/cmark-gfm
30+
path: cmark-gfm
31+
32+
- uses: actions/setup-python@v2
33+
name: Install Python
34+
with:
35+
python-version: '3.7'
36+
37+
- name: Install cibuildwheel
38+
run: |
39+
python -m pip --disable-pip-version-check install cibuildwheel==1.6.4
40+
41+
- name: Install Visual C++ for Python 2.7
42+
if: runner.os == 'Windows'
43+
run: |
44+
choco install vcpython27 -f -y
45+
46+
- name: Build wheels
47+
run: |
48+
python -m cibuildwheel --output-dir wheelhouse
49+
50+
- uses: actions/upload-artifact@v2
51+
with:
52+
path: ./wheelhouse/*.whl
53+
54+
- name: Publish
55+
env:
56+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
57+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
58+
run: twine upload --skip-existing ./wheelhouse/*

noxfile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import nox
66

77

8-
@nox.session(py=['2.7', '2.7-32', '3.5', '3.6', '3.7', '3.8'])
8+
@nox.session(py=['2.7', '2.7-32', '3.5', '3.6', '3.7', '3.8', '3.9'])
99
def unit(session):
1010
session.install('pytest', 'pytest-cov')
1111
session.install('.')
@@ -20,8 +20,9 @@ def unit(session):
2020

2121
@nox.session
2222
def lint(session):
23-
session.install('flake8', 'readme_renderer')
24-
session.run('flake8', 'cmarkgfm', 'tests')
23+
session.install('flake8')
24+
session.run('flake8', 'src/cmarkgfm', 'tests')
25+
session.install('readme_renderer')
2526
session.run('python', 'setup.py', 'check', '-m', '-r', '-s')
2627

2728

src/cmarkgfm/build_cmark.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
UNIX_GENERATED_SRC_DIR = os.path.join(PACKAGE_ROOT, 'generated', 'unix')
1818
WIN_GENERATED_SRC_DIR = os.path.join(PACKAGE_ROOT, 'generated', 'windows')
1919

20-
with io.open(os.path.join(HERE, 'cmark.cffi.h'), 'r', encoding='utf-8') as fh:
20+
CMARK_DEF_H_PATH = os.path.join(HERE, 'cmark.cffi.h')
21+
CMARK_MODULE_H_PATH = os.path.join(HERE, 'cmark_module.h')
22+
23+
with io.open(CMARK_DEF_H_PATH, 'r', encoding='utf-8') as fh:
2124
CMARK_DEF_H = fh.read()
2225

23-
with io.open(os.path.join(HERE, 'cmark_module.h'), 'r', encoding='utf-8') as fh:
26+
with io.open(CMARK_MODULE_H_PATH, 'r', encoding='utf-8') as fh:
2427
CMARK_MODULE_H = fh.read()
2528

2629

0 commit comments

Comments
 (0)