-
Notifications
You must be signed in to change notification settings - Fork 4
/
tools.ps1
82 lines (81 loc) · 2.94 KB
/
tools.ps1
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
72
73
74
75
76
77
78
79
80
81
82
$ErrorActionPreference = "Stop"
if ($args.Count -gt 0) {
switch ($args[0]) {
"dep" {
Write-Output "Install dependencies..."
pip install -r requirements.txt || exit $LASTEXITCODE
}
"dep-dev" {
Write-Output "Install dependencies for development..."
pip install pytest flake8 || exit $LASTEXITCODE
pip install pytest-qt pytest-cov || exit $LASTEXITCODE
pip install autopep8 isort || exit $LASTEXITCODE
pip install PyQt5-stubs || exit $LASTEXITCODE
npm install -g pyright || exit $LASTEXITCODE
}
"format" {
Write-Output "Formatting..."
isort -rc -ac -s __init__.py -y || exit $LASTEXITCODE
autopep8 -ir . --list-fixes || exit $LASTEXITCODE
}
"clean" {
Write-Output "Clean generated files.."
Get-ChildItem -Include .coverage -Recurse | Remove-item
Get-ChildItem -Include htmlcov -Recurse | Remove-item -Recurse
Get-ChildItem -Include .pytest_cache -Recurse | Remove-item -Recurse
Get-ChildItem -Include __pycache__ -Recurse | Remove-item -Recurse
}
"clean-ui" {
Write-Output "Clean generated UI files.."
Get-ChildItem ./src/ImagingS/Gui/ui -Exclude .gitignore | Remove-item -Recurse
}
"gen-ui" {
Write-Output "Generate UI files..."
Set-Location src
python -m ImagingS.Gui.uic || exit $LASTEXITCODE
Set-Location ..
}
"gui" {
Write-Output "Run GUI..."
Set-Location src
python -m ImagingS.Gui || exit $LASTEXITCODE
Set-Location ..
}
"cli" {
Write-Output "Run CLI..."
Set-Location src
python -m ImagingS.Cli || exit $LASTEXITCODE
Set-Location ..
}
"lint" {
Write-Output "Lint..."
Write-Output "Flake8 check..."
# stop the build if there are Python syntax errors or undefined names
flake8 . --config=tox_fatal.ini
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --exit-zero
Write-Output "Pyright check..."
pyright
}
"test" {
Write-Output "Test..."
pytest --verbose || exit $LASTEXITCODE
}
"testcov" {
Write-Output "Test and coverage..."
pytest --verbose --cov=. --cov-report=term --cov-report=html || exit $LASTEXITCODE
}
"testcov-noui" {
Write-Output "Test and coverage (without UI)..."
pytest --verbose --ignore test/gui --cov=. --cov-report=term --cov-report=html || exit $LASTEXITCODE
}
Default {
Write-Output "Unrecognized command"
exit -1
}
}
}
else {
Write-Output "Missing command"
exit -1
}