42
42
all_ports_all_boards ,
43
43
)
44
44
45
- IGNORE = [
46
- "tools/ci_set_matrix.py" ,
45
+ # Files that never influence board builds
46
+ IGNORE_BOARD = {
47
+ ".devcontainer" ,
48
+ "docs" ,
49
+ "tests" ,
50
+ "tools/ci_changes_per_commit.py" ,
47
51
"tools/ci_check_duplicate_usb_vid_pid.py" ,
48
- ]
49
-
50
- # Files in these directories never influence board builds
51
- IGNORE_DIRS = ["tests" , "docs" , ".devcontainer" ]
52
+ "tools/ci_set_matrix.py" ,
53
+ }
52
54
53
55
PATTERN_DOCS = (
54
56
r"^(?:\.github|docs|extmod\/ulab)|"
55
57
r"^(?:(?:ports\/\w+\/bindings|shared-bindings)\S+\.c|tools\/extract_pyi\.py|\.readthedocs\.yml|conf\.py|requirements-doc\.txt)$|"
56
58
r"(?:-stubs|\.(?:md|MD|rst|RST))$"
57
59
)
58
60
59
- PATTERN_WINDOWS = [
61
+ PATTERN_WINDOWS = {
60
62
".github/" ,
61
63
"extmod/" ,
62
64
"lib/" ,
63
65
"mpy-cross/" ,
64
66
"ports/unix/" ,
65
- "ports/windows/" ,
66
67
"py/" ,
67
- "requirements" ,
68
68
"tools/" ,
69
- ]
69
+ "requirements-dev.txt" ,
70
+ }
70
71
71
72
72
73
def git_diff (pattern : str ):
73
- return (
74
+ return set (
74
75
subprocess .run (
75
76
f"git diff { pattern } --name-only" ,
76
77
capture_output = True ,
@@ -83,15 +84,15 @@ def git_diff(pattern: str):
83
84
84
85
if len (sys .argv ) > 1 :
85
86
print ("Using files list on commandline" )
86
- changed_files = sys .argv [1 :]
87
+ changed_files = set ( sys .argv [1 :])
87
88
elif os .environ .get ("BASE_SHA" ) and os .environ .get ("HEAD_SHA" ):
88
89
print ("Using files list by computing diff" )
89
90
changed_files = git_diff ("$BASE_SHA...$HEAD_SHA" )
90
91
if os .environ .get ("GITHUB_EVENT_NAME" ) == "pull_request" :
91
- changed_files = list ( set ( changed_files ). intersection (git_diff ("$HEAD_SHA~...$HEAD_SHA" ) ))
92
+ changed_files . intersection_update (git_diff ("$HEAD_SHA~...$HEAD_SHA" ))
92
93
else :
93
94
print ("Using files list in CHANGED_FILES" )
94
- changed_files = json .loads (os .environ .get ("CHANGED_FILES" ) or "[]" )
95
+ changed_files = set ( json .loads (os .environ .get ("CHANGED_FILES" ) or "[]" ) )
95
96
96
97
print ("Using jobs list in LAST_FAILED_JOBS" )
97
98
last_failed_jobs = json .loads (os .environ .get ("LAST_FAILED_JOBS" ) or "{}" )
@@ -103,8 +104,8 @@ def print_enclosed(title, content):
103
104
print ("::endgroup::" )
104
105
105
106
106
- print_enclosed ("LOG : changed_files" , changed_files )
107
- print_enclosed ("LOG : last_failed_jobs" , last_failed_jobs )
107
+ print_enclosed ("Log : changed_files" , changed_files )
108
+ print_enclosed ("Log : last_failed_jobs" , last_failed_jobs )
108
109
109
110
110
111
def set_output (name : str , value ):
@@ -173,11 +174,7 @@ def get_settings(board):
173
174
boards_to_build .update (port_to_boards [port ])
174
175
continue
175
176
176
- # Check the ignore list to see if the file isn't used on board builds.
177
- if p in IGNORE :
178
- continue
179
-
180
- if any ([p .startswith (d ) for d in IGNORE_DIRS ]):
177
+ if any ([p .startswith (d ) for d in IGNORE_BOARD ]):
181
178
continue
182
179
183
180
# As a (nearly) last resort, for some certain files, we compute the settings from the
@@ -287,7 +284,9 @@ def set_windows(build_windows: bool):
287
284
else :
288
285
for file in changed_files :
289
286
for pattern in PATTERN_WINDOWS :
290
- if file .startswith (pattern ):
287
+ if file .startswith (pattern ) and not any (
288
+ [file .startswith (d ) for d in IGNORE_BOARD ]
289
+ ):
291
290
build_windows = True
292
291
break
293
292
else :
@@ -302,11 +301,7 @@ def set_windows(build_windows: bool):
302
301
def main ():
303
302
# Build all if no changed files
304
303
build_all = not changed_files
305
- print (
306
- "Building all docs/boards"
307
- if build_all
308
- else "Adding docs/boards to build based on changed files"
309
- )
304
+ print ("Running: " + ("all" if build_all else "conditionally" ))
310
305
311
306
# Set jobs
312
307
set_docs (build_all )
0 commit comments