From 7fe6520575285e796c24c18ccd0b693ff9cf57d2 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sat, 18 Apr 2020 15:14:39 +0100 Subject: [PATCH] Switch to github CI --- .circleci/config.yml | 20 ----------- .github/workflows/main.yml | 63 ++++++++++++++++++++++++++++++++++ .gitignore | 69 +++++--------------------------------- scripts/ci/run | 7 ++++ scripts/release | 47 ++++++++++++++++++++++++++ setup.py | 40 +++++++++++----------- tox.ini | 5 ++- 7 files changed, 147 insertions(+), 104 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/main.yml create mode 100755 scripts/ci/run create mode 100755 scripts/release diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 165d385..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: 2 - -jobs: - build_and_test: - docker: - - image: circleci/python:latest - - steps: - - checkout - - - run: python3 -m pip install --user tox - - run: python3 -m tox - - - -workflows: - version: 2 - build_and_test: - jobs: - - build_and_test diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9494398 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,63 @@ +# see https://github.com/karlicoss/pymplate for up-to-date reference + +name: CI +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + # TODO shit. matrix is going to prevent from twine deployments because of version conflicts?? + # add 'and' clause?? + + steps: + # fuck me. https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path + - run: echo "::add-path::$HOME/.local/bin" + + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/checkout@v2 + with: + submodules: recursive + + # uncomment for SSH debugging + # - uses: mxschmitt/action-tmate@v2 + + - run: scripts/ci/run + + pypi: + runs-on: ubuntu-latest + needs: build + + steps: + - run: echo "::add-path::$HOME/.local/bin" + + - uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: 'release to test pypi' + # always deploy merged master to test pypi + if: github.event.ref == 'refs/heads/master' + env: + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }} + run: pip3 install --user wheel twine && scripts/release --test + + - name: 'release to pypi' + # always deploy tags to release pypi + # TODO filter release tags only? + if: startsWith(github.event.ref, 'refs/tags') + env: + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + run: pip3 install --user wheel twine && scripts/release + +# todo generate mypy coverage artifacts? diff --git a/.gitignore b/.gitignore index 7bd0d6e..7f13069 100644 --- a/.gitignore +++ b/.gitignore @@ -45,28 +45,13 @@ flycheck_*.el # projectiles files .projectile -projectile-bookmarks.eld # directory configuration .dir-locals.el -# saveplace -places +# network security +/network-security.data -# url cache -url/cache/ - -# cedet -ede-projects.el - -# smex -smex-items - -# company-statistics -company-statistics-cache.el - -# anaconda-mode -anaconda-mode/ ### Python ### # Byte-compiled / optimized / DLL files @@ -124,16 +109,6 @@ coverage.xml *.mo *.pot -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - # Scrapy stuff: .scrapy @@ -143,13 +118,6 @@ docs/_build/ # PyBuilder target/ -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - # pyenv .python-version @@ -166,15 +134,6 @@ celerybeat-schedule # SageMath parsed files *.sage.py -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - # Spyder project settings .spyderproject .spyproject @@ -182,6 +141,11 @@ venv.bak/ # Rope project settings .ropeproject +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + # mkdocs documentation /site @@ -190,22 +154,7 @@ venv.bak/ .dmypy.json dmypy.json -### Python Patch ### -.venv/ - -### Python.VirtualEnv Stack ### -# Virtualenv -# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ -[Bb]in -[Ii]nclude -[Ll]ib -[Ll]ib64 -[Ll]ocal -[Ss]cripts -pyvenv.cfg -pip-selfcheck.json - +# Pyre type checker +.pyre/ # End of https://www.gitignore.io/api/python,emacs - -cov diff --git a/scripts/ci/run b/scripts/ci/run new file mode 100755 index 0000000..c49e635 --- /dev/null +++ b/scripts/ci/run @@ -0,0 +1,7 @@ +#!/bin/bash -eu + +cd "$(dirname "$0")" +cd ../.. + +pip3 install --user tox +tox diff --git a/scripts/release b/scripts/release new file mode 100755 index 0000000..2f12eff --- /dev/null +++ b/scripts/release @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +import os +import sys +from pathlib import Path +from subprocess import check_call +import shutil + + +def main(): + import argparse + p = argparse.ArgumentParser() + p.add_argument('--test', action='store_true', help='use test pypi') + args = p.parse_args() + + extra = [] + if args.test: + extra.extend(['--repository-url', 'https://test.pypi.org/legacy/']) + + root = Path(__file__).absolute().parent.parent + os.chdir(root) # just in case + + dist = root / 'dist' + if dist.exists(): + shutil.rmtree(dist) + + check_call('python3 setup.py sdist bdist_wheel', shell=True) + + TP = 'TWINE_PASSWORD' + password = os.environ.get(TP) + if password is None: + print(f"WARNING: no {TP} passed", file=sys.stderr) + import pip_secrets + password = pip_secrets.token_test if args.test else pip_secrets.token # meh + + check_call([ + 'python3', '-m', 'twine', + 'upload', *dist.iterdir(), + *extra, + ], env={ + 'TWINE_USERNAME': '__token__', + TP: password, + **os.environ, + }) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 4f37384..81ca9ad 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +# see https://github.com/karlicoss/pymplate for up-to-date reference + from setuptools import setup, find_packages # type: ignore INSTALL_REQUIRES = [ @@ -21,31 +23,22 @@ def subpackages(): def main(): + pkg = 'my' setup( - name='my', - version='0.0.20200412', - description='A Python interface to my life', - url='https://github.com/karlicoss/HPI', - author='Dmitrii Gerasimov', - author_email='karlicoss@gmail.com', + name=pkg, + use_scm_version={ + 'version_scheme': 'python-simplified-semver', + 'local_scheme': 'dirty-tag', + }, + setup_requires=['setuptools_scm'], - classifiers=[ - 'Programming Language :: Python :: 3 :: Only', - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: End Users/Desktop', - 'Topic :: Scientific/Engineering :: Information Analysis', - ], - keywords=["pkm", "pim", "quantified-self"], - - # TODO eh, perhaps should use 'src'... - # package_dir={'': ''}, + zip_safe=False, # eh. find_packages doesn't find anything # find_namespace_packages can't find isngle file namspace packages (like my/common.py) - packages=['my', *subpackages()], + packages=[pkg, *subpackages()], package_data={ - 'my': [ + pkg: [ # for mypy 'py.typed', @@ -54,7 +47,13 @@ def main(): ], }, - python_requires='>=3.5', # depends on the modules though.. + + url='https://github.com/karlicoss/HPI', + author='Dmitrii Gerasimov', + author_email='karlicoss@gmail.com', + description='A Python interface to my life', + + install_requires=INSTALL_REQUIRES, extras_require={ 'testing': [ 'pytest', @@ -62,7 +61,6 @@ def main(): 'pylint', ], }, - install_requires=INSTALL_REQUIRES, ) diff --git a/tox.ini b/tox.ini index 1962871..51ee32d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,10 @@ [tox] minversion = 3.5 -envlist = py36,py37 # ,pylint,mypy -skip_missing_interpreters = True +envlist = py3 # ,pylint,mypy # TODO ugh. unclear how to reuse setup.cfg deps in tox [testenv] -passenv = CI CI_* CIRCLE* +passenv = CI CI_* # deliberately set to nonexistent pathe to check the fallback logic setenv = MY_CONFIG = nonexistent commands =