-
-
Notifications
You must be signed in to change notification settings - Fork 10
Heal Dependabot hygiene from the pins catalog #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/usr/bin/env bash | ||
| # [MISE] description="Commit tracked files left dirty by mise run fix." | ||
| set -euo pipefail | ||
| cd "${MISE_PROJECT_ROOT:-$(cd "$(dirname "$0")/../../.." && pwd)}" | ||
|
|
||
| committed=false | ||
| git update-index -q --refresh | ||
| if ! git diff --quiet || ! git diff --cached --quiet; then | ||
| git add --update | ||
| git -c user.name="github-actions[bot]" \ | ||
| -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ | ||
| commit --message "chore: apply hygiene fixes" | ||
| committed=true | ||
| fi | ||
|
|
||
| if [[ -n ${GITHUB_OUTPUT:-} ]]; then | ||
| echo "committed=${committed}" >> "${GITHUB_OUTPUT}" | ||
| fi | ||
| if [[ ${committed} == true ]]; then | ||
| echo "committed=true" | ||
| else | ||
| echo "Tree already clean." | ||
| fi | ||
|
|
||
| if [[ -z ${GH_TOKEN:-} || -z ${HEAD_REF:-} ]]; then | ||
| exit 0 | ||
| fi | ||
| if [[ ${committed} != true && $(git log -1 --pretty=%s) != "chore: apply hygiene fixes" ]]; then | ||
| exit 0 | ||
|
Comment on lines
+30
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the workflow is rerun after a previous invocation pushed |
||
| fi | ||
| git push | ||
| # GITHUB_TOKEN pushes do not start new workflow runs, so dispatch CI on the | ||
| # updated branch after the push. | ||
| gh workflow run CI --ref "${HEAD_REF}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When hygiene pushes a generated-fix commit, the push deliberately creates no Useful? React with 👍 / 👎. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env python3 | ||
| # [MISE] description="Copy catalog action pins onto every consumer." | ||
| # [MISE] shell="python" | ||
|
|
||
| import pathlib | ||
| import sys | ||
|
|
||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[3] | ||
| sys.path.insert(0, str(ROOT)) | ||
|
|
||
| from ci.action_pins import fix_pins # noqa: E402 | ||
|
|
||
|
|
||
| def main() -> int: | ||
| changed = fix_pins(ROOT) | ||
| for path in changed: | ||
| print(f"updated {path.relative_to(ROOT).as_posix()}") | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,13 +68,18 @@ def setup( | |
| zig: bool = False, | ||
| gradle: bool = True, | ||
| save_toolchains: bool = False, | ||
| checkout: bool = True, | ||
| ) -> list[str]: | ||
| lines = [ | ||
| f" - uses: {CHECKOUT}", | ||
| " with:", | ||
| " persist-credentials: false", | ||
| " - uses: ./.github/actions/setup-ci-deps", | ||
| ] | ||
| lines: list[str] = [] | ||
| if checkout: | ||
| lines.extend( | ||
| [ | ||
| f" - uses: {CHECKOUT}", | ||
| " with:", | ||
| " persist-credentials: false", | ||
| ] | ||
| ) | ||
| lines.append(" - uses: ./.github/actions/setup-ci-deps") | ||
| if zig: | ||
| lines.append(" id: setup") | ||
| lines.append(" with:") | ||
|
|
@@ -227,6 +232,10 @@ def render(source: dict[str, object], presets: dict[str, object]) -> str: | |
| " - synchronize", | ||
| " - reopened", | ||
| " - ready_for_review", | ||
| # GITHUB_TOKEN pushes from Dependabot hygiene healing do not start | ||
| # pull_request workflows, so that job dispatches CI on the updated | ||
| # branch after it commits. | ||
| " workflow_dispatch:", | ||
| "", | ||
| "permissions:", | ||
| " contents: read", | ||
|
|
@@ -240,10 +249,23 @@ def render(source: dict[str, object], presets: dict[str, object]) -> str: | |
| " name: hygiene", | ||
| " runs-on: ubuntu-latest", | ||
| " timeout-minutes: 30", | ||
| " permissions:", | ||
| " contents: write", | ||
| " actions: write", | ||
|
Comment on lines
+252
to
+254
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Comment on lines
+252
to
+254
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a non-Dependabot same-repository pull request runs hygiene, this job-level block still grants every PR-controlled step—including Useful? React with 👍 / 👎. |
||
| SCCACHE_ENVIRONMENT, | ||
| *gate(), | ||
| " env:", | ||
| " DEPENDABOT_PR: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository }}", | ||
| " steps:", | ||
| *setup(gradle=False), | ||
| f" - uses: {CHECKOUT}", | ||
| " if: env.DEPENDABOT_PR != 'true'", | ||
| " with:", | ||
| " persist-credentials: false", | ||
| f" - uses: {CHECKOUT}", | ||
| " if: env.DEPENDABOT_PR == 'true'", | ||
| " with:", | ||
| " ref: ${{ github.head_ref }}", | ||
| *setup(gradle=False, checkout=False), | ||
| " - run: mise run ci:generate-workflow --check", | ||
| " - run: mise run ci:generate-devcontainer-tools --check", | ||
| " - run: mise run ci:test-release-tools", | ||
|
|
@@ -254,7 +276,14 @@ def render(source: dict[str, object], presets: dict[str, object]) -> str: | |
| # `mise run fix` provides the project-scoped formatter tools that the | ||
| # dprint wrappers expect; calling hk directly leaves them uninstalled. | ||
| " - run: mise run fix", | ||
| " - id: apply-fix", | ||
| " if: env.DEPENDABOT_PR == 'true'", | ||
| " env:", | ||
| " GH_TOKEN: ${{ github.token }}", | ||
| " HEAD_REF: ${{ github.head_ref }}", | ||
| " run: mise run ci:commit-hygiene-fixes", | ||
|
Comment on lines
+283
to
+288
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Dependabot updates Useful? React with 👍 / 👎. |
||
| " - name: Check generated and formatted files", | ||
| " if: steps.apply-fix.outputs.committed != 'true'", | ||
| " run: |", | ||
| " git update-index -q --refresh", | ||
| " git diff --exit-code -- . ':(exclude)mise*.lock'", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When mise rewrites any tracked root
mise*.lockfile during a Dependabot hygiene run, this unrestricted dirty-tree check stages and commits it, even though the workflow's existing generated-file check deliberately excludes those files at lines 289-290. This turns tolerated, runner-generated lockfile changes into bot-authored dependency-PR changes and can trigger an unnecessary full CI dispatch; apply the same path exclusion when deciding what to commit and when staging it.Useful? React with 👍 / 👎.