From 479f7150b1d22f5986768277f41c350fe63439a7 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Tue, 11 Aug 2026 12:47:30 +0200 Subject: [PATCH 01/14] add step to create empty files if logs were not created --- .github/workflows/bot-lint-comment.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/bot-lint-comment.yml b/.github/workflows/bot-lint-comment.yml index 6dc9c2c8de63d..1e4f10d20a689 100644 --- a/.github/workflows/bot-lint-comment.yml +++ b/.github/workflows/bot-lint-comment.yml @@ -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 @@ -30,6 +31,12 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} + - name: Ensure log files exist + # Check that the log files exist and create empty ones in case the Linter job + # failed to produce/upload them (see + # https://github.com/scikit-learn/scikit-learn/issues/34719). + run: touch "$ARTIFACTS_DIR/linting_output.txt" "$ARTIFACTS_DIR/versions.txt" + # Adapted from https://github.com/docker-mailserver/docker-mailserver/pull/4267#issuecomment-2484565209 # Unfortunately there is no easier way to do it - name: Get PR number from triggering workflow information From c270ab821874ea50c3de01eccbb98d91273d3ad9 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Tue, 11 Aug 2026 13:09:49 +0200 Subject: [PATCH 02/14] remove empty file creation --- .github/workflows/bot-lint-comment.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/bot-lint-comment.yml b/.github/workflows/bot-lint-comment.yml index 1e4f10d20a689..3cc0788787862 100644 --- a/.github/workflows/bot-lint-comment.yml +++ b/.github/workflows/bot-lint-comment.yml @@ -31,12 +31,6 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} - - name: Ensure log files exist - # Check that the log files exist and create empty ones in case the Linter job - # failed to produce/upload them (see - # https://github.com/scikit-learn/scikit-learn/issues/34719). - run: touch "$ARTIFACTS_DIR/linting_output.txt" "$ARTIFACTS_DIR/versions.txt" - # Adapted from https://github.com/docker-mailserver/docker-mailserver/pull/4267#issuecomment-2484565209 # Unfortunately there is no easier way to do it - name: Get PR number from triggering workflow information From 29981b98f648690a86e7250a24e5c3b03c0a812a Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Tue, 11 Aug 2026 13:24:24 +0200 Subject: [PATCH 03/14] add handling if log files don't exist --- build_tools/get_comment.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build_tools/get_comment.py b/build_tools/get_comment.py index 43226c5dbd3ad..2ab5ab7c71351 100644 --- a/build_tools/get_comment.py +++ b/build_tools/get_comment.py @@ -20,6 +20,8 @@ def get_versions(versions_file): versions : dict A dictionary with the versions of the packages. """ + if not os.path.exists(versions_file): + return {} with open(versions_file, "r") as f: return dict(line.strip().split("=") for line in f) @@ -67,8 +69,11 @@ 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() + if os.path.exists(log_file): + with open(log_file, "r") as f: + log = f.read() + else: + log = "" sub_text = ( "\n\n _Generated for commit:" @@ -83,7 +88,7 @@ def get_message(log_file, repo_str, pr_number, sha, run_id, details, versions): "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 ) From 439f407daad45d4a75b38d9ff0f55cbef00ec775 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Tue, 11 Aug 2026 14:01:56 +0200 Subject: [PATCH 04/14] re-trigger CI From debc427bcc7db1b14855d11dd8e1c811be449817 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Wed, 12 Aug 2026 11:10:55 +0200 Subject: [PATCH 05/14] remove defensive download continuation --- .github/workflows/bot-lint-comment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/bot-lint-comment.yml b/.github/workflows/bot-lint-comment.yml index 3cc0788787862..6dc9c2c8de63d 100644 --- a/.github/workflows/bot-lint-comment.yml +++ b/.github/workflows/bot-lint-comment.yml @@ -23,7 +23,6 @@ jobs: run: mkdir -p "$ARTIFACTS_DIR" - name: Download artifact - continue-on-error: true uses: actions/download-artifact@v8 with: name: lint-log From e45a0aa5e74d820957ed0278c05bed7ac28b810f Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Wed, 12 Aug 2026 11:14:19 +0200 Subject: [PATCH 06/14] convert to EAFP and add comment --- build_tools/get_comment.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build_tools/get_comment.py b/build_tools/get_comment.py index 2ab5ab7c71351..125715d8d44e3 100644 --- a/build_tools/get_comment.py +++ b/build_tools/get_comment.py @@ -20,8 +20,6 @@ def get_versions(versions_file): versions : dict A dictionary with the versions of the packages. """ - if not os.path.exists(versions_file): - return {} with open(versions_file, "r") as f: return dict(line.strip().split("=") for line in f) @@ -69,12 +67,6 @@ def get_step_message(log, start, end, title, message, details): def get_message(log_file, repo_str, pr_number, sha, run_id, details, versions): - if os.path.exists(log_file): - with open(log_file, "r") as f: - log = f.read() - else: - log = "" - sub_text = ( "\n\n _Generated for commit:" f" [{sha[:7]}](https://github.com/{repo_str}/pull/{pr_number}/commits/{sha}). " @@ -82,6 +74,14 @@ def get_message(log_file, repo_str, pr_number, sha, run_id, details, versions): f"(https://github.com/{repo_str}/actions/runs/{run_id})_ " ) + # 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" From f1fe60aba45eec0e59e7e1d462bac94c0ade5bd3 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 09:54:34 +0200 Subject: [PATCH 07/14] remove artefact upload --- .github/workflows/lint.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 725b1da30fe76..2a17608844e59 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,12 +45,12 @@ jobs: ./build_tools/linting.sh &> /tmp/linting_output.txt cat /tmp/linting_output.txt - - name: Upload Artifact - if: always() - uses: actions/upload-artifact@v7 - with: - name: lint-log - path: | - /tmp/linting_output.txt - /tmp/versions.txt - retention-days: 1 + # - name: Upload Artifact + # if: always() + # uses: actions/upload-artifact@v7 + # with: + # name: lint-log + # path: | + # /tmp/linting_output.txt + # /tmp/versions.txt + # retention-days: 1 From 0b301b714ff38e02dac624787f7578500abd5711 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 10:03:49 +0200 Subject: [PATCH 08/14] remove file creation but enable upload --- .github/workflows/lint.yml | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2a17608844e59..4a6600f777a7b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,23 +34,23 @@ 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 - - # - name: Upload Artifact - # if: always() - # uses: actions/upload-artifact@v7 - # with: - # name: lint-log - # path: | - # /tmp/linting_output.txt - # /tmp/versions.txt - # retention-days: 1 + # 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() + uses: actions/upload-artifact@v7 + with: + name: lint-log + path: | + /tmp/linting_output.txt + /tmp/versions.txt + retention-days: 1 From c9d61b8dc58ef7838259ab97d8cc71e1a45c83e3 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 10:07:11 +0200 Subject: [PATCH 09/14] add `continue-on-error` --- .github/workflows/bot-lint-comment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bot-lint-comment.yml b/.github/workflows/bot-lint-comment.yml index 6dc9c2c8de63d..3cc0788787862 100644 --- a/.github/workflows/bot-lint-comment.yml +++ b/.github/workflows/bot-lint-comment.yml @@ -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 From fe80199a5150dd4f70c5e73b2fadb64b85e90d52 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 10:12:03 +0200 Subject: [PATCH 10/14] re-trigger CI From ad8aaa333902917e00e2e177287d40050b45f9d7 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 10:19:55 +0200 Subject: [PATCH 11/14] add version file handling --- build_tools/get_comment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build_tools/get_comment.py b/build_tools/get_comment.py index 125715d8d44e3..cfcb35fd9bc15 100644 --- a/build_tools/get_comment.py +++ b/build_tools/get_comment.py @@ -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): From 8385f3ce64bdbe8c45f7d023aca0cbc130ba4470 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 10:23:36 +0200 Subject: [PATCH 12/14] re-trigger CI From 73210cfe865ca3529761f0c96b366549b453fbf7 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 10:31:33 +0200 Subject: [PATCH 13/14] re-trigger CI after file handling added to `main` From b87ce5f7ef03f874088699b74726eb35c4311538 Mon Sep 17 00:00:00 2001 From: AnneBeyer Date: Thu, 13 Aug 2026 10:41:22 +0200 Subject: [PATCH 14/14] try again