ci: auto-format pull requests - #901
Draft
AntonioVentilii wants to merge 5 commits into
Draft
Conversation
Prettier was bumped 3.8.3 -> 3.9.5 in #890, which changed how union types that fit on a single line are printed. The Format job only runs on `pull_request`, so the reformat landed on main unchecked and `npm run format:check` now fails on main and every open PR.
The Format job ran `prettier --check` and failed, leaving contributors to run the formatter by hand and push a follow-up commit. Run `npm run format` instead and, when the job can authenticate as the PR automation app, commit the result back to the PR branch. When it cannot (pushes, forks, dependabot), fall back to printing the diff and failing, which is the previous behaviour. Ports the pattern already used by dfinity/oisy-wallet in frontend-checks.yml, along with its add-and-commit composite action. The EndBug/add-and-commit pin matches the one already used by this repo in e2e-snapshots.yml.
|
✅ No security or compliance issues detected. Reviewed everything up to a58b925. Security Overview
Detected Code Changes
|
DenysKarmazynDFINITY
previously approved these changes
Aug 19, 2026
AntonioVentilii
dismissed
DenysKarmazynDFINITY’s stale review
August 19, 2026 09:24
The base branch was changed.
AntonioVentilii
enabled auto-merge (squash)
August 19, 2026 09:27
AntonioVentilii
disabled auto-merge
August 19, 2026 11:05
DenysKarmazynDFINITY
approved these changes
Aug 19, 2026
AntonioVentilii
marked this pull request as draft
August 19, 2026 12:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Today the
Formatjob runsprettier --checkand fails, leaving the contributor to run the formatter by hand and push a follow-up commit.dfinity/oisy-walletinstead runs the formatter in CI and commits the result back to the PR branch — see itsfrontend-checks.yml(frontend/prettier) andformatting-checks.yml(Rust/shell). This ports that pattern.Changes
.github/actions/add-and-commit— composite action ported fromdfinity/oisy-wallet. Re-supplies the token to git locally (checkout runs withpersist-credentials: false), commits, then unsets the config. TheEndBug/add-and-commitpin is v10.0.0 — the one this repo already uses ine2e-snapshots.yml— rather than oisy-wallet's older v9.1.4.lib-checks.ymlformatjob — mint a GitHub App token (continue-on-error), check out the PR head when one is available, runnpm run format, and commit🤖 Apply formatting changesif anything changed. Job permission goescontents: read->contents: write.Behaviour when the token is unavailable
can_add_commitisfalsefor pushes, fork PRs, and any run where the app token did not mint. In that case the job checks out normally, formats, prints the diff and exits 1 — i.e. exactly today's behaviour, just with a diff attached. Nothing gets silently skipped.This composes with #900: on a push to
main,github.event_name != 'pull_request', so it takes the fail-with-diff path rather than trying to commit tomain.Blocker found on the first run — the private key is not available to this repo
The
Formatrun on this PR shows the app variable resolves but the secret does not:So
vars.PR_AUTOMATION_BOT_PUBLIC_APP_IDreachesoisy-wallet-signer, butsecrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEYdoes not — most likely the org secret's repository-access list does not include this repo.The fallback behaved exactly as designed:
continue-on-errorswallowed the failure,can_add_commitbecamefalse, the job checked out normally, formatted, found no changes and passed. So this PR is safe to merge as-is — it is a no-op relative to today's behaviour until the secret is granted, at which point auto-commit starts working with no further code change.To actually enable it: grant
PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEYrepository access todfinity/oisy-wallet-signerin the org secret settings, and confirm the app is installed here withcontents: write.Minor:
actions/create-github-app-tokennow warns thatapp-idis deprecated in favour ofclient-id. Kept as-is to match the org variable (a numeric app id) anddfinity/oisy-wallet; switching would need a separate client-id variable.Known limitation — this would not have auto-fixed #890
The prettier bump that started this was authored by
app/dependabot. Dependabot-triggeredpull_requestruns get a read-only token and read from the separate Dependabot secrets store, not Actions secrets, so the app token will not mint on them and they take the fail-with-diff path.Auto-formatting dependabot PRs too would additionally require the app credentials to be added under Dependabot secrets. Worth doing as a follow-up if the team wants it, since dependency bumps are exactly the PRs that trigger reformats.
Verification
zizmor --persona pedanticpasses locally on both changed files (the three audits needing a GitHub API token were skipped; theLint GitHub Actionsjob here will cover those).prettier --checkpasses on both files.