43
43
option_airflow_constraints_reference ,
44
44
option_answer ,
45
45
option_dry_run ,
46
- option_github_repository ,
47
46
option_max_age ,
48
47
option_python ,
49
48
option_timezone ,
@@ -73,39 +72,33 @@ def ci_group():
73
72
@option_verbose
74
73
@option_dry_run
75
74
@option_answer
76
- def free_space (verbose : bool , dry_run : bool , answer : str ):
75
+ def free_space ():
77
76
if user_confirm ("Are you sure to run free-space and perform cleanup?" ) == Answer .YES :
78
- run_command (["sudo" , "swapoff" , "-a" ], verbose = verbose , dry_run = dry_run )
79
- run_command (["sudo" , "rm" , "-f" , "/swapfile" ], verbose = verbose , dry_run = dry_run )
77
+ run_command (["sudo" , "swapoff" , "-a" ])
78
+ run_command (["sudo" , "rm" , "-f" , "/swapfile" ])
80
79
for file in Path (tempfile .gettempdir ()).iterdir ():
81
80
if file .name .startswith ("parallel" ):
82
81
run_command (
83
82
["sudo" , "rm" , "-rvf" , os .fspath (file )],
84
- verbose = verbose ,
85
- dry_run = dry_run ,
86
83
check = False ,
87
84
title = f"rm -rvf { file } " ,
88
85
)
89
- run_command (["sudo" , "apt-get" , "clean" ], verbose = verbose , dry_run = dry_run , check = False )
90
- run_command (
91
- ["docker" , "system" , "prune" , "--all" , "--force" , "--volumes" ], verbose = verbose , dry_run = dry_run
92
- )
93
- run_command (["df" , "-h" ], verbose = verbose , dry_run = dry_run )
94
- run_command (["docker" , "logout" , "ghcr.io" ], verbose = verbose , dry_run = dry_run , check = False )
86
+ run_command (["sudo" , "apt-get" , "clean" ], check = False )
87
+ run_command (["docker" , "system" , "prune" , "--all" , "--force" , "--volumes" ])
88
+ run_command (["df" , "-h" ])
89
+ run_command (["docker" , "logout" , "ghcr.io" ], check = False )
95
90
run_command (
96
91
["sudo" , "rm" , "-f" , os .fspath (Path .home () / MSSQL_TMP_DIR_NAME )],
97
- verbose = verbose ,
98
- dry_run = dry_run ,
99
92
)
100
93
101
94
102
95
@ci_group .command (name = "resource-check" , help = "Check if available docker resources are enough." )
103
96
@option_verbose
104
97
@option_dry_run
105
- def resource_check (verbose : bool , dry_run : bool ):
106
- perform_environment_checks (verbose = verbose )
107
- shell_params = ShellParams (verbose = verbose , python = DEFAULT_PYTHON_MAJOR_MINOR_VERSION )
108
- check_docker_resources (shell_params .airflow_image_name , verbose = verbose , dry_run = dry_run )
98
+ def resource_check ():
99
+ perform_environment_checks ()
100
+ shell_params = ShellParams (python = DEFAULT_PYTHON_MAJOR_MINOR_VERSION )
101
+ check_docker_resources (shell_params .airflow_image_name )
109
102
110
103
111
104
HOME_DIR = Path (os .path .expanduser ("~" )).resolve ()
@@ -120,32 +113,30 @@ def resource_check(verbose: bool, dry_run: bool):
120
113
]
121
114
122
115
123
- def fix_ownership_for_file (file : Path , dry_run : bool , verbose : bool ):
116
+ def fix_ownership_for_file (file : Path ):
124
117
get_console ().print (f"[info]Fixing ownership of { file } " )
125
118
result = run_command (
126
119
["sudo" , "chown" , f"{ os .getuid } :{ os .getgid ()} " , str (file .resolve ())],
127
120
check = False ,
128
121
stderr = subprocess .STDOUT ,
129
- dry_run = dry_run ,
130
- verbose = verbose ,
131
122
)
132
123
if result .returncode != 0 :
133
124
get_console ().print (f"[warning]Could not fix ownership for { file } : { result .stdout } " )
134
125
135
126
136
- def fix_ownership_for_path (path : Path , dry_run : bool , verbose : bool ):
127
+ def fix_ownership_for_path (path : Path ):
137
128
if path .is_dir ():
138
129
for p in Path (path ).rglob ("*" ):
139
130
if p .owner == "root" :
140
- fix_ownership_for_file (p , dry_run = dry_run , verbose = verbose )
131
+ fix_ownership_for_file (p )
141
132
else :
142
133
if path .owner == "root" :
143
- fix_ownership_for_file (path , dry_run = dry_run , verbose = verbose )
134
+ fix_ownership_for_file (path )
144
135
145
136
146
- def fix_ownership_without_docker (dry_run : bool , verbose : bool ):
137
+ def fix_ownership_without_docker ():
147
138
for directory_to_fix in DIRECTORIES_TO_FIX :
148
- fix_ownership_for_path (directory_to_fix , dry_run = dry_run , verbose = verbose )
139
+ fix_ownership_for_path (directory_to_fix )
149
140
150
141
151
142
@ci_group .command (name = "fix-ownership" , help = "Fix ownership of source files to be same as host user." )
@@ -155,10 +146,9 @@ def fix_ownership_without_docker(dry_run: bool, verbose: bool):
155
146
help = "Use sudo instead of docker image to fix the ownership. You need to be a `sudoer` to run it" ,
156
147
envvar = "USE_SUDO" ,
157
148
)
158
- @option_github_repository
159
149
@option_verbose
160
150
@option_dry_run
161
- def fix_ownership (github_repository : str , use_sudo : bool , verbose : bool , dry_run : bool ):
151
+ def fix_ownership (use_sudo : bool ):
162
152
system = platform .system ().lower ()
163
153
if system != "linux" :
164
154
get_console ().print (
@@ -167,15 +157,15 @@ def fix_ownership(github_repository: str, use_sudo: bool, verbose: bool, dry_run
167
157
sys .exit (0 )
168
158
if use_sudo :
169
159
get_console ().print ("[info]Fixing ownership using sudo." )
170
- fix_ownership_without_docker (dry_run = dry_run , verbose = verbose )
160
+ fix_ownership_without_docker ()
171
161
sys .exit (0 )
172
162
get_console ().print ("[info]Fixing ownership using docker." )
173
- fix_ownership_using_docker (dry_run = dry_run , verbose = verbose )
163
+ fix_ownership_using_docker ()
174
164
# Always succeed
175
165
sys .exit (0 )
176
166
177
167
178
- def get_changed_files (commit_ref : str | None , dry_run : bool , verbose : bool ) -> tuple [str , ...]:
168
+ def get_changed_files (commit_ref : str | None ) -> tuple [str , ...]:
179
169
if commit_ref is None :
180
170
return ()
181
171
cmd = [
@@ -187,7 +177,7 @@ def get_changed_files(commit_ref: str | None, dry_run: bool, verbose: bool) -> t
187
177
commit_ref + "^" ,
188
178
commit_ref ,
189
179
]
190
- result = run_command (cmd , dry_run = dry_run , verbose = verbose , check = False , capture_output = True , text = True )
180
+ result = run_command (cmd , check = False , capture_output = True , text = True )
191
181
if result .returncode != 0 :
192
182
get_console ().print (
193
183
f"[warning] Error when running diff-tree command [/]\n { result .stdout } \n { result .stderr } "
@@ -244,14 +234,12 @@ def selective_check(
244
234
default_branch : str ,
245
235
default_constraints_branch : str ,
246
236
github_event_name : str ,
247
- verbose : bool ,
248
- dry_run : bool ,
249
237
):
250
238
from airflow_breeze .utils .selective_checks import SelectiveChecks
251
239
252
240
github_event = GithubEvents (github_event_name )
253
241
if commit_ref is not None :
254
- changed_files = get_changed_files (commit_ref = commit_ref , dry_run = dry_run , verbose = verbose )
242
+ changed_files = get_changed_files (commit_ref = commit_ref )
255
243
else :
256
244
changed_files = ()
257
245
sc = SelectiveChecks (
0 commit comments