Switch to github CI

This commit is contained in:
Dima Gerasimov 2020-04-18 15:14:39 +01:00 committed by karlicoss
parent 46f69a8911
commit 7fe6520575
7 changed files with 147 additions and 104 deletions

View file

@ -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

63
.github/workflows/main.yml vendored Normal file
View file

@ -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?

69
.gitignore vendored
View file

@ -45,28 +45,13 @@ flycheck_*.el
# projectiles files # projectiles files
.projectile .projectile
projectile-bookmarks.eld
# directory configuration # directory configuration
.dir-locals.el .dir-locals.el
# saveplace # network security
places /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 ### ### Python ###
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
@ -124,16 +109,6 @@ coverage.xml
*.mo *.mo
*.pot *.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff: # Scrapy stuff:
.scrapy .scrapy
@ -143,13 +118,6 @@ docs/_build/
# PyBuilder # PyBuilder
target/ target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv # pyenv
.python-version .python-version
@ -166,15 +134,6 @@ celerybeat-schedule
# SageMath parsed files # SageMath parsed files
*.sage.py *.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings # Spyder project settings
.spyderproject .spyderproject
.spyproject .spyproject
@ -182,6 +141,11 @@ venv.bak/
# Rope project settings # Rope project settings
.ropeproject .ropeproject
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# mkdocs documentation # mkdocs documentation
/site /site
@ -190,22 +154,7 @@ venv.bak/
.dmypy.json .dmypy.json
dmypy.json dmypy.json
### Python Patch ### # Pyre type checker
.venv/ .pyre/
### 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
# End of https://www.gitignore.io/api/python,emacs # End of https://www.gitignore.io/api/python,emacs
cov

7
scripts/ci/run Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash -eu
cd "$(dirname "$0")"
cd ../..
pip3 install --user tox
tox

47
scripts/release Executable file
View file

@ -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()

View file

@ -1,4 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# see https://github.com/karlicoss/pymplate for up-to-date reference
from setuptools import setup, find_packages # type: ignore from setuptools import setup, find_packages # type: ignore
INSTALL_REQUIRES = [ INSTALL_REQUIRES = [
@ -21,31 +23,22 @@ def subpackages():
def main(): def main():
pkg = 'my'
setup( setup(
name='my', name=pkg,
version='0.0.20200412', use_scm_version={
description='A Python interface to my life', 'version_scheme': 'python-simplified-semver',
url='https://github.com/karlicoss/HPI', 'local_scheme': 'dirty-tag',
author='Dmitrii Gerasimov', },
author_email='karlicoss@gmail.com', setup_requires=['setuptools_scm'],
classifiers=[ zip_safe=False,
'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={'': ''},
# eh. find_packages doesn't find anything # eh. find_packages doesn't find anything
# find_namespace_packages can't find isngle file namspace packages (like my/common.py) # find_namespace_packages can't find isngle file namspace packages (like my/common.py)
packages=['my', *subpackages()], packages=[pkg, *subpackages()],
package_data={ package_data={
'my': [ pkg: [
# for mypy # for mypy
'py.typed', '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={ extras_require={
'testing': [ 'testing': [
'pytest', 'pytest',
@ -62,7 +61,6 @@ def main():
'pylint', 'pylint',
], ],
}, },
install_requires=INSTALL_REQUIRES,
) )

View file

@ -1,11 +1,10 @@
[tox] [tox]
minversion = 3.5 minversion = 3.5
envlist = py36,py37 # ,pylint,mypy envlist = py3 # ,pylint,mypy
skip_missing_interpreters = True
# TODO ugh. unclear how to reuse setup.cfg deps in tox # TODO ugh. unclear how to reuse setup.cfg deps in tox
[testenv] [testenv]
passenv = CI CI_* CIRCLE* passenv = CI CI_*
# deliberately set to nonexistent pathe to check the fallback logic # deliberately set to nonexistent pathe to check the fallback logic
setenv = MY_CONFIG = nonexistent setenv = MY_CONFIG = nonexistent
commands = commands =