-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtasks.py
56 lines (44 loc) · 1.56 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
# -*- coding: utf-8 -*-
# Copyright (c) 2022–2024 The applyaf developers. All rights reserved.
# Project site: https://github.com/questrail/applyaf
# 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 applyaf"""
from invoke import task
from unipath import Path
ROOT_DIR = Path(__file__).ancestor(1)
@task
def lint(c):
"""Run ruff to lint code"""
c.run("ruff check")
@task
def freeze(c):
"""Freeze the pip requirements using pip-chill"""
c.run(f"pip-chill > {Path(ROOT_DIR, 'requirements.txt')}")
@task(lint)
def test(c):
"""Lint and run unit tests"""
c.run("nose2 -C")
@task
def outdated(c):
"""List outdated packages"""
c.run("pip list --outdated")
@task()
def release(c, deploy=False, version=""):
"""Tag release and deploy to PyPI"""
if deploy and version:
c.run("git checkout master")
c.run("git tag -a v{ver} -m 'v{ver}'".format(ver=version))
c.run("git push")
c.run("git push origin --tags")
c.run("hatch build")
c.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")