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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 725b1da30fe76..4a6600f777a7b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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() diff --git a/build_tools/get_comment.py b/build_tools/get_comment.py index 43226c5dbd3ad..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): @@ -67,9 +70,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): - with open(log_file, "r") as f: - log = f.read() - sub_text = ( "\n\n _Generated for commit:" f" [{sha[:7]}](https://github.com/{repo_str}/pull/{pr_number}/commits/{sha}). " @@ -77,13 +77,21 @@ 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" "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 )