-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
71 lines (57 loc) · 2.17 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-
# Copyright (c) 2022–2023 The sdfascii developers. All rights reserved.
# Project site: https://github.com/questrail/sdfascii
# Use of this source code is governed by a MIT-style license that
# can be found in the LICENSE.txt file for the project.
from invoke import run, task
from unipath import Path
TESTPYPI = "https://testpypi.python.org/pypi"
ROOT_DIR = Path(__file__).ancestor(1)
@task
def lint(ctx):
"""Run flake8 to lint code"""
run("python3 -m flake8")
run("python3 -m mypy sdfascii.py")
@task
def freeze(ctx):
# pylint: disable=W0613
"""Freeze the pip requirements using pip-chill"""
run(f"pip-chill > {Path(ROOT_DIR, 'requirements.txt')}")
@task(lint)
def test(ctx):
"""Lint, unit test, and check setup.py"""
run("nose2")
@task
def example1(ctx):
"""Parse HP35670A.DAT to JSON in examples folder"""
run('python sdfascii.py sdf examples/HP35670A.DAT examples/hp35670a.json')
@task
def example2(ctx):
"""Parse HP35665A.DAT to JSON in examples folder"""
run('python sdfascii.py sdf examples/HP35665A.DAT examples/hp35665A.json')
@task()
def release(ctx, deploy=False, test=False, version=''):
"""Tag release, run Travis-CI, and deploy to PyPI
"""
if test:
run("python setup.py check")
run("python setup.py register sdist upload --dry-run")
if deploy:
run("python setup.py check")
if version:
run("git checkout master")
run("git tag -a v{ver} -m 'v{ver}'".format(ver=version))
run("git push")
run("git push origin --tags")
run("python3 -m build")
run("python3 -m twine upload dist/*")
else:
print("* Have you updated the version?")
print("* Have you updated CHANGELOG.md?")
print("* Have you fixed any last minute bugs?")
print("If you answered yes to all of the above questions,")
print("then run `invoke release --deploy -vX.YY.ZZ` to:")
print("- Checkout master")
print("- Tag the git release with provided vX.YY.ZZ version")
print("- Push the master branch and tags to repo")
print("**NOTE:** Use __token__ for pypi username/pwd")