Skip to content

Commit 00f6442

Browse files
airbyte-ci makes pull requests (#37649)
Co-authored-by: alafanechere <[email protected]> Co-authored-by: Augustin <[email protected]>
1 parent a4fb5ab commit 00f6442

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1811
-286
lines changed

airbyte-ci/connectors/connector_ops/connector_ops/utils.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def download_catalog(catalog_url):
5757

5858
OSS_CATALOG = download_catalog(OSS_CATALOG_URL)
5959
METADATA_FILE_NAME = "metadata.yaml"
60+
MANIFEST_FILE_NAME = "manifest.yaml"
61+
DOCKERFILE_FILE_NAME = "Dockerfile"
62+
PYPROJECT_FILE_NAME = "pyproject.toml"
6063
ICON_FILE_NAME = "icon.svg"
6164

6265
STRATEGIC_CONNECTOR_THRESHOLDS = {
@@ -347,9 +350,25 @@ def icon_path(self) -> Path:
347350
def code_directory(self) -> Path:
348351
return Path(f"./{CONNECTOR_PATH_PREFIX}/{self.relative_connector_path}")
349352

353+
@property
354+
def python_source_dir_path(self) -> Path:
355+
return self.code_directory / self.technical_name.replace("-", "_")
356+
357+
@property
358+
def manifest_path(self) -> Path:
359+
return self.python_source_dir_path / MANIFEST_FILE_NAME
360+
350361
@property
351362
def has_dockerfile(self) -> bool:
352-
return (self.code_directory / "Dockerfile").is_file()
363+
return self.dockerfile_file_path.is_file()
364+
365+
@property
366+
def dockerfile_file_path(self) -> Path:
367+
return self.code_directory / DOCKERFILE_FILE_NAME
368+
369+
@property
370+
def pyproject_file_path(self) -> Path:
371+
return self.code_directory / PYPROJECT_FILE_NAME
353372

354373
@property
355374
def metadata_file_path(self) -> Path:

airbyte-ci/connectors/pipelines/README.md

+71-2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ At this point you can run `airbyte-ci` commands.
148148
- [`connectors upgrade_base_image` command](#connectors-upgrade_base_image)
149149
- [`connectors migrate_to_base_image` command](#connectors-migrate_to_base_image)
150150
- [`connectors migrate-to-poetry` command](#connectors-migrate-to-poetry)
151+
- [`connectors migrate_to_inline_schemas` command](#migrate_to_inline_schemas)
152+
- [`connectors pull_request` command](#pull_request)
151153
- [`format` command subgroup](#format-subgroup)
152154
- [`format check` command](#format-check-command)
153155
- [`format fix` command](#format-fix-command)
@@ -464,15 +466,28 @@ Meant to be run on a cron script.
464466
Actions:
465467

466468
* Upgrades dependecies to the current versions
469+
* Can make a pull request and bump version, changelog
470+
471+
```
472+
Usage: airbyte-ci connectors up_to_date [OPTIONS]
473+
474+
Options:
475+
--dev Force update when there are only dev changes.
476+
--dep TEXT Give a specific set of `poetry add` dependencies to update. For
477+
example: --dep airbyte-cdk==0.80.0 --dep pytest@^6.2
478+
--report Auto open report browser.
479+
--pull Create a pull request.
480+
--help Show this message and exit.
481+
```
467482
468483
### Examples
469484
470-
Bump source-openweather:
485+
Get source-openweather up to date. If there are changes, bump the version and add to changelog:
471486
472487
* `airbyte-ci connectors --name=source-openweather up_to_date`: upgrades main dependecies
473488
* `airbyte-ci connectors --name=source-openweather up_to_date --dev`: forces update if there are only dev changes
474489
* `airbyte-ci connectors --name=source-openweather up_to_date --dep pytest@^8.10 --dep [email protected]`: allows update to toml files as well
475-
490+
* `airbyte-ci connectors --name=source-openweather up_to_date --pull`: make a pull request for it
476491
477492
### Other things it could do
478493
@@ -555,6 +570,60 @@ Migrate connectors the poetry package manager.
555570
Migrate source-openweather to use the base image:
556571
`airbyte-ci connectors --name=source-openweather migrate-to-poetry`
557572
573+
### <a id="connectors-migrate_to_inline_schemas"></a>`connectors migrate_to_inline_schemas` command
574+
575+
Migrate `.json` schemas into `manifest.yaml` files, when present.
576+
577+
```
578+
Usage: airbyte-ci connectors migrate_to_inline_schemas [OPTIONS]
579+
580+
Options:
581+
--report Auto open report browser.
582+
--help Show this message and exit.
583+
```
584+
585+
#### Examples
586+
587+
Migrate source-quickbooks to use inline schemas:
588+
`airbyte-ci connectors --name=source-quickbooks migrate_to_inline_schemas`
589+
590+
### <a id="connectors-pull_request"></a>`connectors pull_request` command
591+
592+
Makes a pull request for all changed connectors. If the branch already exists, it will update the existing one.
593+
594+
```
595+
Usage: airbyte-ci connectors pull_request [OPTIONS]
596+
597+
Options:
598+
-m, --message TEXT Commit message and pull request title and
599+
changelog (if enabled). [required]
600+
-b, --branch_id TEXT update a branch named <branch_id>/<connector-
601+
name> instead generating one from the message.
602+
[required]
603+
--report Auto open report browser.
604+
--title TEXT Title of the PR to be created or edited
605+
(optional - defaults to message or no change).
606+
--body TEXT Body of the PR to be created or edited (optional
607+
- defaults to empty or not change).
608+
--changelog Add message to the changelog for this version.
609+
--bump [patch|minor|major] Bump the metadata.yaml version. Can be `major`,
610+
`minor`, or `patch`.
611+
--dry-run Don't actually make the pull requests. Just
612+
print the files that would be changed.
613+
--help Show this message and exit.
614+
```
615+
616+
#### Examples
617+
618+
Make a PR for all changes, bump the version and make a changelog in those PRs. They will be on the branch ci_update/round2/<connector-name>:
619+
`airbyte-ci connectors pull_request -m "upgrading connectors" -b ci_update/round2 --bump patch --changelog`
620+
621+
Do it just for a few connectors:
622+
`airbyte-ci connectors --name source-aha --name source-quickbooks pull_request -m "upgrading connectors" -b ci_update/round2 --bump patch --changelog`
623+
624+
You can also set or set/change the title or body of the PR:
625+
`airbyte-ci connectors --name source-aha --name source-quickbooks pull_request -m "upgrading connectors" -b ci_update/round2 --title "New title" --body "full body\n\ngoes here"`
626+
558627
### <a id="format-subgroup"></a>`format` command subgroup
559628
560629
Available commands:

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

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ async def build(ctx: click.Context, use_host_gradle_dist_tar: bool, build_archit
5050
is_local=ctx.obj["is_local"],
5151
git_branch=ctx.obj["git_branch"],
5252
git_revision=ctx.obj["git_revision"],
53+
diffed_branch=ctx.obj["diffed_branch"],
54+
git_repo_url=ctx.obj["git_repo_url"],
5355
ci_report_bucket=ctx.obj["ci_report_bucket_name"],
5456
report_output_prefix=ctx.obj["report_output_prefix"],
5557
use_remote_secrets=ctx.obj["use_remote_secrets"],

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/build_image/steps/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
from __future__ import annotations
77

88
import anyio
9-
from connector_ops.utils import ConnectorLanguage # type: ignore
9+
from connector_ops.utils import ConnectorLanguage # type: ignore
1010
from pipelines.airbyte_ci.connectors.build_image.steps import java_connectors, python_connectors
1111
from pipelines.airbyte_ci.connectors.build_image.steps.common import LoadContainerToLocalDockerHost, StepStatus
1212
from pipelines.airbyte_ci.connectors.context import ConnectorContext
1313
from pipelines.airbyte_ci.connectors.reports import ConnectorReport, Report
1414
from pipelines.models.steps import StepResult
1515

1616

17-
1817
class NoBuildStepForLanguageError(Exception):
1918
pass
2019

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/build_image/steps/build_customization.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ def get_build_customization_module(connector: Connector) -> Optional[ModuleType]
2222
"""
2323
build_customization_spec_path = connector.code_directory / BUILD_CUSTOMIZATION_SPEC_NAME
2424

25-
if not build_customization_spec_path.exists() or not (build_customization_spec := importlib.util.spec_from_file_location(
26-
f"{connector.code_directory.name}_{BUILD_CUSTOMIZATION_MODULE_NAME}", build_customization_spec_path
27-
)):
25+
if not build_customization_spec_path.exists() or not (
26+
build_customization_spec := importlib.util.spec_from_file_location(
27+
f"{connector.code_directory.name}_{BUILD_CUSTOMIZATION_MODULE_NAME}", build_customization_spec_path
28+
)
29+
):
2830
return None
2931

3032
if build_customization_spec.loader is None:

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/build_image/steps/common.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
if TYPE_CHECKING:
1616
from typing import Any
1717

18+
1819
class BuildConnectorImagesBase(Step, ABC):
1920
"""
2021
A step to build connector images for a set of platforms.
@@ -39,13 +40,17 @@ async def _run(self, *args: Any) -> StepResult:
3940
await connector.with_exec(["spec"])
4041
except ExecError as e:
4142
return StepResult(
42-
step=self, status=StepStatus.FAILURE, stderr=str(e),
43-
stdout=f"Failed to run the spec command on the connector container for platform {platform}."
43+
step=self,
44+
status=StepStatus.FAILURE,
45+
stderr=str(e),
46+
stdout=f"Failed to run the spec command on the connector container for platform {platform}.",
47+
exc_info=e,
4448
)
4549
build_results_per_platform[platform] = connector
4650
except QueryError as e:
47-
return StepResult(step=self, status=StepStatus.FAILURE,
48-
stderr=f"Failed to build connector image for platform {platform}: {e}")
51+
return StepResult(
52+
step=self, status=StepStatus.FAILURE, stderr=f"Failed to build connector image for platform {platform}: {e}"
53+
)
4954
success_message = (
5055
f"The {self.context.connector.technical_name} docker image "
5156
f"was successfully built for platform(s) {', '.join(self.build_platforms)}"
@@ -86,6 +91,7 @@ def image_name(self) -> str:
8691

8792
async def _run(self) -> StepResult:
8893
loaded_images = []
94+
image_sha = None
8995
multi_platforms = len(self.containers) > 1
9096
for platform, container in self.containers.items():
9197
_, exported_tar_path = await export_container_to_tarball(self.context, container, platform)
@@ -109,4 +115,6 @@ async def _run(self) -> StepResult:
109115
step=self, status=StepStatus.FAILURE, stderr=f"Something went wrong while interacting with the local docker client: {e}"
110116
)
111117

112-
return StepResult(step=self, status=StepStatus.SUCCESS, stdout=f"Loaded image {','.join(loaded_images)} to your Docker host ({image_sha}).")
118+
return StepResult(
119+
step=self, status=StepStatus.SUCCESS, stdout=f"Loaded image {','.join(loaded_images)} to your Docker host ({image_sha})."
120+
)

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/build_image/steps/normalization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BuildOrPullNormalization(Step):
1414
"""A step to build or pull the normalization image for a connector according to the image name."""
1515

1616
context: ConnectorContext
17-
17+
1818
def __init__(self, context: ConnectorContext, normalization_image: str, build_platform: Platform) -> None:
1919
"""Initialize the step to build or pull the normalization image.
2020

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/build_image/steps/python_connectors.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,9 @@ async def _create_builder_container(self, base_container: Container) -> Containe
4646
Container: The builder container, with installed dependencies.
4747
"""
4848
ONLY_BUILD_FILES = ["pyproject.toml", "poetry.lock", "poetry.toml", "setup.py", "requirements.txt", "README.md"]
49-
49+
5050
builder = await with_python_connector_installed(
51-
self.context,
52-
base_container,
53-
str(self.context.connector.code_directory),
54-
install_root_package=False,
55-
include=ONLY_BUILD_FILES
51+
self.context, base_container, str(self.context.connector.code_directory), install_root_package=False, include=ONLY_BUILD_FILES
5652
)
5753
return builder
5854

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

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ async def bump_version(
2929
is_local=ctx.obj["is_local"],
3030
git_branch=ctx.obj["git_branch"],
3131
git_revision=ctx.obj["git_revision"],
32+
diffed_branch=ctx.obj["diffed_branch"],
33+
git_repo_url=ctx.obj["git_repo_url"],
3234
ci_report_bucket=ctx.obj["ci_report_bucket_name"],
3335
report_output_prefix=ctx.obj["report_output_prefix"],
3436
use_remote_secrets=ctx.obj["use_remote_secrets"],

0 commit comments

Comments
 (0)