Add brew sync-tap-workflows developer command#3
Add brew sync-tap-workflows developer command#3Copilot wants to merge 7 commits intodev-cmd/add-brew-sync-tap-workflowsfrom
brew sync-tap-workflows developer command#3Conversation
Co-authored-by: toobuntu <674390+toobuntu@users.noreply.github.com>
brew sync-tap-workflows developer command
|
@copilot
private_constant :CASK_WORKFLOWS, :FORMULA_WORKFLOWS, :CASK_RAW_URL, :CORE_RAW_URL, :ORG_GITHUB_RAW_URL
If |
…dd docs/completions Co-authored-by: toobuntu <674390+toobuntu@users.noreply.github.com>
Done in 160f7f3:
|
|
@copilot Are the transforms being applied when brew sync-tap-workflows --dry-run --cask toobuntu/testing | awk '/Would write/ {print $NF}'
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/ci.yml
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/ci-retry.yml
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/actionlint.yml
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/autobump.yml.disabled
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/cache.yml
brew sync-tap-workflows --dry-run --formula toobuntu/testing | awk '/Would write/ {print $NF}'
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/autobump.yml.disabled
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/actionlint.yml
/opt/homebrew/Library/Taps/toobuntu/homebrew-testing/.github/workflows/cache.ymlIt seems that |
Co-authored-by: toobuntu <674390+toobuntu@users.noreply.github.com> Agent-Logs-Url: https://github.com/toobuntu/brew/sessions/3a7e25cf-4dba-4c61-8743-3ca6ffcac96a
Addressed in 00f9496: Transforms in Summary: Added an end-of-run summary that lists all file paths, e.g.:
|
Co-authored-by: toobuntu <674390+toobuntu@users.noreply.github.com> Agent-Logs-Url: https://github.com/toobuntu/brew/sessions/4665abaf-3b56-4fab-a763-c4cbbeb9891a
Co-authored-by: toobuntu <674390+toobuntu@users.noreply.github.com> Agent-Logs-Url: https://github.com/toobuntu/brew/sessions/30a430b4-4118-444a-b94a-5995114821ef
… add docs Co-authored-by: toobuntu <674390+toobuntu@users.noreply.github.com> Agent-Logs-Url: https://github.com/toobuntu/brew/sessions/9bbb6b9b-bf8d-4cca-b881-b2d1b54d7188
on:key)tests.ymlandpublish.ymlfor--formula(single source of truth viaTapNew):tap-new.rb: extract two class methodsTapNew.render_tests_yml(branch:, github_packages: false, root_url: nil)andTapNew.render_publish_yml(branch:, label:, github_packages: false); updaterunto call them — ERB content identical, no other changessync_tap_workflows.rb:require "dev-cmd/tap-new", callTapNew.render_tests_yml/render_publish_yml; addwrite_static_workflowhelper for dry-run/write path; add--pull-label=flagsync_tap_workflows.rbbrew generate-man-completionsin this PR)brew sync-tap-workflowssection todocs/How-to-Create-and-Maintain-a-Tap.mdbrew typecheckandbrew testspassOriginal prompt
Summary
Add a new
brew sync-tap-workflowsdeveloper command that fetches workflow files from upstream Homebrew taps (Homebrew/homebrew-caskorHomebrew/homebrew-core) and adapts them for use in third-party taps using YAML-aware mutations via thepsych-puregem (comment-preserving YAML parser).Motivation
Third-party tap maintainers have no way to keep CI workflows in sync with upstream Homebrew. The existing
tap-newembeds workflow templates as ERB heredocs that drift over time. This command provides both initial generation and ongoing sync, and will be called bytap-newin a follow-up PR to replace the ERB heredoc approach for cask/shared workflows.Background discussions:
New dependency: psych-pure
Add
psych-puretoLibrary/Homebrew/Gemfilein a new optional group:This gem provides comment-preserving YAML parsing/dumping. It is pure Ruby (no native extensions), stable, and used in production by Discourse. See: https://github.com/kddnewton/psych-pure
New file:
Library/Homebrew/dev-cmd/sync_tap_workflows.rbNote: Homebrew dev-cmd files use underscores in filenames (matching the Ruby class name), while the CLI command uses hyphens (
brew sync-tap-workflows). Check existing dev-cmd files for the correct convention and follow it.CLI interface
Flags
Error if neither
--casknor--formulais specified.How it works
Fetch upstream files via GitHub raw content URL:
--cask: fetch fromHomebrew/homebrew-cask— files:ci.yml,ci-retry.yml,actionlint.yml,autobump.yml,cache.yml--formula: fetch fromHomebrew/homebrew-core— files:autobump.yml, and fromHomebrew/.github(the org-wide shared config repo) — files:actionlint.yml. Forcache.yml, fetch fromHomebrew/homebrew-cask(it's the same across repos, synced by the.githubrepo).Use
Utils::Curl.curl_downloadorGitHub::API.open_restor similar Homebrew patterns for fetching. Check how other dev-cmds fetch remote content and follow that pattern. The URL pattern is:Parse with psych-pure (comment-preserving):
Apply YAML-tree mutations (structural changes on the parsed data):
For ALL workflow files that have
on.push.branches:For ALL workflow files that have
on.merge_group:Also remove
merge_groupreferences inif:conditions (these are strings, so use String#gsub on theifvalue).For files with org guards (
if:conditions on jobs):github.repository_owner == 'Homebrew'withgithub.repository_owner == '<tap.user>'github.repository == 'Homebrew/homebrew-cask'withgithub.repository == '<tap.user>/homebrew-<tap.repository>'github.repository == 'Homebrew/homebrew-core'withgithub.repository == '<tap.user>/homebrew-<tap.repository>'Apply string mutations on
run:scalars (shell scripts insiderun:keys are opaque to YAML — use String#gsub):generate-matrixrun scripts: remove themerge_groupelif branch; keepnew_cask/--newlogic${{ join(matrix.audit_args, ' ') }}with--online --strict--tap=Homebrew/caskwith--tap=<tap.user>/<tap.repository>--tap=Homebrew/corewith--tap=<tap.user>/<tap.repository>Apply autobump-specific mutations:
yaml["jobs"]["autobump"]["steps"]and delete the step whosenamematches)secrets.HOMEBREW_CASK_REPO_WORKFLOW_TOKEN→secrets.BOT_TOKEN(string replace in env values)This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.