Skip to content

Commit b0977b9

Browse files
authored
MNT minor linter bot message enhancements (scikit-learn#26670)
1 parent 04575f5 commit b0977b9

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

.github/workflows/lint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ jobs:
3636
pip install pytest ruff $(get_dep mypy min) $(get_dep black min) cython-lint
3737
3838
- name: Run linting
39+
id: lint-script
3940
# We download the linting script from main, since this workflow is run
4041
# from main itself.
4142
run: |
42-
curl https://raw.githubusercontent.com/scikit-learn/scikit-learn/main/build_tools/linting.sh -o ./build_tools/linting.sh
43+
set +e
44+
curl https://raw.githubusercontent.com/scikit-learn/scikit-learn/main/build_tools/linting.sh --retry 5 -o ./build_tools/linting.sh
4345
./build_tools/linting.sh &> /tmp/linting_output.txt
46+
cat /tmp/linting_output.txt
4447
4548
- name: Upload Artifact
4649
if: always()

build_tools/get_comment.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,30 +152,44 @@ def get_message(log_file, repo, pr_number, sha, run_id, details):
152152
details=details,
153153
)
154154

155-
commit_link = (
156-
"\n\n_Generated for commit:"
157-
f" [{sha[:7]}](https://github.com/{repo}/pull/{pr_number}/commits/{sha})_"
155+
sub_text = (
156+
"\n\n<sub> _Generated for commit:"
157+
f" [{sha[:7]}](https://github.com/{repo}/pull/{pr_number}/commits/{sha}). "
158+
"Link to the linter CI: [here]"
159+
f"(https://github.com/{repo}/actions/runs/{run_id})_ </sub>"
158160
)
159161

160162
if not message:
161163
# no issues detected, so this script "fails"
162164
return (
163165
"## ✔️ Linting Passed\n"
164166
"All linting checks passed. Your pull request is in excellent shape! ☀️"
165-
+ commit_link
167+
+ sub_text
166168
)
167169

170+
if not details:
171+
# This happens if posting the log fails, which happens if the log is too
172+
# long. Typically, this happens if the PR branch hasn't been updated
173+
# since we've introduced import sorting.
174+
branch_not_updated = (
175+
"_Merging with `upstream/main` might fix / improve the issues if you "
176+
"haven't done that since 21.06.2023._\n\n"
177+
)
178+
else:
179+
branch_not_updated = ""
180+
168181
message = (
169182
"## ❌ Linting issues\n\n"
170-
"This PR is introducing linting issues. Here's a summary of the issues. "
171-
"Note that you can avoid having linting issues by enabling `pre-commit` "
172-
"hooks. Instructions to enable them can be found [here]("
173-
"https://scikit-learn.org/dev/developers/contributing.html#how-to-contribute)."
174-
"\n\n"
175-
"You can see the details of the linting issues under the `lint` job [here]"
176-
f"(https://github.com/{repo}/actions/runs/{run_id})\n\n"
183+
+ branch_not_updated
184+
+ "This PR is introducing linting issues. Here's a summary of the issues. "
185+
+ "Note that you can avoid having linting issues by enabling `pre-commit` "
186+
+ "hooks. Instructions to enable them can be found [here]("
187+
+ "https://scikit-learn.org/dev/developers/contributing.html#how-to-contribute)"
188+
+ ".\n\n"
189+
+ "You can see the details of the linting issues under the `lint` job [here]"
190+
+ f"(https://github.com/{repo}/actions/runs/{run_id})\n\n"
177191
+ message
178-
+ commit_link
192+
+ sub_text
179193
)
180194

181195
return message

0 commit comments

Comments
 (0)