Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Commit

Permalink
Switch to GitHub actions for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rossmacarthur committed Feb 1, 2020
1 parent c4e1937 commit dbf28eb
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 197 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: build

on: [push]

jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, pypy2, 3.5, 3.6, 3.7, 3.8, pypy3]

steps:
- uses: actions/checkout@v1

- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- run: echo "::set-env name=VIRTUAL_ENV::$(printf ${{ env.pythonLocation }} | sed 's/\/bin$//g')"

- name: Install just
run: |
curl --proto '=https' -fLsS https://rossmacarthur.github.io/install/crate.sh \
| bash -s -- --repo casey/just --to $GITHUB_WORKSPACE/bin
echo "::add-path::$GITHUB_WORKSPACE/bin"
- name: Install dependencies
run: just install-all

- name: Lint
run: just lint

- name: Test
run: just test

- name: Upload coverage report to Codecov
if: matrix.python-version == 3.7
run: pip install codecov && codecov --slug=$GITHUB_REPOSITORY --branch=$GITHUB_REF --commit=$GITHUB_SHA
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy:
needs: test
if: startsWith(github.event.ref, 'refs/tags')

name: Deploy Python package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install dependencies
run: pip install --upgrade setuptools twine wheel

- name: Build distribution
run: python setup.py sdist bdist_wheel

- name: Publish artefacts
run: twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

79 changes: 31 additions & 48 deletions Justfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,71 +1,54 @@
#!/usr/bin/env just

export PYTHON := "python"
export VIRTUAL_ENV := env_var_or_default("VIRTUAL_ENV", "venv")
export VIRTUAL_ENV := env_var("VIRTUAL_ENV")

# Show this message and exit.
help:
@just --list

# Remove all build artifacts.
clean:
rm -rf venv build dist wheels
find . \( -name *.pyc -o -name *.pyo -o -name __pycache__ -o -name *.egg-info \) -exec rm -rf {} +
# Run any Just command but only if we are using the given Python version.
_python VERSION COMMAND +ARGS='':
@if $VIRTUAL_ENV/bin/python \
-c "import platform as p;print ('{} {}'.format(p.python_version(), p.python_implementation()))" \
| grep -q "^{{ VERSION }}"; then \
just {{ COMMAND }} {{ ARGS }}; \
fi

# Create a virtualenv.
venv:
#!/usr/bin/env sh -x
case "$($PYTHON --version)" in
"Python 3"*)
$PYTHON -m venv venv;;
*)
virtualenv --python "$PYTHON" venv;;
esac
# Completely removing anything not tracked by Git.
pristine:
git reset --hard && git clean -dfx

# Check the VIRTUAL_ENV variable, and if it is not set create a virtualenv.
check-venv:
#!/usr/bin/env sh
if [ "$VIRTUAL_ENV" = "venv" ]; then
just create-env
else
echo "Not creating virtualenv because VIRTUAL_ENV is set."
fi
# Remove all build artefacts.
clean:
rm -rf build dist wheels
find . \( -name *.pyc -o -name *.pyo -o -name __pycache__ -o -name *.egg-info \) -exec rm -rf {} +

# Install package and all features.
install: check-venv
# Install package.
install:
$VIRTUAL_ENV/bin/pip install -e ".[ext]"

# Install package, all features, and all development dependencies.
install-all: check-venv
$VIRTUAL_ENV/bin/pip install -r ci/requirements/lint.txt -r ci/requirements/test.txt -e ".[ext]"
# Install package and development dependencies.
install-all:
$VIRTUAL_ENV/bin/pip install -r dev-requirements.in -e ".[ext]"

_black +ARGS='':
$VIRTUAL_ENV/bin/black --target-version py27 --skip-string-normalization . {{ ARGS }}

# Run all lints.
lint:
$VIRTUAL_ENV/bin/black --target-version py27 --skip-string-normalization --check .
@just _python '3.[6-9].*C' _black --check
$VIRTUAL_ENV/bin/flake8 --max-complexity 10 .

# Blacken and sort import statements
# Sort import statements and run black.
blacken:
$VIRTUAL_ENV/bin/isort --recursive .
$VIRTUAL_ENV/bin/black --target-version py27 --skip-string-normalization .
@just _python '3.[6-9].*C' _black

# Run tests excluding doctests.
test:
$VIRTUAL_ENV/bin/pytest -vv --cov=serde --cov-report term-missing
_test +ARGS='':
$VIRTUAL_ENV/bin/pytest -xvv --cov=serde --cov-report term-missing {{ ARGS }} tests

# Run all tests.
test-all:
$VIRTUAL_ENV/bin/pytest -vv --cov=serde --cov-report term-missing --cov-fail-under 100 \
--doctest-modules --doctest-import "*<serde"

# Build source and wheel package.
dist: clean
$VIRTUAL_ENV/bin/python setup.py sdist bdist_wheel --universal
@ls -l dist

# Package and upload a release.
release: dist
$VIRTUAL_ENV/bin/twine upload dist/*
test:
@just _python '\(2\|3.5\)' _test
@just _python 3.[6-9] _test --cov-fail-under 100

# Compile docs.
docs:
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Serde
:target: https://ross.macarthur.io/project/serde/
:alt: Documentation Status

.. image:: https://img.shields.io/travis/rossmacarthur/serde/master.svg?style=flat-square
:target: https://travis-ci.org/rossmacarthur/serde
.. image:: https://img.shields.io/github/workflow/status/rossmacarthur/serde/build/master?style=flat-square
:target: https://github.com/rossmacarthur/serde/actions?query=workflow%3Abuild
:alt: Build Status

.. image:: https://img.shields.io/codecov/c/github/rossmacarthur/serde.svg?style=flat-square
Expand Down
7 changes: 0 additions & 7 deletions ci/after_success.sh

This file was deleted.

9 changes: 0 additions & 9 deletions ci/before_install.sh

This file was deleted.

13 changes: 0 additions & 13 deletions ci/install.sh

This file was deleted.

10 changes: 0 additions & 10 deletions ci/requirements/lint.in

This file was deleted.

29 changes: 0 additions & 29 deletions ci/requirements/lint.txt

This file was deleted.

4 changes: 0 additions & 4 deletions ci/requirements/test.in

This file was deleted.

21 changes: 0 additions & 21 deletions ci/requirements/test.txt

This file was deleted.

13 changes: 0 additions & 13 deletions ci/script.sh

This file was deleted.

16 changes: 16 additions & 0 deletions dev-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Linting requirements
black; python_version>="3.6" and implementation_name=="cpython"
flake8
flake8-bugbear; python_version>="3"
flake8-comprehensions
flake8-docstrings
flake8-isort
flake8-mutable
flake8-pep3101
flake8-quotes
pep8-naming

# Testing requirements
mock
pytest
pytest-cov
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ per-file-ignores =
src/serde/__init__.py: D205
src/serde/validators.py: D102,D107
tests/*: D
tests/test_model_py36.py: D,E999

[isort]
balanced_wrapping = true
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def get_metadata():
metadata = get_metadata()

# Primary requirements
install_requires = ['isodate >=0.6.0, <0.7.0', 'six >=1.0.0, <2.0.0']
ext_requires = ['chardet >=3.0.0, <4.0.0', 'validators >=0.12.0, <0.15.0']
install_requires = ['isodate==0.6.*', 'six==1.*']
ext_requires = ['chardet==3.*', 'validators>=0.12.0,<0.15.0']

setup(
# Options
Expand Down

0 comments on commit dbf28eb

Please sign in to comment.