-
Notifications
You must be signed in to change notification settings - Fork 21
/
prep.py
60 lines (45 loc) · 1.38 KB
/
prep.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
# prep.py
"""
Script to automatically perform testing, formatting, building and any other
operation needed before distribution. Currently WIP.
"""
import coverage
import os
import subprocess
import unittest
def main():
# Before this, we assume that the version is correctly incremented
# Run black, format draftsman + test folders
subprocess.run(["black", "draftsman"])
subprocess.run(["black", "test"])
# Before running testing, run the update script to reset to no mods
# err = subprocess.run(["draftsman-update", "--no-mods"])
# if err.returncode:
# print(err)
# return err
# Run code coverage, fail if not 100%
# cov = coverage.Coverage()
# test_loader = unittest.TestLoader()
# tests = test_loader.discover("test")
# test_runner = unittest.TextTestRunner()
# print(tests)
# cov.start()
# result = test_runner.run(tests)
# cov.stop()
# cov.save()
# cov.report()
# #f = open(os.devnull, "w")
# print(cov.html_report())
# Run tox, fail if tox failed at any point
err = subprocess.run(["tox"])
if err.returncode:
print(err)
return err
# Run build
# This doesn't work for some reason
#subprocess.run(["python", "-m", "build", "."])
# But this does
os.system("python -m build .")
# twine upload dist/*
if __name__ == "__main__":
main()