Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
3de3edf
add skeleton implementation, imported from airbyte-pytest
aaronsteers Feb 10, 2025
3b88490
tidy imports
aaronsteers Feb 11, 2025
1250472
fix some imports
aaronsteers Feb 15, 2025
9dec6e3
Merge branch 'main' into aj/feat/mini-cat-test-suites
aaronsteers Feb 19, 2025
11d89f6
working test of tests
aaronsteers Feb 20, 2025
42d8a4e
remove old file
aaronsteers Feb 24, 2025
c8e7722
misc fixes
aaronsteers Feb 24, 2025
6248994
allow subclasses of abstractsource
aaronsteers Feb 24, 2025
a0f8ed5
Merge remote-tracking branch 'origin/main' into aj/feat/mini-cat-test…
aaronsteers Apr 7, 2025
fcfe697
fix test handling for expected errors
aaronsteers Apr 7, 2025
03f3360
Auto-fix lint and format issues
Apr 7, 2025
460c40a
remove unused code
aaronsteers Apr 7, 2025
8918bfe
fix tests
aaronsteers Apr 8, 2025
83344f3
use pep440 style dynamic versioning
aaronsteers Apr 9, 2025
76a92a9
update ci job (temporarily run on all pushes)
aaronsteers Apr 9, 2025
e6911e5
Merge remote-tracking branch 'origin/main' into aj/feat/mini-cat-test…
aaronsteers Apr 10, 2025
039eef0
Merge remote-tracking branch 'origin/main' into aj/feat/mini-cat-test…
aaronsteers Apr 10, 2025
5658441
Update .github/workflows/pypi_publish.yml
aaronsteers Apr 10, 2025
310ea68
fix fixture resource paths
aaronsteers Apr 10, 2025
1e74eef
lint fixes
aaronsteers Apr 10, 2025
c9ad3bd
fix imports
aaronsteers Apr 10, 2025
f8b581e
fix lint issues
aaronsteers Apr 12, 2025
4a05f46
fix lint and typing
aaronsteers Apr 12, 2025
e58dfad
[cherry-pick-me][chore]: resolve pytest warnings undeclared marks, an…
aaronsteers Apr 12, 2025
418dcb9
fix relative path logic
aaronsteers Apr 12, 2025
8d75d0d
ruff fix
aaronsteers Apr 12, 2025
c3a32ae
[cherry-pick-me][fix]: dataclasses constructor break with __test__ me…
aaronsteers Apr 12, 2025
0897b83
fix paths
aaronsteers Apr 12, 2025
b282e5d
[cherry-pick-me]: use kw args
aaronsteers Apr 12, 2025
9a8b5eb
Merge branch 'main' into aj/feat/mini-cat-test-suites
aaronsteers Apr 12, 2025
d5aaf3c
[cherry-pick-me]: kw args
aaronsteers Apr 12, 2025
7a00ff4
[cherry-pick-me]: use kw args for Test* dataclasses
aaronsteers Apr 12, 2025
5dff39e
Merge remote-tracking branch 'origin/main' into aj/feat/mini-cat-test…
aaronsteers Apr 12, 2025
3160691
fix relative resource paths
aaronsteers Apr 12, 2025
015ced9
fix imports
aaronsteers Apr 12, 2025
e2a9fb9
fix more tests
aaronsteers Apr 12, 2025
bfc1943
format fix
aaronsteers Apr 12, 2025
f82b76a
[cherry-pick-me][chore]: resolve pytest warnings undeclared marks, an…
aaronsteers Apr 12, 2025
f091b53
[cherry-pick-me][fix]: dataclasses constructor break with __test__ me…
aaronsteers Apr 12, 2025
12afc3d
[cherry-pick-me]: use kw args
aaronsteers Apr 12, 2025
cca55f7
[cherry-pick-me]: kw args
aaronsteers Apr 12, 2025
4f7a84e
[cherry-pick-me]: use kw args for Test* dataclasses
aaronsteers Apr 12, 2025
e24594b
Merge branch 'devin/1744436819-cherry-pick-test-fixes' into aj/feat/m…
aaronsteers Apr 12, 2025
9389cc5
reduce code needed for inheritance
aaronsteers Apr 12, 2025
e4cae20
fix type hint
aaronsteers Apr 12, 2025
18ff2e8
Use ClassVar[bool] for __test__ instead of kw_only=True
devin-ai-integration[bot] Apr 12, 2025
40fddcc
Use ClassVar[bool] for __test__ attributes instead of kw_only=True
devin-ai-integration[bot] Apr 12, 2025
e2c69df
Update more classes to use ClassVar[bool] for __test__ attributes
devin-ai-integration[bot] Apr 12, 2025
e79e901
Apply ruff formatting
devin-ai-integration[bot] Apr 12, 2025
c26345e
Fix remaining files with ruff formatting
devin-ai-integration[bot] Apr 12, 2025
eb0f643
addl cleanup
aaronsteers Apr 12, 2025
7a750d6
Merge branch 'devin/1744436819-cherry-pick-test-fixes' into aj/feat/m…
aaronsteers Apr 13, 2025
b8407e5
Merge branch 'main' into devin/1744436819-cherry-pick-test-fixes
aaronsteers Apr 14, 2025
88acba3
Merge branch 'main' into aj/feat/mini-cat-test-suites
aaronsteers Apr 14, 2025
4b6c53e
poe lock
aaronsteers Apr 14, 2025
f0bea0c
remove unrelated changes
aaronsteers Apr 14, 2025
8c91964
Merge branch 'devin/1744436819-cherry-pick-test-fixes' into aj/feat/m…
aaronsteers Apr 14, 2025
4f84c14
revert unnecessary changes
aaronsteers Apr 14, 2025
d0aba9f
Merge branch 'devin/1744436819-cherry-pick-test-fixes' into aj/feat/m…
aaronsteers Apr 14, 2025
1468a48
clean up naming, remove unused
aaronsteers Apr 14, 2025
2812e7d
tidy up pr
aaronsteers Apr 14, 2025
c4e6655
clean up IConnector interface
aaronsteers Apr 14, 2025
f6d6ccd
ruff fix
aaronsteers Apr 14, 2025
d20d91f
poe lock
aaronsteers Apr 14, 2025
b363b52
Merge branch 'main' into aj/feat/mini-cat-test-suites
aaronsteers Apr 15, 2025
b045532
clean up test module structure and pytest hooks
aaronsteers Apr 15, 2025
dc95a71
remove extra pytest files
aaronsteers Apr 15, 2025
a36d6a9
add usage docs
aaronsteers Apr 15, 2025
da442a9
clean up
aaronsteers Apr 15, 2025
623df9c
new cli
aaronsteers Apr 16, 2025
dd1f040
add airbyte-cdk cli scaffold
aaronsteers Apr 17, 2025
0209c1e
add comment
aaronsteers Apr 17, 2025
38c7166
add helper functions: find_connector_root(), find_connector_root_from…
aaronsteers Apr 17, 2025
c371030
misc fixes (working now)
aaronsteers Apr 18, 2025
8892914
delete unused devtools.py file
aaronsteers Apr 18, 2025
de07f9d
clean up cli module structure
aaronsteers Apr 18, 2025
a330cb7
update cli entrypoint
aaronsteers Apr 18, 2025
14b1385
add image command stub
aaronsteers Apr 18, 2025
1b45851
add --version support
aaronsteers Apr 18, 2025
67e4aca
Merge remote-tracking branch 'origin/main' into aj/feat/add-standard-…
aaronsteers Apr 18, 2025
79b11dc
ruff format
aaronsteers Apr 18, 2025
aec8602
chore: `poetry add rich` (transitive dependency)
aaronsteers Apr 18, 2025
ea848b0
remove click declaration (replaced by rich-click)
aaronsteers Apr 18, 2025
4fc4932
typing fixes
aaronsteers Apr 18, 2025
0cc217e
fix deptry issues
aaronsteers Apr 18, 2025
c4f9eee
pull in refactoring from downstream pr
aaronsteers Apr 18, 2025
5f025ba
add manifest help text
aaronsteers Apr 18, 2025
6fdf2c6
feat: add secrets fetch command to CDK CLI (#494)
devin-ai-integration[bot] Apr 18, 2025
db52db6
apply suggestion (owner-only read/write)
aaronsteers Apr 18, 2025
4d524b6
ensure we print the absolute path so secrets don't get lost
aaronsteers Apr 18, 2025
72514ac
allow imports outside of cwd
aaronsteers Apr 19, 2025
8cdf876
remove stale files from other PR
aaronsteers Apr 19, 2025
032d5e7
remove stale declarative module
aaronsteers Apr 19, 2025
7de9ab7
fix imports and such
aaronsteers Apr 19, 2025
a28e63b
tidy up cli help text declarations
aaronsteers Apr 19, 2025
1b47886
Merge branch 'main' into aj/feat/add-standard-tests-cli
aaronsteers Apr 19, 2025
e45e19b
Merge branch 'main' into aj/feat/add-standard-tests-cli
aaronsteers Apr 24, 2025
bf7ce53
Auto-commit Resolving dependencies... changes
Apr 24, 2025
e40f3a1
Merge branch 'main' into aj/feat/add-standard-tests-cli
aaronsteers Apr 24, 2025
4f383fc
chore: add optional 'dev' dependency
aaronsteers Apr 24, 2025
b012495
Auto-commit Resolving dependencies... changes
Apr 25, 2025
9ea97fa
Merge branch 'main' into aj/feat/add-standard-tests-cli
aaronsteers Apr 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ dist
.idea
.vscode
**/__pycache__
.tmp
86 changes: 86 additions & 0 deletions airbyte_cdk/cli/airbyte_cdk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
"""CLI commands for `airbyte-cdk`.

This CLI interface allows you to interact with your connector, including
testing and running commands.

**Basic Usage:**

```bash
airbyte-cdk --help
airbyte-cdk --version
airbyte-cdk connector --help
airbyte-cdk manifest --help
```

**Running Statelessly:**

You can run the latest version of this CLI, from any machine, using `pipx` or `uvx`:

```bash
# Run the latest version of the CLI:
pipx run airbyte-cdk connector --help
uvx airbyte-cdk connector --help

# Run from a specific CDK version:
pipx run airbyte-cdk==6.5.1 connector --help
uvx airbyte-cdk==6.5.1 connector --help
```

**Running within your virtualenv:**

You can also run from your connector's virtualenv:

```bash
poetry run airbyte-cdk connector --help
```

"""

from typing import cast

import rich_click as click

from airbyte_cdk.cli.airbyte_cdk._connector import connector_cli_group
from airbyte_cdk.cli.airbyte_cdk._image import image_cli_group
from airbyte_cdk.cli.airbyte_cdk._manifest import manifest_cli_group
from airbyte_cdk.cli.airbyte_cdk._secrets import secrets_cli_group
from airbyte_cdk.cli.airbyte_cdk._version import print_version


@click.group(
help=__doc__.replace("\n", "\n\n"), # Render docstring as help text (markdown)
invoke_without_command=True,
)
@click.option(
"--version",
is_flag=True,
help="Show the version of the Airbyte CDK.",
)
@click.pass_context
def cli(
ctx: click.Context,
version: bool,
) -> None:
"""Airbyte CDK CLI.

Help text is provided from the file-level docstring.
"""
if version:
print_version(short=False)
ctx.exit()

if ctx.invoked_subcommand is None:
# If no subcommand is provided, show the help message.
click.echo(ctx.get_help())
ctx.exit()


cli.add_command(connector_cli_group)
cli.add_command(manifest_cli_group)
cli.add_command(image_cli_group)
cli.add_command(secrets_cli_group)


if __name__ == "__main__":
cli()
179 changes: 179 additions & 0 deletions airbyte_cdk/cli/airbyte_cdk/_connector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
"""CLI command for `airbyte-cdk`."""

USAGE = """CLI command for `airbyte-cdk`.

This CLI interface allows you to interact with your connector, including
testing and running commands.

**Basic Usage:**

```bash
airbyte-cdk --help
airbyte-cdk connector --help
airbyte-cdk manifest --help
```

**Running Statelessly:**

You can run the latest version of this CLI, from any machine, using `pipx` or `uvx`:

```bash
# Run the latest version of the CLI:
pipx run airbyte-cdk connector --help
uvx airbyte-cdk connector --help

# Run from a specific CDK version:
pipx run airbyte-cdk==6.5.1 connector --help
uvx airbyte-cdk==6.5.1 connector --help
```

**Running within your virtualenv:**

You can also run from your connector's virtualenv:

```bash
poetry run airbyte-cdk connector --help
```

"""

import os
from pathlib import Path
from types import ModuleType

import rich_click as click

# from airbyte_cdk.test.standard_tests import pytest_hooks
from airbyte_cdk.cli.airbyte_cdk._util import resolve_connector_name_and_directory
from airbyte_cdk.test.standard_tests.test_resources import find_connector_root_from_name
from airbyte_cdk.test.standard_tests.util import create_connector_test_suite

click.rich_click.TEXT_MARKUP = "markdown"

pytest: ModuleType | None
try:
import pytest
except ImportError:
pytest = None
# Handle the case where pytest is not installed.
# This prevents import errors when running the script without pytest installed.
# We will raise an error later if pytest is required for a given command.


TEST_FILE_TEMPLATE = '''
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
"""FAST Airbyte Standard Tests for the source_pokeapi_w_components source."""

#from airbyte_cdk.test.standard_tests import {base_class_name}
from airbyte_cdk.test.standard_tests.util import create_connector_test_suite
from pathlib import Path

pytest_plugins = [
"airbyte_cdk.test.standard_tests.pytest_hooks",
]

TestSuite = create_connector_test_suite(
connector_directory=Path(),
)

# class TestSuite({base_class_name}):
# """Test suite for the source_pokeapi_w_components source.

# This class inherits from SourceTestSuiteBase and implements all of the tests in the suite.

# As long as the class name starts with "Test", pytest will automatically discover and run the
# tests in this class.
# """
'''


@click.group(
name="connector",
help=__doc__.replace("\n", "\n\n"), # Render docstring as help text (markdown)
)
def connector_cli_group() -> None:
"""Connector related commands."""
pass


@connector_cli_group.command()
@click.option(
"--connector-name",
type=str,
help="Name of the connector to test. Ignored if --connector-directory is provided.",
)
@click.option(
"--connector-directory",
type=click.Path(exists=True, file_okay=False, path_type=Path),
help="Path to the connector directory.",
)
@click.option(
"--collect-only",
is_flag=True,
default=False,
help="Only collect tests, do not run them.",
)
def test(
connector_name: str | None = None,
connector_directory: Path | None = None,
*,
collect_only: bool = False,
) -> None:
"""Run connector tests.

This command runs the standard connector tests for a specific connector.

If no connector name or directory is provided, we will look within the current working
directory. If the current working directory is not a connector directory (e.g. starting
with 'source-') and no connector name or path is provided, the process will fail.
"""
if pytest is None:
raise ImportError(
"pytest is not installed. Please install pytest to run the connector tests."
)
click.echo("Connector test command executed.")
connector_name, connector_directory = resolve_connector_name_and_directory(
connector_name=connector_name,
connector_directory=connector_directory,
)

connector_test_suite = create_connector_test_suite(
connector_name=connector_name if not connector_directory else None,
connector_directory=connector_directory,
)

pytest_args: list[str] = []
if connector_directory:
pytest_args.append(f"--rootdir={connector_directory}")
os.chdir(str(connector_directory))
else:
print("No connector directory provided. Running tests in the current directory.")

file_text = TEST_FILE_TEMPLATE.format(
base_class_name=connector_test_suite.__bases__[0].__name__,
connector_directory=str(connector_directory),
)
test_file_path = Path() / ".tmp" / "integration_tests/test_airbyte_standards.py"
test_file_path = test_file_path.resolve().absolute()
test_file_path.parent.mkdir(parents=True, exist_ok=True)
test_file_path.write_text(file_text)

if collect_only:
pytest_args.append("--collect-only")

pytest_args.append(str(test_file_path))
click.echo(f"Running tests from connector directory: {connector_directory}...")
click.echo(f"Test file: {test_file_path}")
click.echo(f"Collect only: {collect_only}")
click.echo(f"Pytest args: {pytest_args}")
click.echo("Invoking Pytest...")
pytest.main(
pytest_args,
plugins=[],
)


__all__ = [
"connector_cli_group",
]
24 changes: 24 additions & 0 deletions airbyte_cdk/cli/airbyte_cdk/_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
"""Docker image commands.

Coming soon.

This module is planned to provide a command line interface (CLI) for building
Docker images for Airbyte CDK connectors.
"""

import click


@click.group(
name="image",
help=__doc__.replace("\n", "\n\n"), # Render docstring as help text (markdown)
)
def image_cli_group() -> None:
"""Docker image commands."""
pass


__all__ = [
"image_cli_group",
]
24 changes: 24 additions & 0 deletions airbyte_cdk/cli/airbyte_cdk/_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
"""Manifest related commands.

Coming soon.

This module is planned to provide a command line interface (CLI) for validating
Airbyte CDK manifests.
"""

import rich_click as click


@click.group(
name="manifest",
help=__doc__.replace("\n", "\n\n"), # Render docstring as help text (markdown)
)
def manifest_cli_group() -> None:
"""Manifest related commands."""
pass


__all__ = [
"manifest_cli_group",
]
Loading
Loading