Skip to content

Instantly share code, notes, and snippets.

@weierophinney
Last active Apr 11, 2022
Embed
What would you like to do?
Adding Renovate to Laminas, Mezzio repositories

Updating Laminas/Mezzio repositories to prepare for Renovate-Bot

Per discussion during the February 2022 Laminas Technical Steering Committee meeting, we have a plan for adding Renovate to automate the following in Laminas and Mezzio repsitories:

  • Automatically update composer.lock each night, without a pull request.
  • On test failures following ^^, open a PR.
  • Automatically widen ranges for new major releases in composer.json and create a PR.
  • Separate patches for laminas/* upgrades, as well as other repositories.

To do this, we need to do the following in each repository:

  1. Add a config.platform.php value to the composer.json corresponding to the minimum supported PHP version
  2. Update the lockfile using a Composer v2.2+ version
  3. Update the CI workflow to ensure that branches created by Renovate trigger the CI workflow

To make that happen, we need your help to create the pull requests accomplishing the above.

You will need:

  • git
  • Composer 2.2+ (run composer self-update --2 to ensure you have the most recent v2 release)
  • jq
  • curl, diff, and sed (standard in all Linux distributions and generally available on Mac and WSL)

Here are the steps:

  1. Clone the repository if you haven't already

  2. Check out the most recent release branch (if you just cloned, this will be the branch that's checked out initially).

  3. Create a new branch: git switch -c feature/renovate

  4. Run the following to add the platform PHP setting:

    $ composer config platform.php $(jq -r '.require.php' < composer.json | sed -E 's/^[\^~]?(\S+).*$/\1/')
  5. Update dependencies: composer update

  6. See if there are differences in the CI workflow:

    $ diff -u --ignore-all-space \
    <(curl -s https://raw.githubusercontent.com/laminas/laminas-eventmanager/9e11e32de9eb66451ddaba81d282cccb9bbf245f/.github/workflows/continuous-integration.yml) \
    .github/workflows/continuous-integration.yml
    • If there ARE differences, change the push.branches setting so any branch is allowed

    • If there ARE NOT differences, run the following:

      $ echo 'name: "Continuous Integration"
      
      on:
        pull_request:
        push:
          branches:
          tags:
      
      jobs:
        ci:
          uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x' > .github/workflows/continuous-integration.yml
  7. Stage and commit the files: git add composer.* .github/workflows/continuous-integration.yml && git commit -m 'Prepare for Renovate-Bot' -s

  8. Create a pull request from your feature/renovate branch. If you are using the GitHub CLI, this can be done with: gh pr create

Bonus Round

If you have time and are able, we can take this same time to update the automatic-releases workflow to use the new reusable workflow. This can be done int he same feature/renovate branch, as part of the same pull request.

  1. See if there are differences in the automatic-releases workflow:

    $ diff -u --ignore-all-space \
    <(curl -s https://raw.githubusercontent.com/laminas/laminas-eventmanager/9e11e32de9eb66451ddaba81d282cccb9bbf245f/.github/workflows/release-on-milestone-closed.yml) \
    .github/workflows/release-on-milestone-closed.yml
    • If there ARE differences, DO NOTHING

    • If there ARE NOT differences, run the following:

      $ echo 'name: "Automatic Releases"
      
      on:
        milestone:
          types:
            - "closed"
      
      jobs:
        release:
          uses: laminas/workflow-automatic-releases/.github/workflows/release-on-milestone-closed.yml@1.x
          secrets:
            GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
            GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
            ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
            SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}' > .github/workflows/release-on-milestone-closed.yml
  2. Stage and commit the files: git add .github/workflows/release-on-milestone-closed.yml && git commit -m 'Update to reusable automatic-releases workflow' -s

  3. Push the changes to your fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment