-
-
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 all commits
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,40 @@ | ||
| #!/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 | ||
| # Hygiene ignores runner-generated lockfile churn; keep that out of the commit. | ||
| lockfile_exclude=':(exclude)mise*.lock' | ||
| git update-index -q --refresh | ||
| if ! git diff --quiet -- . "${lockfile_exclude}" \ | ||
| || ! git diff --cached --quiet -- . "${lockfile_exclude}"; then | ||
| git add --update -- . "${lockfile_exclude}" | ||
| 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 | ||
| # A clean tree whose tip is already a hygiene commit still pushes and | ||
| # dispatches. That recovers a run that committed and pushed, then failed | ||
| # before `gh workflow run` (maplibre-compose#1140). | ||
| if [[ ${committed} != true && $(git log -1 --pretty=%s) != "chore: apply hygiene fixes" ]]; then | ||
| exit 0 | ||
| 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,21 +249,45 @@ 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: dprint output-resolved-config > /dev/null", | ||
| # `mise run fix` rewrites consumer action pins from the catalog, then | ||
| # `ci:generate-workflow` applies those pins to this file. Both run | ||
| # before --check so a Dependabot catalog bump can heal instead of | ||
| # failing the job first. `mise run fix` also provides the | ||
| # project-scoped formatter tools that the dprint wrappers expect. | ||
| " - run: mise run fix", | ||
| " - run: mise run ci:generate-workflow", | ||
| " - run: mise run ci:generate-workflow --check", | ||
| " - run: mise run ci:generate-devcontainer-tools --check", | ||
| " - run: mise run ci:test-release-tools", | ||
| " - run: mise run --force //bindings/dart:ffigen", | ||
| " - run: mise run --force //bindings/dotnet:generate", | ||
| " - run: mise run --force //bindings/kotlin:generate", | ||
| " - run: dprint output-resolved-config > /dev/null", | ||
| # `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 the workflow is rerun after a previous invocation pushed
chore: apply hygiene fixes, the clean tree still bypasses this early return based solely on the tip commit message. The script then pushes an unchanged branch and starts another complete CI workflow for the same commit, wasting CI capacity and potentially producing concurrent runs for one SHA.