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

Proposal on consistent approach for running GitHub actions #3961

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

kevindew
Copy link
Member

This has been produced following the discussiona in: #3950 and #3816

This is to try resolve a consistency issue we have in GOV.UK where we have an agreed approach to using GitHub Actions documented which doesn't reflect the configurations used across GOV.UK.

Since we agreed the approach of running CI GitHub Action on [push, pull_request] and adopted it has become clear that this is not unanimously popular and, due to the appearance of duplicate jobs, can imply misconfiguration.

The motivation to document a new approach is to try form consensus on an approach that can be good enough for most cases and cover common concerns. This can then reduce the time we spend debating how to configure individual projects.

Aspects I've wanted to cover in this are:

  • Stay broadly consistent with approach replatforming popularised since that is what is predominantly in use
  • Remove the appearance of duplicate runs by default in pull requests
  • Allow CI for external contributors (our current process for dealing with them seems more of a legacy Jenkins concern)
  • Offer an approach for running CI without opening a PR, as that seems to be a common point of contention (it's a key part of some workflows, yet not a concern for others).

A risk of this approach is that the use of workflow_dispatch is somewhat ignored and thus unreliable. This doesn't seem a huge concern to me as I imagine this would be fixed if it's used frequently or be a sign that it can be removed.

@sengi
Copy link
Contributor

sengi commented Apr 18, 2023

Just to add a bit of extra background: the practical motivation for eliminating the duplicate runs is that in at least one repo (govuk-developer-docs) they've been exacerbating flakiness because of expensive tests exhausting quotas and this has been a non-negligible time sink for Replatforming team because we're trying to be helpful and make lots of updates to existing documentation in that repo.

@sengi sengi requested review from theseanything and sengi April 18, 2023 11:28
Copy link
Contributor

@sengi sengi left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good to me 👍

Definitely worth getting @theseanything's input as well.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
```

We previously recommended CI jobs to run on `[push, pull_request]` as per
[RFC-123][] however this caused an appearance of duplicate runs of a CI job
Copy link
Contributor

@sengi sengi Apr 18, 2023

Choose a reason for hiding this comment

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

It definitely runs real duplicate jobs, unfortunately. Disappointing that GitHub doesn't just solve this out of the box, as it's a sore point for so many of its users :(

Suggested change
[RFC-123][] however this caused an appearance of duplicate runs of a CI job
[RFC-123] however this caused duplicate runs of a CI job

Copy link
Contributor

@ChrisBAshton ChrisBAshton Apr 19, 2023

Choose a reason for hiding this comment

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

Worth updating the PR description and commit message too, as they still reference "appearance of", @kevindew

@sengi
Copy link
Contributor

sengi commented Apr 18, 2023

Happy to help with rolling this out btw!

Copy link
Contributor

@theseanything theseanything left a comment

Choose a reason for hiding this comment

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

Looks good - thanks for updating this!

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@kevindew
Copy link
Member Author

Thank you @theseanything and @sengi ⭐ . I'll make amends to this later and seek a wider input before merging.

@kevindew kevindew marked this pull request as ready for review April 18, 2023 16:29
@kevindew
Copy link
Member Author

Thanks @theseanything and @sengi, I think I've got all your suggestions in now, do shout if I've got any wrong.

I'll go ask in #govuk-developers

Copy link
Contributor

@robinjam robinjam left a comment

Choose a reason for hiding this comment

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

Love this, especially the addition of the workflow_dispatch trigger to allow folks run CI on their branch without raising a PR (if they wish).

Copy link
Contributor

@ChrisBAshton ChrisBAshton left a comment

Choose a reason for hiding this comment

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

LGTM ⭐ Thanks for raising this.

workflow_dispatch:
inputs:
ref:
description: 'The branch, tag or SHA to checkout'
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: we can omit these quotes I think.

Comment on lines 36 to 37
tested and because `pull_request` merges the changes with
the repository default branch.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this last bit. Don't GitHub actions run against the branch as-is, whether or not the trigger was push or pull_request?

Copy link
Contributor

@sengi sengi Apr 19, 2023

Choose a reason for hiding this comment

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

So I only found out about the details of this recently myself (thanks to @kevindew for putting me onto it) — pull_request uses the refs/pull/<pr_number>/merge reference that GitHub uses for setting up the merge. (I believe this is essentially the PR branch rebased onto the destination branch, but don't quote me on that.) Compare https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request with https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push

If the PR branch is up-to-date with main then there should be no practical difference, but if they've diverged significantly and "Require branches to be up-to-date before merging" isn't enabled (which it shouldn't normally need to be — in fact I'd guess that's why the pull_request trigger uses the merge ref rather than the PR branch as-is) then it could mean you're testing against an old version of the rest of the codebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation! Perhaps we should amend that sentence to link back to your comment? 🙏

This has been produced following the discussiona in:
#3950 and
#3816

This is to try resolve a consistency issue we have in GOV.UK where we
have an agreed approach to using GitHub Actions documented which doesn't
reflect the configurations used across GOV.UK.

Since we agreed the approach of running CI GitHub Action on `[push,
pull_request]` and adopted it has become clear that this is not
unanimously popular and, due to the appearance of duplicate jobs, can
imply misconfiguration.

The motivation to document a new approach is to try form consensus on an
approach that can be good enough for most cases and cover common
concerns. This can then reduce the time we spend debating how to
configure individual projects.

Aspects I've wanted to cover in this are:

- Stay broadly consistent with approach replatforming popularised since
  that is what is predominantly in use
- Remove the appearance of duplicate runs by default in pull requests
- Allow CI for external contributors (our [current process for dealing
  with them][1] seems more of a legacy Jenkins concern)
- Offer an approach for running CI without opening a PR, as that seems
  to be a common point of contention (it's a key part of some workflows,
  yet not a concern for others).

A risk of this approach is that the use of workflow_dispatch is somewhat
ignored and thus unreliable. This doesn't seem a huge concern to me as I
imagine this would be fixed if it's used frequently or be a sign that it
can be removed.

[1]: https://docs.publishing.service.gov.uk/manual/merge-pr.html#a-change-from-an-external-contributor
@kevindew
Copy link
Member Author

Thanks all!

@kevindew kevindew merged commit 032a03b into main Apr 21, 2023
@kevindew kevindew deleted the ci-proposal branch April 21, 2023 17:02
kevindew added a commit to alphagov/govuk_publishing_components that referenced this pull request Jun 2, 2023
This changes the approach to how this GitHub Action is run to reflect
the change in standards in GOV.UK [1]

[1]: alphagov/govuk-developer-docs#3961
kevindew added a commit to alphagov/govuk_publishing_components that referenced this pull request Jun 2, 2023
This changes the approach to how this GitHub Action is run to reflect
the change in standards in GOV.UK [1]

[1]: alphagov/govuk-developer-docs#3961
kevindew added a commit to alphagov/govuk_app_config that referenced this pull request Jun 2, 2023
kevindew added a commit to alphagov/govspeak that referenced this pull request Jun 22, 2023
kevindew added a commit to alphagov/govspeak that referenced this pull request Jul 4, 2023
kevindew added a commit to alphagov/rubocop-govuk that referenced this pull request Jul 27, 2023
This updates the approach to running this workflow to reflect the
approach in: alphagov/govuk-developer-docs#3961
kevindew added a commit to alphagov/rubocop-govuk that referenced this pull request Jul 27, 2023
This updates the approach to running this workflow to reflect the
approach in: alphagov/govuk-developer-docs#3961
kevindew added a commit to alphagov/rubocop-govuk that referenced this pull request Jul 27, 2023
This updates the approach to running this workflow to reflect the
approach in: alphagov/govuk-developer-docs#3961
kevindew added a commit to alphagov/gds-sso that referenced this pull request Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants