Skip to content

Commit 91700ed

Browse files
committed
Merge remote-tracking branch 'origin/main' into aj/feat/cli/add-docker-mode-fast-test-option
2 parents bfe7d91 + d09c2ec commit 91700ed

File tree

67 files changed

+6372
-881
lines changed

Some content is hidden

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

67 files changed

+6372
-881
lines changed

.github/workflows/connector-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ concurrency:
2525
jobs:
2626
cdk_changes:
2727
name: Get Changes
28-
runs-on: ubuntu-22.04
28+
runs-on: ubuntu-24.04
2929
permissions:
3030
statuses: write
3131
pull-requests: read
@@ -62,7 +62,7 @@ jobs:
6262
# Forked PRs are handled by the community_ci.yml workflow
6363
# If the condition is not met the job will be skipped (it will not fail)
6464
# runs-on: connector-test-large
65-
runs-on: ubuntu-22.04
65+
runs-on: ubuntu-24.04
6666
timeout-minutes: 360 # 6 hours
6767
strategy:
6868
fail-fast: false
@@ -153,7 +153,7 @@ jobs:
153153
POETRY_DYNAMIC_VERSIONING_BYPASS: "0.0.0"
154154
run: |
155155
cd airbyte
156-
make tools.airbyte-ci-dev.install
156+
make tools.airbyte-ci.install
157157
airbyte-ci \
158158
--ci-report-bucket-name=airbyte-ci-reports-multi \
159159
connectors \

airbyte_cdk/cli/airbyte_cdk/_connector.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@
4444

4545
import rich_click as click
4646

47-
# from airbyte_cdk.test.standard_tests import pytest_hooks
48-
from airbyte_cdk.cli.airbyte_cdk._util import resolve_connector_name_and_directory
49-
from airbyte_cdk.test.standard_tests.test_resources import find_connector_root_from_name
5047
from airbyte_cdk.test.standard_tests.util import create_connector_test_suite
5148

49+
# from airbyte_cdk.test.standard_tests import pytest_hooks
50+
from airbyte_cdk.utils.connector_paths import (
51+
find_connector_root_from_name,
52+
resolve_connector_name_and_directory,
53+
)
54+
5255
click.rich_click.TEXT_MARKUP = "markdown"
5356

5457
pytest: ModuleType | None
@@ -63,7 +66,7 @@
6366

6467
TEST_FILE_TEMPLATE = '''
6568
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
66-
"""FAST Airbyte Standard Tests for the source_pokeapi_w_components source."""
69+
"""FAST Airbyte Standard Tests for the {connector_name} source."""
6770
6871
#from airbyte_cdk.test.standard_tests import {base_class_name}
6972
from airbyte_cdk.test.standard_tests.util import create_connector_test_suite
@@ -78,7 +81,7 @@
7881
)
7982
8083
# class TestSuite({base_class_name}):
81-
# """Test suite for the source_pokeapi_w_components source.
84+
# """Test suite for the {connector_name} source.
8285
8386
# This class inherits from SourceTestSuiteBase and implements all of the tests in the suite.
8487
@@ -98,15 +101,11 @@ def connector_cli_group() -> None:
98101

99102

100103
@connector_cli_group.command()
101-
@click.option(
102-
"--connector-name",
104+
@click.argument(
105+
"connector",
106+
required=False,
103107
type=str,
104-
help="Name of the connector to test. Ignored if --connector-directory is provided.",
105-
)
106-
@click.option(
107-
"--connector-directory",
108-
type=click.Path(exists=True, file_okay=False, path_type=Path),
109-
help="Path to the connector directory.",
108+
metavar="[CONNECTOR]",
110109
)
111110
@click.option(
112111
"--collect-only",
@@ -125,8 +124,7 @@ def connector_cli_group() -> None:
125124
),
126125
)
127126
def test(
128-
connector_name: str | None = None,
129-
connector_directory: Path | None = None,
127+
connector: str | Path | None = None,
130128
*,
131129
collect_only: bool = False,
132130
use_docker_image: str | bool = False,
@@ -135,6 +133,9 @@ def test(
135133
136134
This command runs the standard connector tests for a specific connector.
137135
136+
[CONNECTOR] can be a connector name (e.g. 'source-pokeapi'), a path to a connector directory, or omitted to use the current working directory.
137+
If a string containing '/' is provided, it is treated as a path. Otherwise, it is treated as a connector name.
138+
138139
If no connector name or directory is provided, we will look within the current working
139140
directory. If the current working directory is not a connector directory (e.g. starting
140141
with 'source-' or 'destination-') and no connector name or path is provided, the process
@@ -152,10 +153,7 @@ def test(
152153
)
153154

154155
click.echo("Connector test command executed.")
155-
connector_name, connector_directory = resolve_connector_name_and_directory(
156-
connector_name=connector_name,
157-
connector_directory=connector_directory,
158-
)
156+
connector_name, connector_directory = resolve_connector_name_and_directory(connector)
159157

160158
connector_test_suite = create_connector_test_suite(
161159
connector_name=connector_name if not connector_directory else None,
@@ -171,7 +169,7 @@ def test(
171169

172170
file_text = TEST_FILE_TEMPLATE.format(
173171
base_class_name=connector_test_suite.__bases__[0].__name__,
174-
connector_directory=str(connector_directory),
172+
connector_name=connector_name,
175173
)
176174
test_file_path = Path() / ".tmp" / "integration_tests/test_airbyte_standards.py"
177175
test_file_path = test_file_path.resolve().absolute()

airbyte_cdk/cli/airbyte_cdk/_image.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
import rich_click as click
1212

13-
from airbyte_cdk.cli.airbyte_cdk._util import resolve_connector_name_and_directory
1413
from airbyte_cdk.models.connector_metadata import MetadataFile
14+
from airbyte_cdk.utils.connector_paths import resolve_connector_name_and_directory
1515
from airbyte_cdk.utils.docker import (
1616
ConnectorImageBuildError,
1717
build_connector_image,
@@ -28,49 +28,62 @@ def image_cli_group() -> None:
2828

2929

3030
@image_cli_group.command()
31-
@click.option(
32-
"--connector-name",
31+
@click.argument(
32+
"connector",
33+
required=False,
3334
type=str,
34-
help="Name of the connector to test. Ignored if --connector-directory is provided.",
35-
)
36-
@click.option(
37-
"--connector-directory",
38-
type=click.Path(exists=True, file_okay=False, path_type=Path),
39-
help="Path to the connector directory.",
35+
metavar="[CONNECTOR]",
4036
)
4137
@click.option("--tag", default="dev", help="Tag to apply to the built image (default: dev)")
4238
@click.option("--no-verify", is_flag=True, help="Skip verification of the built image")
39+
@click.option(
40+
"--dockerfile",
41+
type=click.Path(exists=True, file_okay=True, path_type=Path),
42+
help="Optional. Override the Dockerfile used for building the image.",
43+
)
4344
def build(
44-
connector_name: str | None = None,
45+
connector: str | None = None,
4546
connector_directory: Path | None = None,
4647
*,
4748
tag: str = "dev",
4849
no_verify: bool = False,
50+
dockerfile: Path | None = None,
4951
) -> None:
5052
"""Build a connector Docker image.
5153
5254
This command builds a Docker image for a connector, using either
5355
the connector's Dockerfile or a base image specified in the metadata.
5456
The image is built for both AMD64 and ARM64 architectures.
57+
58+
[CONNECTOR] can be a connector name (e.g. 'source-pokeapi'), a path to a connector directory, or omitted to use the current working directory.
59+
If a string containing '/' is provided, it is treated as a path. Otherwise, it is treated as a connector name.
5560
"""
5661
if not verify_docker_installation():
5762
click.echo(
5863
"Docker is not installed or not running. Please install Docker and try again.", err=True
5964
)
6065
sys.exit(1)
6166

62-
connector_name, connector_directory = resolve_connector_name_and_directory(
63-
connector_name=connector_name,
64-
connector_directory=connector_directory,
65-
)
67+
connector_name, connector_directory = resolve_connector_name_and_directory(connector)
6668

67-
click.echo(f"Building '{tag}' Image for Connector '{connector_name}':")
69+
metadata_file_path: Path = connector_directory / "metadata.yaml"
70+
try:
71+
metadata = MetadataFile.from_file(metadata_file_path)
72+
except (FileNotFoundError, ValueError) as e:
73+
click.echo(
74+
f"Error loading metadata file '{metadata_file_path}': {e!s}",
75+
err=True,
76+
)
77+
sys.exit(1)
78+
click.echo(f"Building Image for Connector: {metadata.data.dockerRepository}:{tag}")
6879
try:
6980
build_connector_image(
7081
connector_directory=connector_directory,
7182
connector_name=connector_name,
83+
metadata=metadata,
7284
tag=tag,
7385
no_verify=no_verify,
86+
dockerfile_override=dockerfile or None,
7487
)
7588
except ConnectorImageBuildError as e:
7689
click.echo(

0 commit comments

Comments
 (0)