forked from aws/aws-sam-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Make.ps1
165 lines (142 loc) · 3.76 KB
/
Make.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<#
.SYNOPSIS
Run on Windows the same commands as in ./Makefile without installing any aditional software.
.DESCRIPTION
Run on Windows the same commands as in ./Makefile without installing any aditional software.
The only difference is syntax. Instead of make commands use parameters, meaning add '-' before the command.
Parameter names are case insensetive.
See Examples.
.EXAMPLE
./Make -TestCovReport
.EXAMPLE
./Make -pr
#>
[CmdletBinding(DefaultParameterSetName = '_')] # ParameterSetName '_'is just a workaround to redirect to default case
param (
# Install all dependencies
[Parameter(ParameterSetName = 'Init')]
[switch]
$Init,
# Run unit tests and fail if coverage falls below 95%
[Parameter(ParameterSetName = 'Test')]
[switch]
$Test,
# Run unit tests with html coverage report
[Parameter(ParameterSetName = 'TestCovReport')]
[switch]
$TestCovReport,
# Run integration tests; they don't need code coverage
[Parameter(ParameterSetName = 'IntegTest')]
[switch]
$IntegTest,
# Verify function test coverage only for `samcli.local` package
[Parameter(ParameterSetName = 'FuncTest')]
[switch]
$FuncTest,
# Run regression tests
[Parameter(ParameterSetName = 'RegresTest')]
[switch]
$RegresTest,
# Smoke tests run in parallel
[Parameter(ParameterSetName = 'SmokeTest')]
[switch]
$SmokeTest,
# Linter performs static analysis to catch latent bugs and mypy performs type check
[Parameter(ParameterSetName = 'Lint')]
[switch]
$Lint,
# Lint and then test
[Parameter(ParameterSetName = 'Dev')]
[switch]
$Dev,
# Format with black
[Parameter(ParameterSetName = 'Black')]
[switch]
$Black,
# Perform format check
[Parameter(ParameterSetName = 'BlackCheck')]
[switch]
$BlackCheck,
# install, lint, check formating
[Parameter(ParameterSetName = 'Pr')]
[switch]
$Pr
# Update reproducable requirements. Path to python interpreter
# [Parameter(ParameterSetName = 'UpdReq')]
# [string]
# $UpdateReproducableReqs
)
function Init {
pip install -e '.[pre-dev]'
pip install -e '.[dev]'
}
function Test {
pytest --cov samcli --cov-report term-missing --cov-fail-under 95 tests/unit
}
function Lint {
ruff check samcli schema
mypy setup.py samcli tests
}
function Dev {
Lint
Test
}
function BlackCheck {
black --check setup.py samcli tests
}
if ( -not (Test-Path "env:SAM_CLI_TELEMETRY")) {
$env:SAM_CLI_TELEMETRY = 0
}
$env:SAM_CLI_DEV = 1
try {
switch ($true) {
$Init {
Init
}
$Test {
Test
}
$TestCovReport {
pytest --cov samcli --cov-report html --cov-fail-under 95 tests/unit
}
$IntegTest {
Write-Output "Telemetry Status: $env:SAM_CLI_TELEMETRY"
pytest tests/integration
}
$FuncTest {
Write-Output "Telemetry Status: $env:SAM_CLI_TELEMETRY"
pytest --cov samcli.local --cov samcli.commands.local --cov-report term-missing tests/functional
}
$RegresTest {
Write-Output "Telemetry Status: $env:SAM_CLI_TELEMETRY"
pytest tests/regression
}
$SmokeTest {
Write-Output "Telemetry Status: $env:SAM_CLI_TELEMETRY"
pytest -n 4 tests/smoke
}
$Lint {
Lint
}
$Dev {
Dev
}
$Black {
black setup.py samcli tests
}
$BlackCheck {
BlackCheck
}
$Pr {
Init
Dev
BlackCheck
}
default {
Get-Help ./Make
}
}
}
finally {
$env:SAM_CLI_DEV = ''
}