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

[airbyte-ci/auto-merge] - Updates PR pipeline to bypass CI checks for promoted release candidate PRs #49827

Merged
merged 25 commits into from
Jan 9, 2025

Conversation

pnilan
Copy link
Contributor

@pnilan pnilan commented Dec 17, 2024

What

  • Adds new auto-merge/bypass-checks label to publishing pipeline when publishing with --promote-release-candidate flag.
  • auto-merge workflow includes label mapping to required validator methods. If new autom-merge/byapss-checks label included in a given PR, auto-merge will run all validator methods except for the CI checks one.
  • Closes https://github.com/airbytehq/airbyte-internal-issues/issues/11168

How

  • New auto-merge/bypass-ci-checks label added to PR when running publish pipeline with --promote-release-candidate flag. Also new promoted-rc label added for human filtering of PRs
  • Checks the PR against a mapped set of PR validators based on included labels within the PR.
    • New get_pr_validators method checks the PR's labels against the new VALIDATOR_MAPPING and returns mapped pr validator methods.

Review guide

  1. publish/pipeline.py
  2. auto_merge/main.py
  3. auto_merge/pr_validators.py
  4. auto_merge/consts.py

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 9, 2025 10:44pm

Copy link
Contributor

@clnoll clnoll left a comment

Choose a reason for hiding this comment

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

@pnilan this looks good to me, just a couple of very minor comments. I'll leave the final approval to @alafanechere.

@@ -753,7 +753,7 @@ async def run_connector_promote_pipeline(context: PublishConnectorContext, semap
all_modified_files.update(
await add_changelog_entry.export_modified_files(context.connector.local_connector_documentation_directory)
)
post_changelog_pr_update = CreateOrUpdatePullRequest(context, skip_ci=False, labels=["auto-merge"])
post_changelog_pr_update = CreateOrUpdatePullRequest(context, skip_ci=True, labels=["auto-merge", "auto-merge/promoted-rc"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Can "auto-merge" and "auto-merge/promoted-rc" be pulled in from the constants file?

Copy link
Contributor

Choose a reason for hiding this comment

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

We could ideally add the auto_merge packages as a dependency of pipelines and import constant from it.

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 add automerge as a dependency.

@@ -48,12 +48,13 @@ def head_commit_passes_all_required_checks(
return True, None


# A PR is considered auto-mergeable if:
# A standard PR is considered auto-mergeable if:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since we don't define what "standard" means here, I'd prefer to leave this comment as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

Copy link
Contributor

@alafanechere alafanechere 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 @pnilan . The implementation looks correct. Please consider my suggestion which I think would help in the maintenance of the package in case other use cases like this arise in the future. And can you please bump the auto_merge package version in pyproject.toml?

Comment on lines 58 to 60
# Let's declare faster checks first as the check_if_pr_is_auto_mergeable function fails fast.
DEFAULT_ENABLED_VALIDATORS = [has_auto_merge_label, targets_main_branch, only_modifies_connectors, head_commit_passes_all_required_checks]
PROMOTED_RC_PR_VALIDATORS = [has_auto_merge_label, targets_main_branch, only_modifies_connectors]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd reverse the logic.
The default validators would have less requirements than a second one which would require the head commit to pass.

DEFAULT_ENABLED_VALIDATORS = {has_auto_merge_label, targets_main_branch, only_modifies_connectors}
PASSING_CHECKS_VALIDATORS = DEFAULT_ENABLED_VALIDATORS + { "head_commit_passes_all_required_checks"}

It would define an implicit logic of strictness elevation.

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 agree -- updated.

Comment on lines 6 to 7
AUTO_MERGE_LABEL = "auto-merge"
AUTO_MERGE_PROMOTED_RC_LABEL = "auto-merge/promoted-rc"
Copy link
Contributor

@alafanechere alafanechere Dec 19, 2024

Choose a reason for hiding this comment

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

I suggest removing the auto-merge/ prefix and defining a mapping of labels to validator groups. This would allow to easily expand your implementation to other use cases.
E.g : A PR has the auto-merge label AND promoted-rc -> use a specific set of validators. We could then add different combination with only a single change to make to a mapping.

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've updated this by adding a get_pr_validators function and a label -> validator mapping dictionary. Take a look and let me know what you think.

@@ -753,7 +753,7 @@ async def run_connector_promote_pipeline(context: PublishConnectorContext, semap
all_modified_files.update(
await add_changelog_entry.export_modified_files(context.connector.local_connector_documentation_directory)
)
post_changelog_pr_update = CreateOrUpdatePullRequest(context, skip_ci=False, labels=["auto-merge"])
post_changelog_pr_update = CreateOrUpdatePullRequest(context, skip_ci=True, labels=["auto-merge", "auto-merge/promoted-rc"])
Copy link
Contributor

Choose a reason for hiding this comment

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

We could ideally add the auto_merge packages as a dependency of pipelines and import constant from it.

@@ -115,7 +115,7 @@ async def get_file_contents(container: Container, path: str) -> Optional[str]:
def catch_exec_error_group() -> Generator:
try:
yield
except anyio.ExceptionGroup as eg:
except ExceptionGroup as eg:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the inclusion of auto-merge as a library, I needed to update the anyio version to at least 4.0.0, which deprecated anyio.ExceptionGroup in favor of the built-in ExceptionGroup. See here: https://anyio.readthedocs.io/en/stable/migration.html#task-groups-now-wrap-single-exceptions-in-groups

Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 67 to 71
# Let's declare faster checks first as the check_if_pr_is_auto_mergeable function fails fast.
VALIDATOR_MAPPING: dict[str, list[Callable]] = {
AUTO_MERGE_LABEL: [has_auto_merge_label, targets_main_branch, only_modifies_connectors, head_commit_passes_all_required_checks],
AUTO_MERGE_BYPASS_CI_CHECKS_LABEL: [has_auto_merge_bypass_ci_checks_label, targets_main_branch, only_modifies_connectors],
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit for readability

Suggested change
# Let's declare faster checks first as the check_if_pr_is_auto_mergeable function fails fast.
VALIDATOR_MAPPING: dict[str, list[Callable]] = {
AUTO_MERGE_LABEL: [has_auto_merge_label, targets_main_branch, only_modifies_connectors, head_commit_passes_all_required_checks],
AUTO_MERGE_BYPASS_CI_CHECKS_LABEL: [has_auto_merge_bypass_ci_checks_label, targets_main_branch, only_modifies_connectors],
}
COMMON_VALIDATORS = {
has_auto_merge_label,
targets_main_branch,
only_modifies_connectors,
}
# Let's declare faster checks first as the check_if_pr_is_auto_mergeable function fails fast.
VALIDATOR_MAPPING: dict[str, set[Callable]] = {
AUTO_MERGE_LABEL: COMMON_VALIDATORS + {head_commit_passes_all_required_checks},
AUTO_MERGE_BYPASS_CI_CHECKS_LABEL: COMMON_VALIDATORS,
}

@pnilan pnilan merged commit 4265fab into master Jan 9, 2025
29 checks passed
@pnilan pnilan deleted the pnilan/workflows/update-automerge-rules branch January 9, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants