diff --git a/.github/ci/get_connector.py b/.github/ci/get_connector.py new file mode 100644 index 00000000..9b454dbb --- /dev/null +++ b/.github/ci/get_connector.py @@ -0,0 +1,25 @@ +def extract_connector_name(file_path): + connector_names = set() + with open(file_path, "r") as file: + for line in file: + line = line.strip() + if line.startswith("connectors/"): + parts = line.split("/") + if len(parts) > 1: + connector_names.add(parts[1]) + if len(connector_names) == 0: + raise ValueError("No connector name found in the file.") + elif len(connector_names) > 1: + raise ValueError("Multiple connector names found in the file.") + + return connector_names + + +# Example usage: +file_path = "changed_files.txt" +try: + connector_name = extract_connector_name(file_path) + print(f"::set-output name=connector::{next(iter(connector_name))}") +except Exception as e: + print(e) + print("::set-output name=connector::not-found") diff --git a/.github/workflows/run_integration_tests.yml b/.github/workflows/run_integration_tests.yml index 97404040..c2e85c87 100644 --- a/.github/workflows/run_integration_tests.yml +++ b/.github/workflows/run_integration_tests.yml @@ -32,7 +32,11 @@ jobs: - name: Get what connector we are testing id: get_connector - run: echo "::set-output name=connector::source_zendesk_support" + run: | + git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1 + git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }} > changed_files.txt + cat changed_files.txt + python .github/ci/get_connector.py - name: Run Integration Tests for Postgres working-directory: connectors/${{ steps.get_connector.outputs.connector }}/integration_tests diff --git a/changed_files.txt b/changed_files.txt new file mode 100644 index 00000000..2b768c84 --- /dev/null +++ b/changed_files.txt @@ -0,0 +1,3 @@ +.github/ci/get_connector.py +.github/workflows/run_integration_tests.yml +connectors/source_zendesk_support/models/fivetran_converter/ticket_field_history.sql \ No newline at end of file diff --git a/connectors/source_zendesk_support/models/fivetran_converter/ticket_field_history.sql b/connectors/source_zendesk_support/models/fivetran_converter/ticket_field_history.sql index 0ddb9e8d..8ff9b80e 100644 --- a/connectors/source_zendesk_support/models/fivetran_converter/ticket_field_history.sql +++ b/connectors/source_zendesk_support/models/fivetran_converter/ticket_field_history.sql @@ -6,7 +6,7 @@ f.value:field_name::STRING AS FIELD_NAME, f.value:value::STRING AS VALUE, t.author_id as AUTHOR_ID, - t.created_at as UPDATED_AT, + t.created_at as UPDATED FROM {{ source('source_zendesk_support', 'ticket_audits') }} t, LATERAL FLATTEN(input => t.events) f @@ -21,7 +21,7 @@ JSON_EXTRACT_SCALAR(f, '$.field_name') AS FIELD_NAME, JSON_EXTRACT_SCALAR(f, '$.value') AS VALUE, t.author_id AS AUTHOR_ID, - t.created_at AS UPDATED_AT + t.created_at AS UPDATED FROM {{ source('source_zendesk_support', 'ticket_audits') }} t, UNNEST(JSON_EXTRACT_ARRAY(t.events)) AS f @@ -33,11 +33,11 @@ WITH tmp AS ( SELECT - t.id AS TICKET_ID, - f.value->>'field_name' AS FIELD_NAME, - f.value->>'value' AS VALUE, - t.author_id AS AUTHOR_ID, - t.created_at AS UPDATED_AT + t.id AS ticket_id, + f.value->>'field_name' AS field_name, + f.value->>'value' AS value, + t.author_id AS author_id, + t.created_at AS updated FROM {{ source('source_zendesk_support', 'ticket_audits') }} t, LATERAL jsonb_array_elements(t.events::jsonb) AS f(value)