Skip to content

Commit c47142f

Browse files
bleonardclnoll
andauthored
airbyte_ci: up_to_date command (#37487)
Co-authored-by: Catherine Noll <[email protected]>
1 parent 75ac5a9 commit c47142f

File tree

7 files changed

+477
-2
lines changed

7 files changed

+477
-2
lines changed

airbyte-ci/connectors/pipelines/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ At this point you can run `airbyte-ci` commands.
142142
- [`connectors publish` command](#connectors-publish-command)
143143
- [Examples](#examples)
144144
- [Options](#options-2)
145+
- [`connectors up_to_date` command](#up_to_date)
145146
- [`connectors bump_version` command](#connectors-bump_version)
146147
- [`connectors upgrade_cdk` command](#connectors-upgrade_cdk)
147148
- [`connectors upgrade_base_image` command](#connectors-upgrade_base_image)
@@ -456,6 +457,32 @@ remoteRegistries:
456457
packageName: airbyte-source-pokeapi
457458
```
458459
460+
### <a id="connectors-up_to_date"></a>`connectors up_to_date` command
461+
462+
Meant to be run on a cron script.
463+
464+
Actions:
465+
466+
* Upgrades dependecies to the current versions
467+
468+
### Examples
469+
470+
Bump source-openweather:
471+
472+
* `airbyte-ci connectors --name=source-openweather up_to_date`: upgrades main dependecies
473+
* `airbyte-ci connectors --name=source-openweather up_to_date --dev`: forces update if there are only dev changes
474+
* `airbyte-ci connectors --name=source-openweather up_to_date --dep pytest@^8.10 --dep [email protected]`: allows update to toml files as well
475+
476+
477+
### Other things it could do
478+
479+
* upgrade it the latest base image
480+
* make sure it's the newest version of pytest
481+
* do a `poetry update` to update everything else
482+
* make the pull requests on a well known branch, replacing the last one if still open
483+
* bump the toml and metadata and changelog
484+
* also bump the manifest version of the CDK
485+
459486
### <a id="connectors-bump_version"></a>`connectors bump_version` command
460487

461488
Bump the version of the selected connectors.

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ def should_use_remote_secrets(use_remote_secrets: Optional[bool]) -> bool:
153153
"migrate_to_base_image": "pipelines.airbyte_ci.connectors.migrate_to_base_image.commands.migrate_to_base_image",
154154
"migrate-to-poetry": "pipelines.airbyte_ci.connectors.migrate_to_poetry.commands.migrate_to_poetry",
155155
"upgrade_base_image": "pipelines.airbyte_ci.connectors.upgrade_base_image.commands.upgrade_base_image",
156-
"upgrade_cdk": "pipelines.airbyte_ci.connectors.upgrade_cdk.commands.bump_version",
156+
"upgrade_cdk": "pipelines.airbyte_ci.connectors.upgrade_cdk.commands.upgrade_cdk",
157+
"up_to_date": "pipelines.airbyte_ci.connectors.up_to_date.commands.up_to_date",
157158
},
158159
)
159160
@click.option(

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/consts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class CONNECTOR_TEST_STEP_ID(str, Enum):
3030
CHECK_MIGRATION_CANDIDATE = "check_migration_candidate"
3131
POETRY_INIT = "poetry_init"
3232
DELETE_SETUP_PY = "delete_setup_py"
33+
CHECK_UPDATE_CANDIDATE = "check_update_candidate"
34+
UPDATE_POETRY = "upgrade_poetry"
3335
CONNECTOR_REGRESSION_TESTS = "connector_regression_tests"
3436

3537
def __str__(self) -> str:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
from typing import List
6+
7+
import asyncclick as click
8+
from pipelines.airbyte_ci.connectors.context import ConnectorContext
9+
from pipelines.airbyte_ci.connectors.pipeline import run_connectors_pipelines
10+
from pipelines.airbyte_ci.connectors.up_to_date.pipeline import run_connector_up_to_date_pipeline
11+
from pipelines.cli.dagger_pipeline_command import DaggerPipelineCommand
12+
13+
14+
@click.command(
15+
cls=DaggerPipelineCommand,
16+
short_help="Get the selected Python connectors up to date.",
17+
)
18+
@click.option(
19+
"--dev",
20+
type=bool,
21+
default=False,
22+
is_flag=True,
23+
help="Force update when there are only dev changes.",
24+
)
25+
@click.option(
26+
"--dep",
27+
type=str,
28+
multiple=True,
29+
default=[],
30+
help="Give a specific set of `poetry add` dependencies to update. For example: --dep airbyte-cdk==0.80.0 --dep pytest@^6.2",
31+
)
32+
33+
# TODO: flag to skip regression tests
34+
# TODO: flag to make PR
35+
# TODO: also update the manifest.yaml with the cdk version?
36+
@click.pass_context
37+
async def up_to_date(ctx: click.Context, dev: bool, dep: List[str]) -> bool:
38+
39+
connectors_contexts = [
40+
ConnectorContext(
41+
pipeline_name=f"Update {connector.technical_name} to latest",
42+
connector=connector,
43+
is_local=ctx.obj["is_local"],
44+
git_branch=ctx.obj["git_branch"],
45+
git_revision=ctx.obj["git_revision"],
46+
ci_report_bucket=ctx.obj["ci_report_bucket_name"],
47+
report_output_prefix=ctx.obj["report_output_prefix"],
48+
use_remote_secrets=ctx.obj["use_remote_secrets"],
49+
gha_workflow_run_url=ctx.obj.get("gha_workflow_run_url"),
50+
dagger_logs_url=ctx.obj.get("dagger_logs_url"),
51+
pipeline_start_timestamp=ctx.obj.get("pipeline_start_timestamp"),
52+
ci_context=ctx.obj.get("ci_context"),
53+
ci_gcs_credentials=ctx.obj["ci_gcs_credentials"],
54+
ci_git_user=ctx.obj["ci_git_user"],
55+
ci_github_access_token=ctx.obj["ci_github_access_token"],
56+
enable_report_auto_open=True,
57+
docker_hub_username=ctx.obj.get("docker_hub_username"),
58+
docker_hub_password=ctx.obj.get("docker_hub_password"),
59+
s3_build_cache_access_key_id=ctx.obj.get("s3_build_cache_access_key_id"),
60+
s3_build_cache_secret_key=ctx.obj.get("s3_build_cache_secret_key"),
61+
)
62+
for connector in ctx.obj["selected_connectors_with_modified_files"]
63+
]
64+
65+
await run_connectors_pipelines(
66+
connectors_contexts,
67+
run_connector_up_to_date_pipeline,
68+
"Get Python connector up to date",
69+
ctx.obj["concurrency"],
70+
ctx.obj["dagger_logs_path"],
71+
ctx.obj["execute_timeout"],
72+
dev,
73+
dep,
74+
)
75+
76+
return True

0 commit comments

Comments
 (0)