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

infra: code freeze workflow #767

Merged
merged 9 commits into from
Nov 20, 2023
Merged

infra: code freeze workflow #767

merged 9 commits into from
Nov 20, 2023

Conversation

ajberdy
Copy link
Contributor

@ajberdy ajberdy commented Oct 27, 2023

Issue #, if available:

Description of changes:

Support for selectively freezing main branch

Testing done:

Manual testing of the following cases:

  • Freeze without specifying feature branch:
    • Feature branch can be merged
    • Critical fix can be merged
    • Other code cannot be merged
  • Freeze with specifying feature branch:
    • Matching feature branch can be merged (exact and prefix match)
    • Other feature branch cannot be merged
  • Freeze off
    • Any code can be merged (check is skipped)

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ajberdy ajberdy requested a review from speller26 October 27, 2023 21:56
@ajberdy ajberdy requested a review from a team as a code owner October 27, 2023 21:56
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (44a2bbb) 100.00% compared to head (23c8ad4) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #767   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          129       129           
  Lines         8374      8374           
  Branches      1866      1866           
=========================================
  Hits          8374      8374           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- main

env:
FROZEN: "false" # Set to "true" to freeze branches, "false" otherwise
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No these are just set within the workflow. Is there a benefit to moving to action variables until we want to reuse these values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't mind the workflow for updating action variables, but there's a limitation that you can't set an empty value (for allowing all feature branch merges) and there's no documentation to attach to the place they get updated.

We could update this workflow to use a more generable/intuitive env variable UNFROZEN_PREFIX to allow us to specify feature or feature/my-feature and not rely on an empty value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use repository variables

Copy link
Contributor

Choose a reason for hiding this comment

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

For code freezes, will we need to publish PRs each time? If so, I think using the action variables would allow for easier changes and cleaner commit history.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I've update the script to use action variables

ajberdy and others added 3 commits October 27, 2023 15:47
Co-authored-by: Abe Coull <85974725+math411@users.noreply.github.com>
@ajberdy ajberdy requested a review from AbeCoull October 27, 2023 23:09
@AbeCoull
Copy link
Contributor

If the branch is frozen will updates from main break?

@ajberdy
Copy link
Contributor Author

ajberdy commented Oct 27, 2023

If the branch is frozen will updates from main break?

There are two settings:

  • FROZEN: true/false
  • UNFROZEN_PREFIX: str

This workflow will run for any PR into main with the following logic:

FROZEN: bool
UNFROZEN_PREFIX: str

def can_merge_into_main(pr):
    if not FROZEN:
        return True
    else:
        if pr.branch.startswith(UNFROZEN_PREFIX):
            return True
        elif pr.title.startswith("fix:") and pr.title.contains("[critical]"):
            return True
        else:
            return False

I'm not sure specifically what you're asking about, but there is a race condition if the workflow succeeds before the repo is frozen and then is merged after. We can probably fix this by enabling a merge queue (which runs the workflows before merging), but maybe there's a more direct way to trigger this workflow only when the env variable is updated

AbeCoull
AbeCoull previously approved these changes Oct 27, 2023
@ajberdy
Copy link
Contributor Author

ajberdy commented Oct 27, 2023

It seems like a benefit of using variables within the file is if we update the workflow on main, then any PRs will have to update their branch (and rerun the code freeze workflow) before merging, avoiding the race condition we get with repository variables. I think that's enough of a reason to at least move the FROZEN variable to the file. We can leave the unfrozen prefix in the action variables if you think it makes sense, or might as well have them together

@ajberdy ajberdy requested a review from AbeCoull November 20, 2023 18:32
@ajberdy ajberdy merged commit 5d8e38c into main Nov 20, 2023
23 checks passed
@ajberdy ajberdy deleted the code-freeze branch November 20, 2023 18:52
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.

2 participants