-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Connector CI: Update nightlies to write to GCS #26929
Merged
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
11b9bbd
Generate report output prefix
983dab4
DNC
d453de4
Upload to gcs bucket
61bbacc
Revert dev comments
31af476
Format
aa90f16
Reenable for cron
b8f7b55
remove reports
2819e35
Merge origin/master
7c51451
Connector CI reports
f2af62d
Reremove AWS
c6dfa9f
Missed some env vars
2c762c3
Move bucket to CI
8569e83
Merge origin/master
12ba356
Bad merge
b2cc13c
Merge origin/master
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,10 +40,7 @@ def validate_environment(is_local: bool, use_remote_secrets: bool): | |
else: | ||
required_env_vars_for_ci = [ | ||
"GCP_GSM_CREDENTIALS", | ||
"AWS_ACCESS_KEY_ID", | ||
"AWS_SECRET_ACCESS_KEY", | ||
"AWS_DEFAULT_REGION", | ||
"TEST_REPORTS_BUCKET_NAME", | ||
"CI_REPORT_BUCKET_NAME", | ||
"CI_GITHUB_ACCESS_TOKEN", | ||
] | ||
for required_env_var in required_env_vars_for_ci: | ||
|
@@ -55,11 +52,55 @@ def validate_environment(is_local: bool, use_remote_secrets: bool): | |
) | ||
|
||
|
||
def render_report_output_prefix(ctx: click.Context) -> str: | ||
"""Render the report output prefix for any command in the Connector CLI. | ||
|
||
The goal is to standardize the output of all logs and reports generated by the CLI | ||
related to a specific command, and to a specific CI context. | ||
|
||
Note: We cannot hoist this higher in the command hierarchy because only one level of | ||
subcommands are available at the time the context is created. | ||
""" | ||
|
||
git_branch = ctx.obj["git_branch"] | ||
git_revision = ctx.obj["git_revision"] | ||
pipeline_start_timestamp = ctx.obj["pipeline_start_timestamp"] | ||
ci_context = ctx.obj["ci_context"] | ||
sanitized_branch = git_branch.replace("/", "_") | ||
|
||
# get the command name for the current context, if a group then prepend the parent command name | ||
invoked_subcommand = ctx.invoked_subcommand | ||
parent_command_path = ctx.command_path.replace(" ", "/") if ctx.command_path else None | ||
cmd = f"{parent_command_path}/{invoked_subcommand}" if parent_command_path else invoked_subcommand | ||
|
||
path_values = [ | ||
cmd, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
ci_context, | ||
sanitized_branch, | ||
pipeline_start_timestamp, | ||
git_revision, | ||
] | ||
|
||
# check all values are defined | ||
if None in path_values: | ||
raise ValueError(f"Missing value required to render the report output prefix: {path_values}") | ||
|
||
# join all values with a slash, and convert all values to string | ||
return "/".join(map(str, path_values)) | ||
|
||
|
||
# COMMANDS | ||
|
||
|
||
@click.group(help="Commands related to connectors and connector acceptance tests.") | ||
@click.option("--use-remote-secrets", default=True) # specific to connectors | ||
@click.option( | ||
"--ci-gcs-credentials", | ||
help="The service account to use during CI.", | ||
type=click.STRING, | ||
required=False, # Not required for pre-release or local pipelines | ||
envvar="GCP_GSM_CREDENTIALS", | ||
) | ||
@click.option( | ||
"--name", "names", multiple=True, help="Only test a specific connector. Use its technical name. e.g source-pokeapi.", type=str | ||
) | ||
|
@@ -82,7 +123,8 @@ def validate_environment(is_local: bool, use_remote_secrets: bool): | |
@click.pass_context | ||
def connectors( | ||
ctx: click.Context, | ||
use_remote_secrets: str, | ||
use_remote_secrets: bool, | ||
ci_gcs_credentials: str, | ||
names: Tuple[str], | ||
languages: Tuple[ConnectorLanguage], | ||
release_stages: Tuple[str], | ||
|
@@ -95,12 +137,14 @@ def connectors( | |
|
||
ctx.ensure_object(dict) | ||
ctx.obj["use_remote_secrets"] = use_remote_secrets | ||
ctx.obj["ci_gcs_credentials"] = ci_gcs_credentials | ||
ctx.obj["connector_names"] = names | ||
ctx.obj["connector_languages"] = languages | ||
ctx.obj["release_states"] = release_stages | ||
ctx.obj["modified"] = modified | ||
ctx.obj["concurrency"] = concurrency | ||
ctx.obj["execute_timeout"] = execute_timeout | ||
ctx.obj["report_output_prefix"] = render_report_output_prefix(ctx) | ||
|
||
all_connectors = get_all_released_connectors() | ||
|
||
|
@@ -165,12 +209,14 @@ def test( | |
git_branch=ctx.obj["git_branch"], | ||
git_revision=ctx.obj["git_revision"], | ||
modified_files=modified_files, | ||
s3_report_key="python-poc/tests/history/", | ||
test_report_bucket=ctx.obj["ci_report_bucket_name"], | ||
report_output_prefix=ctx.obj["report_output_prefix"], | ||
use_remote_secrets=ctx.obj["use_remote_secrets"], | ||
gha_workflow_run_url=ctx.obj.get("gha_workflow_run_url"), | ||
pipeline_start_timestamp=ctx.obj.get("pipeline_start_timestamp"), | ||
ci_context=ctx.obj.get("ci_context"), | ||
pull_request=ctx.obj.get("pull_request"), | ||
ci_gcs_credentials=ctx.obj["ci_gcs_credentials"], | ||
) | ||
for connector, modified_files in ctx.obj["selected_connectors_and_files"].items() | ||
] | ||
|
@@ -205,11 +251,13 @@ def build(ctx: click.Context) -> bool: | |
git_branch=ctx.obj["git_branch"], | ||
git_revision=ctx.obj["git_revision"], | ||
modified_files=modified_files, | ||
s3_report_key="python-poc/build/history/", | ||
test_report_bucket=ctx.obj["ci_report_bucket_name"], | ||
report_output_prefix=ctx.obj["report_output_prefix"], | ||
use_remote_secrets=ctx.obj["use_remote_secrets"], | ||
gha_workflow_run_url=ctx.obj.get("gha_workflow_run_url"), | ||
pipeline_start_timestamp=ctx.obj.get("pipeline_start_timestamp"), | ||
ci_context=ctx.obj.get("ci_context"), | ||
ci_gcs_credentials=ctx.obj["ci_gcs_credentials"], | ||
) | ||
for connector, modified_files in ctx.obj["selected_connectors_and_files"].items() | ||
] | ||
|
@@ -299,6 +347,7 @@ def publish( | |
ctx.obj["spec_cache_bucket_name"] = spec_cache_bucket_name | ||
ctx.obj["metadata_service_bucket_name"] = metadata_service_bucket_name | ||
ctx.obj["metadata_service_gcs_credentials"] = metadata_service_gcs_credentials | ||
|
||
validate_publish_options(pre_release, ctx.obj) | ||
if ctx.obj["is_local"]: | ||
click.confirm( | ||
|
@@ -314,29 +363,33 @@ def publish( | |
|
||
click.secho(f"Will publish the following connectors: {', '.join(selected_connectors_names)}.", fg="green") | ||
|
||
publish_connector_contexts = reorder_contexts([ | ||
PublishConnectorContext( | ||
connector, | ||
pre_release, | ||
modified_files, | ||
spec_cache_gcs_credentials, | ||
spec_cache_bucket_name, | ||
metadata_service_gcs_credentials, | ||
metadata_service_bucket_name, | ||
docker_hub_username, | ||
docker_hub_password, | ||
slack_webhook, | ||
slack_channel, | ||
ctx.obj["is_local"], | ||
ctx.obj["git_branch"], | ||
ctx.obj["git_revision"], | ||
gha_workflow_run_url=ctx.obj.get("gha_workflow_run_url"), | ||
pipeline_start_timestamp=ctx.obj.get("pipeline_start_timestamp"), | ||
ci_context=ctx.obj.get("ci_context"), | ||
pull_request=ctx.obj.get("pull_request"), | ||
) | ||
for connector, modified_files in selected_connectors_and_files.items() | ||
]) | ||
publish_connector_contexts = reorder_contexts( | ||
[ | ||
PublishConnectorContext( | ||
connector=connector, | ||
pre_release=pre_release, | ||
modified_files=modified_files, | ||
spec_cache_gcs_credentials=spec_cache_gcs_credentials, | ||
spec_cache_bucket_name=spec_cache_bucket_name, | ||
metadata_service_gcs_credentials=metadata_service_gcs_credentials, | ||
metadata_bucket_name=metadata_service_bucket_name, | ||
docker_hub_username=docker_hub_username, | ||
docker_hub_password=docker_hub_password, | ||
slack_webhook=slack_webhook, | ||
reporting_slack_channel=slack_channel, | ||
test_report_bucket=ctx.obj["ci_report_bucket_name"], | ||
report_output_prefix=ctx.obj["report_output_prefix"], | ||
is_local=ctx.obj["is_local"], | ||
git_branch=ctx.obj["git_branch"], | ||
git_revision=ctx.obj["git_revision"], | ||
gha_workflow_run_url=ctx.obj.get("gha_workflow_run_url"), | ||
pipeline_start_timestamp=ctx.obj.get("pipeline_start_timestamp"), | ||
ci_context=ctx.obj.get("ci_context"), | ||
ci_gcs_credentials=ctx.obj["ci_gcs_credentials"], | ||
) | ||
for connector, modified_files in selected_connectors_and_files.items() | ||
] | ||
) | ||
|
||
click.secho("Concurrency is forced to 1. For stability reasons we disable parallel publish pipelines.", fg="yellow") | ||
ctx.obj["concurrency"] = 1 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this function can be a method of the Report class, given you'd pass the invoked_command to our
PipelineContext
class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this in as I think its a good idea for the
airbyte-ci
to set the top level path for all airbyte-ci related outputs.This lets us standardize the path in both the pipelines and any utilities we might make.