Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/bot-lint-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
run: mkdir -p "$ARTIFACTS_DIR"

- name: Download artifact
continue-on-error: true
uses: actions/download-artifact@v8
with:
name: lint-log
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ jobs:
run: |
pip install -r build_tools/github/lint_lock.txt
# we save the versions of the linters to be used in the error message later.
python -c "from importlib.metadata import version; print(f\"pytest={version('pytest')}\")" >> /tmp/versions.txt
python -c "from importlib.metadata import version; print(f\"ruff={version('ruff')}\")" >> /tmp/versions.txt
python -c "from importlib.metadata import version; print(f\"pyrefly={version('pyrefly')}\")" >> /tmp/versions.txt
python -c "from importlib.metadata import version; print(f\"cython-lint={version('cython-lint')}\")" >> /tmp/versions.txt

- name: Run linting
run: |
set +e
./build_tools/linting.sh &> /tmp/linting_output.txt
cat /tmp/linting_output.txt
# python -c "from importlib.metadata import version; print(f\"pytest={version('pytest')}\")" >> /tmp/versions.txt
# python -c "from importlib.metadata import version; print(f\"ruff={version('ruff')}\")" >> /tmp/versions.txt
# python -c "from importlib.metadata import version; print(f\"pyrefly={version('pyrefly')}\")" >> /tmp/versions.txt
# python -c "from importlib.metadata import version; print(f\"cython-lint={version('cython-lint')}\")" >> /tmp/versions.txt

# - name: Run linting
# run: |
# set +e
# ./build_tools/linting.sh &> /tmp/linting_output.txt
# cat /tmp/linting_output.txt

- name: Upload Artifact
if: always()
Expand Down
20 changes: 14 additions & 6 deletions build_tools/get_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ def get_versions(versions_file):
versions : dict
A dictionary with the versions of the packages.
"""
with open(versions_file, "r") as f:
return dict(line.strip().split("=") for line in f)
try:
with open(versions_file, "r") as f:
return dict(line.strip().split("=") for line in f)
except FileNotFoundError:
return {}


def get_step_message(log, start, end, title, message, details):
Expand Down Expand Up @@ -67,23 +70,28 @@ def get_step_message(log, start, end, title, message, details):


def get_message(log_file, repo_str, pr_number, sha, run_id, details, versions):
with open(log_file, "r") as f:
log = f.read()

sub_text = (
"\n\n<sub> _Generated for commit:"
f" [{sha[:7]}](https://github.com/{repo_str}/pull/{pr_number}/commits/{sha}). "
"Link to the linter CI: [here]"
f"(https://github.com/{repo_str}/actions/runs/{run_id})_ </sub>"
)

# If the log file wasn't created due to some earlier failure in the linting step, we
# still want to return the generic message below.
try:
with open(log_file, "r") as f:
log = f.read()
except FileNotFoundError:
log = ""

if "### Linting completed ###" not in log:
return (
"## ❌ Linting issues\n\n"
"There was an issue running the linter job. Please update with "
"`upstream/main` ([link]("
"https://scikit-learn.org/dev/developers/contributing.html"
"#how-to-contribute)) and push the changes. If you already have done "
"#development-workflow)) and push the changes. If you already have done "
"that, please send an empty commit with `git commit --allow-empty` "
"and push the changes to trigger the CI.\n\n" + sub_text
)
Expand Down
Loading