-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
60 lines (48 loc) · 1.69 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
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2024 The tektronix developers. All rights reserved.
# Project site: https://github.com/questrail/tektronix
# Use of this source code is governed by a MIT-style license that
# can be found in the LICENSE.txt file for the project.
"""Invoke based tasks for tektronix"""
from invoke import run, task
from unipath import Path
ROOT_DIR = Path(__file__).ancestor(1)
@task
def lint(ctx):
# pylint: disable=W0613
"""Run ruff and mypy to lint code"""
run("ruff check src/")
run("python3 -m mypy src/")
@task
def freeze(ctx):
# pylint: disable=W0613
"""Freeze the pip requirements using pip-chill"""
run(f"pip-chill > {Path(ROOT_DIR, 'requirements.txt')}")
@task
def outdated(ctx):
"""List outdated packages"""
run("pip list --outdated")
@task
def test(ctx):
"""Unit test code"""
run("nose2 -C")
@task
def release(ctx, deploy=False, version=""):
"""Tag release and deploy to PyPI"""
if deploy and 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("hatch build")
run("hatch publish")
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("- Deploy to PyPi using Travis")