Skip to content
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

🎉 Source Drift: migrate to the CDK #7247

Merged
merged 4 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
6 changes: 6 additions & 0 deletions airbyte-integrations/connectors/source-drift/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!main.py
!source_drift
!setup.py
!secrets
40 changes: 30 additions & 10 deletions airbyte-integrations/connectors/source-drift/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
FROM airbyte/integration-base-python:0.1.1
FROM python:3.7.11-alpine3.14 as base

# Bash is installed for more convenient debugging.
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*
# build and load all requirements
FROM base as builder
WORKDIR /airbyte/integration_code

# upgrade pip to the latest version
RUN apk --no-cache upgrade \
&& pip install --upgrade pip \
&& apk --no-cache add tzdata build-base

ENV CODE_PATH="source_drift"
ENV AIRBYTE_IMPL_MODULE="source_drift"
ENV AIRBYTE_IMPL_PATH="SourceDrift"

WORKDIR /airbyte/integration_code
COPY $CODE_PATH ./$CODE_PATH
COPY setup.py ./
RUN pip install .
# install necessary packages to a temporary folder
RUN pip install --prefix=/install .

# build a clean environment
FROM base
WORKDIR /airbyte/integration_code

# copy all loaded and built libraries to a pure basic image
COPY --from=builder /install /usr/local
# add default timezone settings
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN echo "Etc/UTC" > /etc/timezone

# bash is installed for more convenient debugging.
RUN apk --no-cache add bash

# copy payload code only
COPY main.py ./
COPY source_drift ./source_drift

ENV AIRBYTE_ENTRYPOINT "/airbyte/base.sh"
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LABEL io.airbyte.version=0.2.2
LABEL io.airbyte.version=0.2.3

LABEL io.airbyte.name=airbyte/source-drift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-drift:dev
tests:
spec:
- spec_path: "source_drift/spec.json"
connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
- config_path: "secrets/config.json"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: ["accounts", ]
full_refresh:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

# Build latest connector image
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2)

# Pull latest acctest image
docker pull airbyte/source-acceptance-test:latest

# Run
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp \
-v $(pwd):/test_input \
airbyte/source-acceptance-test \
--acceptance-test-config /test_input

11 changes: 2 additions & 9 deletions airbyte-integrations/connectors/source-drift/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-standard-source-test-file'
id 'airbyte-source-acceptance-test'
}

airbytePython {
moduleDirectory 'source_drift'
}

airbyteStandardSourceTestFile {
specPath = "source_drift/spec.json"
configPath = "secrets/config.json"
configuredCatalogPath = "sample_files/configured_catalog.json"
}

dependencies {
implementation files(project(':airbyte-integrations:bases:base-standard-source-test-file').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:source-acceptance-test').airbyteDocker.outputs)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#


import pytest

pytest_plugins = ("source_acceptance_test.plugin",)


@pytest.fixture(scope="session", autouse=True)
def connector_setup():
""" This fixture is a placeholder for external resources that acceptance test might require."""
yield
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"streams": [
{
"name": "accounts",
"json_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"ownerId": {
"type": "integer"
},
"name": {
"type": "string"
},
"domain": {
"type": "string"
},
"accountId": {
"type": "string"
},
"customProperties": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"name": {
"type": "string"
},
"value": {},
"type": {
"type": "string"
}
}
}
},
"deleted": {
"type": "boolean"
},
"createDateTime": {
"type": "integer"
},
"updateDateTime": {
"type": "integer"
},
"targeted": {
"type": "boolean"
}
}
},
"supported_sync_modes": ["full_refresh"],
"source_defined_cursor": false
},
{
"name": "conversations",
"json_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"participants": {
"type": "array",
"items": {
"type": "integer"
}
},
"status": {
"type": "string",
"enum": ["open", "closed", "pending", "bulk_sent"]
},
"contactId": {
"type": "integer"
},
"inboxId": {
"type": "integer"
},
"createdAt": {
"type": "integer"
},
"updatedAt": {
"type": "integer"
},
"relatedPlaybookId": {
"type": ["null", "string"]
},
"conversationTags": {
"type": "array",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string",
"description": "HEX value"
},
"name": {
"type": "string"
}
}
}
}
}
},
"supported_sync_modes": ["full_refresh"],
"source_defined_cursor": false
},
{
"name": "users",
"json_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"orgId": {
"type": "integer"
},
"name": {
"type": "string"
},
"alias": {
"type": "string"
},
"email": {
"type": "string"
},
"phone": {
"type": "string"
},
"locale": {
"type": "string"
},
"availability": {
"type": "string"
},
"role": {
"type": "string"
},
"timeZone": {
"type": "string"
},
"avatarUrl": {
"type": "string"
},
"verified": {
"type": "boolean"
},
"bot": {
"type": "boolean"
},
"createdAt": {
"type": "integer"
},
"updatedAt": {
"type": "integer"
}
}
},
"supported_sync_modes": ["full_refresh"],
"source_defined_cursor": false
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"streams": [
{
"stream": {
"name": "accounts",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "conversations",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "users",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"access_token": "invalid_access_token"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"access_token": "1234567890abcdefghijk"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import sys

from base_python.entrypoint import launch
from airbyte_cdk.entrypoint import launch
from source_drift import SourceDrift

if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This file is autogenerated -- only edit if you know what you are doing. Use setup.py for declaring dependencies.
-e ../../bases/airbyte-protocol
-e ../../bases/base-python
-e ../../bases/source-acceptance-test
-e .
15 changes: 13 additions & 2 deletions airbyte-integrations/connectors/source-drift/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = ["airbyte-cdk~=0.1", "requests~=2.22"]

TEST_REQUIREMENTS = [
"pytest~=6.1",
"pytest-mock~=3.6.1",
"source-acceptance-test",
]

setup(
name="source_drift",
description="Source implementation for Drift.",
author="Airbyte",
author_email="contact@airbyte.io",
packages=find_packages(),
install_requires=["airbyte-protocol", "base-python", "requests~=2.22", "pytest==6.1.2"],
package_data={"": ["*.json", "schemas/*.json"]},
install_requires=MAIN_REQUIREMENTS,
package_data={"": ["*.json", "schemas/*.json", "schemas/shared/*.json"]},
extras_require={
"tests": TEST_REQUIREMENTS,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing import Iterator, Tuple

from base_python import BaseClient
from airbyte_cdk.sources.deprecated.client import BaseClient

from .api import APIClient
from .common import AuthError, ValidationError
Expand Down
Loading