|
67 | 67 | FLAKE8_FORMAT="default"
|
68 | 68 | fi
|
69 | 69 |
|
| 70 | + |
| 71 | +function if_gh_actions { |
| 72 | + # If this is running on GitHub Actions, echo the argument list, otherwise |
| 73 | + # echo the empty string. |
| 74 | + # Used to conditionally pass command-line arguments as in |
| 75 | + # $(if_gh_actions --baz spam) | xargs foo --bar |
| 76 | + if [[ "$GITHUB_ACTIONS" == "true" ]]; then |
| 77 | + for arg in "$@"; do echo $arg; done | quote_if_needed |
| 78 | + else |
| 79 | + echo "" |
| 80 | + fi |
| 81 | +} |
| 82 | + |
| 83 | + |
70 | 84 | ### LINTING ###
|
71 | 85 | if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
|
72 | 86 |
|
@@ -126,35 +140,23 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
|
126 | 140 | VALIDATE_CMD=$BASE_DIR/scripts/validate_unwanted_patterns.py
|
127 | 141 |
|
128 | 142 | MSG='Check for use of not concatenated strings' ; echo $MSG
|
129 |
| - if [[ "$GITHUB_ACTIONS" == "true" ]]; then |
130 |
| - echo $GIT_TRACKED_ALL_PY_FILES | xargs $VALIDATE_CMD --validation-type="strings_to_concatenate" --format="##[error]{source_path}:{line_number}:{msg}" --no-override |
131 |
| - else |
132 |
| - echo $GIT_TRACKED_ALL_PY_FILES | xargs $VALIDATE_CMD --validation-type="strings_to_concatenate" --no-override |
133 |
| - fi |
| 143 | + ARGS=$({ if_gh_actions --format="##[error]{source_path}:{line_number}:{msg}"; echo $GIT_TRACKED_ALL_PY_FILES; }) |
| 144 | + echo $ARGS | xargs $VALIDATE_CMD --validation-type="strings_to_concatenate" --no-override |
134 | 145 | RET=$(($RET + $?)) ; echo $MSG "DONE"
|
135 | 146 |
|
136 | 147 | MSG='Check for strings with wrong placed spaces' ; echo $MSG
|
137 |
| - if [[ "$GITHUB_ACTIONS" == "true" ]]; then |
138 |
| - echo $GIT_TRACKED_ALL_PY_FILES | xargs $VALIDATE_CMD --validation-type="strings_with_wrong_placed_whitespace" --format="##[error]{source_path}:{line_number}:{msg}" --no-override |
139 |
| - else |
140 |
| - echo $GIT_TRACKED_ALL_PY_FILES | xargs $VALIDATE_CMD --validation-type="strings_with_wrong_placed_whitespace" --no-override |
141 |
| - fi |
| 148 | + ARGS=$({ if_gh_actions --format="##[error]{source_path}:{line_number}:{msg}"; echo $GIT_TRACKED_ALL_PY_FILES; }) |
| 149 | + echo $ARGS | xargs $VALIDATE_CMD --validation-type="strings_with_wrong_placed_whitespace" --no-override |
142 | 150 | RET=$(($RET + $?)) ; echo $MSG "DONE"
|
143 | 151 |
|
144 | 152 | MSG='Check for import of private attributes across modules' ; echo $MSG
|
145 |
| - if [[ "$GITHUB_ACTIONS" == "true" ]]; then |
146 |
| - $VALIDATE_CMD --validation-type="private_import_across_module" --included-file-extensions="py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored --format="##[error]{source_path}:{line_number}:{msg}" pandas/ |
147 |
| - else |
148 |
| - $VALIDATE_CMD --validation-type="private_import_across_module" --included-file-extensions="py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored pandas/ |
149 |
| - fi |
| 153 | + ARGS=$(if_gh_actions --format="##[error]{source_path}:{line_number}:{msg}") |
| 154 | + echo $ARGS | xargs $VALIDATE_CMD --validation-type="private_import_across_module" --included-file-extensions="py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored pandas/ |
150 | 155 | RET=$(($RET + $?)) ; echo $MSG "DONE"
|
151 | 156 |
|
152 | 157 | MSG='Check for use of private functions across modules' ; echo $MSG
|
153 |
| - if [[ "$GITHUB_ACTIONS" == "true" ]]; then |
154 |
| - $VALIDATE_CMD --validation-type="private_function_across_module" --included-file-extensions="py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored,doc/ --format="##[error]{source_path}:{line_number}:{msg}" pandas/ |
155 |
| - else |
156 |
| - $VALIDATE_CMD --validation-type="private_function_across_module" --included-file-extensions="py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored,doc/ pandas/ |
157 |
| - fi |
| 158 | + ARGS=$(if_gh_actions --format="##[error]{source_path}:{line_number}:{msg}") |
| 159 | + echo $ARGS | xargs $VALIDATE_CMD --validation-type="private_function_across_module" --included-file-extensions="py" --excluded-file-paths=pandas/tests,asv_bench/,pandas/_vendored,doc/ pandas/ |
158 | 160 | RET=$(($RET + $?)) ; echo $MSG "DONE"
|
159 | 161 |
|
160 | 162 | echo "isort --version-number"
|
|
0 commit comments