Skip to content
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

Adjust release procedure and CI system for "trunk-based" development strategy #2120

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Jun 30, 2023

Previously, releases were always made from a point in the revision history of the main branch (typically the tip of the branch at the time of the release). Although the simplicity of this approach is nice, it can be limiting in some cases. For this reason, the project is switching to using a "trunk-based" development strategy, as described here:

https://trunkbaseddevelopment.com/

This approach allows making releases at any time that consist of the arbitrary subset of revisions suitable for shipping to the users at that time. The commits that should be included in the release are cherry-picked to a release branch and the tag created on that branch.

This means that:

  • PRs can be merged to the main branch as soon as they have passed review rather than having to postpone the merge of changes that are not ready to be included in the next release.
  • Releases don't need to be postponed if the prior revision history on the main branch contains changes that are not ready to be included in the release.

This development strategy is already in use in other Arduino Tooling projects (e.g., Arduino CLI, Arduino Lint, and Arduino Firmware Uploader).

The documented release procedure must be adjusted to reflect the new development strategy.

CI System Adjustments

The status of the GitHub Actions workflows should be evaluated before making a release. However, this is not so simple as checking the status of the commit at the tip of the release branch. The reason is that, for the sake of efficiency, the workflows are configured to run only when the processes are relevant to the trigger event (e.g., no need to run unit tests for a change to the readme).

In the case of the default branch, you can simply set the workflow runs filter to that branch and then check the result of the latest run of each workflow of interest. However, that was not possible to do with the release branch since it might be that the workflow was never run in that branch. The status of the latest run of the workflow in the default branch might not match the status for the release branch if the release branch does not contain the full history.

For this reason, it will be helpful to trigger all relevant workflows on the creation of a release branch. This will ensure that each of those workflows will always have at least one run in the release branch. Subsequent commits pushed to the branch can run based on their usual trigger filters and the status of the latest run of each workflow in the branch will provide an accurate indication of the state of that branch.

Branches are created for purposes other than releases, most notably feature branches to stage work for a pull request. Due to the comprehensive nature of this project's CI system, it would not be convenient or efficient to fully run all CI workflows on the creation of every feature branch.

Unfortunately, GitHub Actions does not support filters on the create event of branch creation like it does for the push and pull_request events. There is support for a branches filter of the push event, but that filter is an "AND" to the paths filter while this application requires an "OR". For this reason, the workflows must be triggered by the creation of any branch. The unwanted job runs are prevented by adding a run-determination job with the branch filter handled by Bash commands. The other jobs of the workflow use this run-determination job as a dependency, only running when it indicates they should via a job output. Because this minimal run-determination job runs very quickly, it is roughly equivalent to the workflow having been skipped entirely for non-release branch creations.

This system has been in use in the Tooling Team's collection of reusable "asset" workflows:

And in the downstream consumers of those workflows:

Motivation

Change description

Other information

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@per1234 per1234 added topic: documentation Related to documentation for the project type: enhancement Proposed improvement topic: infrastructure Related to project infrastructure labels Jun 30, 2023
@per1234 per1234 requested a review from kittaakos June 30, 2023 12:01
@per1234 per1234 self-assigned this Jun 30, 2023
Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

docs/internal/release-procedure.md Outdated Show resolved Hide resolved
@per1234 per1234 force-pushed the trunk-based branch 2 times, most recently from bd38428 to 1a7722b Compare June 30, 2023 12:27
…strategy

Previously, releases were always made from a point in the revision history of the `main` branch (typically the tip of
the branch at the time of the release). Although the simplicity of this approach is nice, it can be limiting in some
cases. For this reason, the project is switching to using a "trunk-based" development strategy, as described here:

https://trunkbaseddevelopment.com/

This approach allows making releases at any time that consist of the arbitrary subset of revisions suitable for shipping
to the users at that time. The commits that should be included in the release are cherry-picked to a release branch and
the tag created on that branch.

This means that:

- PRs can be merged to the `main` branch as soon as they have passed review rather than having to postpone the merge of
  changes that are not ready to be included in the next release.
- Releases don't need to be postponed if the prior revision history on the `main` branch contains changes that are not
  ready to be included in the release.

The documented release procedure must be adjusted to reflect the new development strategy.

CI System Adjustments
---------------------

The status of the GitHub Actions workflows should be evaluated before making a release. However, this is not so simple as
checking the status of the commit at the tip of the release branch. The reason is that, for the sake of efficiency, the
workflows are configured to run only when the processes are relevant to the trigger event (e.g., no need to run unit
tests for a change to the readme).

In the case of the default branch, you can simply set the workflow runs filter to that branch and then check the result
of the latest run of each workflow of interest. However, that was not possible to do with the release branch since it
might be that the workflow was never run in that branch. The status of the latest run of the workflow in the default
branch might not match the status for the release branch if the release branch does not contain the full history.

For this reason, it will be helpful to trigger all relevant workflows on the creation of a release branch. This will
ensure that each of those workflows will always have at least one run in the release branch. Subsequent commits pushed to
the branch can run based on their usual trigger filters and the status of the latest run of each workflow in the branch
will provide an accurate indication of the state of that branch.

Branches are created for purposes other than releases, most notably feature branches to stage work for a pull request.
Due to the comprehensive nature of this project's CI system, it would not be convenient or efficient to fully run all CI
workflows on the creation of every feature branch.

Unfortunately, GitHub Actions does not support filters on the `create` event of branch creation like it does for the
`push` and `pull_request` events. There is support for a `branches` filter of the `push` event, but that filter is an
"AND" to the `paths` filter while this application requires an "OR". For this reason, the workflows must be triggered by
the creation of any branch. The unwanted job runs are prevented by adding a `run-determination` job with the branch
filter handled by Bash commands. The other jobs of the workflow use this `run-determination` job as a dependency, only
running when it indicates they should via a job output. Because this minimal `run-determination` job runs very quickly,
it is roughly equivalent to the workflow having been skipped entirely for non-release branch creations.
@per1234 per1234 force-pushed the trunk-based branch 2 times, most recently from 85d9157 to cf93c82 Compare June 30, 2023 16:22
@per1234 per1234 merged commit 6e18dca into arduino:main Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: documentation Related to documentation for the project topic: infrastructure Related to project infrastructure type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants