Skip to content

Add Dependabot gate to auto-close dependency bumps ahead of Home Assistant#263

Merged
timlaing merged 6 commits into
mainfrom
copilot/check-compatibility-home-assistant
May 26, 2026
Merged

Add Dependabot gate to auto-close dependency bumps ahead of Home Assistant#263
timlaing merged 6 commits into
mainfrom
copilot/check-compatibility-home-assistant

Conversation

Copy link
Copy Markdown

Copilot AI commented May 26, 2026

Dependabot PRs can propose dependency versions newer than what Home Assistant currently pins, creating churn and incompatible update noise. This change adds an automated gate to close those PRs when the proposed version is ahead of HA’s current requirement.

  • Workflow entrypoint and safety scope

    • Adds .github/workflows/close_dependabot_pr_if_ha_older.yml.
    • Runs on pull_request_target events and only executes for dependabot[bot].
  • Version extraction and comparison logic

    • Parses Dependabot PR titles (Bump <dep> from <old> to <new>) using robust delimiter logic.
    • Fetches home-assistant/core dev/requirements_all.txt.
    • Normalizes dependency names (-, _, .) before matching and compares versions via packaging.version.Version.
  • Automated PR action

    • If HA’s pinned version is older than the PR target version, posts a reasoned comment and closes the PR.
    • Falls back safely (no close) for parse failures, missing pins, invalid versions, or fetch errors.
if: steps.compare.outputs.should_close == 'true'
uses: actions/github-script@v8
with:
  script: |
    await github.rest.issues.createComment({ ... });
    await github.rest.pulls.update({ state: "closed", ... });

@timlaing timlaing marked this pull request as ready for review May 26, 2026 21:15
Copilot AI review requested due to automatic review settings May 26, 2026 21:15
@timlaing timlaing merged commit d8fed9d into main May 26, 2026
20 of 21 checks passed
@timlaing timlaing deleted the copilot/check-compatibility-home-assistant branch May 26, 2026 21:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions workflow to automatically close Dependabot dependency-bump PRs when the proposed dependency version is newer than the version pinned by Home Assistant, reducing upgrade churn and keeping this project aligned with HA’s dependency constraints.

Changes:

  • Introduces a pull_request_target workflow that runs only for Dependabot PRs.
  • Parses Dependabot PR titles to extract dependency name and target version, then fetches HA’s requirements_all.txt to compare pinned versions.
  • If HA’s pinned version is older than the Dependabot target, comments with the reason and closes the PR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


jobs:
close_pr_if_ha_uses_older_version:
if: github.actor == 'dependabot[bot]'
Comment on lines +50 to +52
run: |
python -m pip install --disable-pip-version-check packaging
python - <<'PY'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants