|
| 1 | +Migrating Consumer Repositories |
| 2 | +=============================== |
| 3 | + |
| 4 | +Use this guide when an existing PHP package repository is adopting |
| 5 | +``fast-forward/dev-tools`` for the first time. The goal is to introduce the |
| 6 | +shared Composer scripts, workflow stubs, wiki setup, skills, and repository |
| 7 | +defaults in a reviewable pull request. |
| 8 | + |
| 9 | +This page complements :doc:`syncing-consumer-projects`; it focuses on the |
| 10 | +migration path instead of the full command reference. |
| 11 | + |
| 12 | +Preflight Checks |
| 13 | +---------------- |
| 14 | + |
| 15 | +Before installing DevTools, confirm the repository has: |
| 16 | + |
| 17 | +- a committed ``composer.json`` with the package name, PHP constraint, license, |
| 18 | + and autoload settings already reviewed; |
| 19 | +- a clean working tree; |
| 20 | +- a configured ``origin`` remote that points to the GitHub repository; |
| 21 | +- agreement on whether the repository should publish GitHub Pages reports and a |
| 22 | + GitHub Wiki; |
| 23 | +- a maintainer who can review workflow, Dependabot, and branch protection |
| 24 | + changes. |
| 25 | + |
| 26 | +If the repository already has custom workflows or generated documentation, list |
| 27 | +the files that must be preserved before running sync. The sync command protects |
| 28 | +many existing files by default, but maintainers should still review the outcome |
| 29 | +as infrastructure code. |
| 30 | + |
| 31 | +Install DevTools |
| 32 | +---------------- |
| 33 | + |
| 34 | +Install the package as a development dependency: |
| 35 | + |
| 36 | +.. code-block:: bash |
| 37 | +
|
| 38 | + composer require --dev fast-forward/dev-tools |
| 39 | +
|
| 40 | +Commit the Composer changes separately only if the repository prefers very small |
| 41 | +review steps. For most migrations, it is reasonable to keep the Composer update |
| 42 | +and generated sync changes in the same pull request so reviewers can understand |
| 43 | +the complete automation model. |
| 44 | + |
| 45 | +Run Sync Safely |
| 46 | +--------------- |
| 47 | + |
| 48 | +Run the sync command from the repository root: |
| 49 | + |
| 50 | +.. code-block:: bash |
| 51 | +
|
| 52 | + composer dev-tools:sync |
| 53 | +
|
| 54 | +Then inspect the result before staging anything: |
| 55 | + |
| 56 | +.. code-block:: bash |
| 57 | +
|
| 58 | + git status --short |
| 59 | + git diff |
| 60 | +
|
| 61 | +Expected changes can include: |
| 62 | + |
| 63 | +.. list-table:: |
| 64 | + :header-rows: 1 |
| 65 | + |
| 66 | + * - Area |
| 67 | + - Expected change |
| 68 | + - Review focus |
| 69 | + * - ``composer.json`` |
| 70 | + - Adds shared ``dev-tools`` scripts and GrumPHP defaults. |
| 71 | + - Keep existing package metadata, scripts, and project-specific settings. |
| 72 | + * - ``.github/workflows/*.yml`` |
| 73 | + - Adds thin workflow stubs that call reusable Fast Forward workflows. |
| 74 | + - Compare with any existing CI, release, docs, or Pages workflows. |
| 75 | + * - ``.editorconfig`` |
| 76 | + - Adds the shared editor defaults when missing. |
| 77 | + - Confirm indentation and line-ending expectations match the project. |
| 78 | + * - ``.github/dependabot.yml`` |
| 79 | + - Adds the shared Dependabot template when missing. |
| 80 | + - Confirm update cadence and ecosystem coverage. |
| 81 | + * - ``.github/wiki`` |
| 82 | + - Adds the wiki submodule when missing. |
| 83 | + - Confirm the wiki repository exists and branch protection is compatible. |
| 84 | + * - ``.agents/skills`` |
| 85 | + - Links packaged skills for issue, PR, tests, docs, README, and style work. |
| 86 | + - Preserve existing custom skills and non-symlink directories. |
| 87 | + * - ``LICENSE`` |
| 88 | + - Adds the packaged license file when missing. |
| 89 | + - Confirm it matches the package metadata. |
| 90 | + * - ``.gitignore`` and ``.gitattributes`` |
| 91 | + - Adds repository defaults when missing. |
| 92 | + - Keep existing project-specific ignores and export rules. |
| 93 | + |
| 94 | +Handling Existing Custom Files |
| 95 | +------------------------------ |
| 96 | + |
| 97 | +When a target file already exists, treat the migration as a comparison exercise: |
| 98 | + |
| 99 | +1. keep the existing file in place; |
| 100 | +2. compare it with the corresponding packaged file or workflow stub; |
| 101 | +3. copy only the entries that make sense for the repository; |
| 102 | +4. leave a pull request note explaining any intentional divergence. |
| 103 | + |
| 104 | +This is especially important for custom CI workflows, release automation, |
| 105 | +repository-specific ``.gitignore`` rules, and existing Dependabot policies. |
| 106 | +Shared defaults are meant to reduce repeated maintenance, not erase local |
| 107 | +constraints. |
| 108 | + |
| 109 | +Branch Protection and Bot Commits |
| 110 | +--------------------------------- |
| 111 | + |
| 112 | +Consumer repositories commonly protect ``main``. That is compatible with the |
| 113 | +Fast Forward model: |
| 114 | + |
| 115 | +- pull requests receive generated previews and bot updates on the PR branch; |
| 116 | +- report previews are published under PR-specific Pages paths; |
| 117 | +- wiki previews use branches such as ``pr-123`` before merge; |
| 118 | +- post-merge jobs publish final reports and wiki content from ``main``. |
| 119 | + |
| 120 | +If branch protection blocks bot commits to pull request branches, either adjust |
| 121 | +the repository policy to allow workflow updates on PR branches or document that |
| 122 | +maintainers must refresh generated pointers manually before merge. |
| 123 | + |
| 124 | +Suggested Pull Request Rollout |
| 125 | +------------------------------ |
| 126 | + |
| 127 | +Use one migration pull request per consumer repository: |
| 128 | + |
| 129 | +1. install ``fast-forward/dev-tools``; |
| 130 | +2. run ``composer dev-tools:sync``; |
| 131 | +3. review and adapt generated files; |
| 132 | +4. run the smallest relevant local verification command; |
| 133 | +5. open the pull request and let GitHub Actions create previews; |
| 134 | +6. verify report and wiki preview links before merge; |
| 135 | +7. merge through the protected ``main`` branch. |
| 136 | + |
| 137 | +After merge, confirm that the final reports and wiki pages reflect the merged |
| 138 | +revision. If they do not, inspect the workflow logs before making follow-up |
| 139 | +changes. |
| 140 | + |
| 141 | +Related References |
| 142 | +------------------ |
| 143 | + |
| 144 | +- :doc:`syncing-consumer-projects` |
| 145 | +- :doc:`syncing-packaged-skills` |
| 146 | +- :doc:`github-actions` |
0 commit comments