Skip to content

Commit

Permalink
🎉 Source Tempo: migrate to the CDK
Browse files Browse the repository at this point in the history
* Source Tempo #7645 - migrate to the CDK

* Source Tempo #7645 - bump version and update changelog
  • Loading branch information
vitaliizazmic committed Nov 8, 2021
1 parent 3cbfb99 commit 88e2d2c
Show file tree
Hide file tree
Showing 20 changed files with 176 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sourceDefinitionId": "d1aa448b-7c54-498e-ad95-263cbebcd2db",
"name": "Tempo",
"dockerRepository": "airbyte/source-tempo",
"dockerImageTag": "0.2.3",
"dockerImageTag": "0.2.4",
"documentationUrl": "https://docs.airbyte.io/integrations/sources/tempo"
}
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
- name: Tempo
sourceDefinitionId: d1aa448b-7c54-498e-ad95-263cbebcd2db
dockerRepository: airbyte/source-tempo
dockerImageTag: 0.2.3
dockerImageTag: 0.2.4
documentationUrl: https://docs.airbyte.io/integrations/sources/tempo
sourceType: api
- name: TikTok Marketing
Expand Down
6 changes: 6 additions & 0 deletions airbyte-integrations/connectors/source-tempo/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!main.py
!source_tempo
!setup.py
!secrets
42 changes: 31 additions & 11 deletions airbyte-integrations/connectors/source-tempo/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_tempo"
ENV AIRBYTE_IMPL_MODULE="source_tempo"
ENV AIRBYTE_IMPL_PATH="SourceTempo"

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_tempo ./source_tempo

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.3
LABEL io.airbyte.version=0.2.4
LABEL io.airbyte.name=airbyte/source-tempo
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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-tempo:dev
tests:
spec:
- spec_path: "source_tempo/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"
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

14 changes: 1 addition & 13 deletions airbyte-integrations/connectors/source-tempo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-standard-source-test-file'
id 'airbyte-source-acceptance-test'
}

airbytePython {
moduleDirectory 'source_tempo'
}

airbyteStandardSourceTestFile {
specPath = "source_tempo/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-singer').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,40 @@
{
"streams": [
{
"stream": {
"name": "accounts",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "customers",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "workload-schemes",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "worklogs",
"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 @@
{
"api_token": "<invalid_api_token>"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"api_token": "<api_token>"
}
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_tempo import SourceTempo

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 .
18 changes: 16 additions & 2 deletions airbyte-integrations/connectors/source-tempo/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,26 @@

from setuptools import find_packages, setup

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

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

setup(
name="source_tempo",
description="Source implementation for Tempo.",
author="Thomas van Latum",
author_email="thomas@gcompany.nl",
packages=find_packages(),
install_requires=["airbyte-protocol", "base-python", "requests", "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 @@ -8,7 +8,7 @@
from typing import Mapping, Tuple

import requests
from base_python import BaseClient
from airbyte_cdk.sources.deprecated.client import BaseClient
from requests.exceptions import ConnectionError


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"readOnly": true
},
"id": {
"type": "string",
"type": "integer",
"description": "The ID of the tempo Workload Scheme.",
"readOnly": true
},
Expand All @@ -24,12 +24,12 @@
"readOnly": true
},
"defaultScheme": {
"type": "string",
"type": "boolean",
"description": "The defaultScheme of the tempo Workload Scheme.",
"readOnly": true
},
"memberCount": {
"type": "string",
"type": "integer",
"description": "The memberCount of the tempo Workload Scheme.",
"readOnly": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
"readOnly": true
},
"tempoWorklogId": {
"type": "string",
"type": "integer",
"description": "The ID of the tempo worklog.",
"readOnly": true
},
"jiraWorklogId": {
"type": "string",
"type": "integer",
"description": "The ID of the jira worklog.",
"readOnly": true
},
"issue": {
"type": "object",
"description": "Details of the issue",
"additionalProperties": {
"type": "string",
"type": ["string", "integer"],
"readOnly": true
},
"readOnly": true
},
"timeSpentSeconds": {
"type": "string",
"type": "integer",
"description": "Time spend in seconds of the worklog",
"readOnly": true
},
Expand Down Expand Up @@ -70,10 +70,11 @@
"type": "object",
"description": "Additional attribute of the worklog",
"readOnly": true,
"additionalProperties": {
"type": "string",
"readOnly": true
}
"additionalProperties": true
},
"billableSeconds": {
"type": ["null", "integer"],
"description": "Billable time spent working"
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#


from base_python import BaseSource
from airbyte_cdk.sources.deprecated.base_source import BaseSource

from .client import Client

Expand Down
6 changes: 6 additions & 0 deletions docs/integrations/sources/tempo.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ Source Tempo is designed to interact with the data your permissions give you acc

Go to **Tempo &gt; Settings**, scroll down to **Data Access** and select **API integration**.

## Changelog

| Version | Date | Pull Request | Subject |
| :------ | :-------- | :----- | :------ |
| 0.2.4 | 2021-11-08 | [7649](https://github.com/airbytehq/airbyte/pull/7649) | Migrate to the CDK |

0 comments on commit 88e2d2c

Please sign in to comment.