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

migrate greenhouse to config-based cdk #15344

Merged
merged 57 commits into from
Aug 12, 2022
Merged

Conversation

girarda
Copy link
Contributor

@girarda girarda commented Aug 5, 2022

What

Migrate the greenhouse connector to config-based

How

  • Replace custom source with a source inheriting from YamlDeclarativeSource
  • Define the connector config in airbyte-integrations/connectors/source-greenhouse/source_greenhouse/greenhouse.yaml
  • Set additionalProperties to true in the spec
  • Add a title to the spec's api_key field
  • Update acceptance tests to use valid credentials
  • Update unit tests

Recommended reading order

  1. airbyte-integrations/connectors/source-greenhouse/source_greenhouse/greenhouse.yaml
  2. airbyte-integrations/connectors/source-greenhouse/source_greenhouse/source.py
  3. airbyte-integrations/connectors/source-greenhouse/unit_tests/test_streams.py
  4. airbyte-integrations/connectors/source-greenhouse/source_greenhouse/spec.json
  5. airbyte-integrations/connectors/source-greenhouse/acceptance-test-config.yml

🚨 User Impact 🚨

Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834011930
❌ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834011930
🐛 https://gradle.com/s/rltwadbrsc4qi

Build Failed

Test summary info:

=========================== short test summary info ============================
FAILED test_core.py::TestSpec::test_additional_properties_is_true[inputs0] - ...
FAILED test_core.py::TestConnection::test_check[inputs0] - AssertionError: as...
FAILED test_core.py::TestConnection::test_check[inputs1] - AssertionError: as...
FAILED test_core.py::TestBasicRead::test_read[inputs0] - docker.errors.Contai...
FAILED test_full_refresh.py::TestFullRefresh::test_sequential_reads[inputs0]
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:60: Skipping TestIncremental.test_two_sequential_reads because not found in the config
=================== 5 failed, 32 passed, 1 skipped in 42.93s ===================

@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834134116
❌ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834134116
🐛 https://gradle.com/s/fluqdi7kp622w

Build Failed

Test summary info:

=========================== short test summary info ============================
FAILED test_core.py::TestSpec::test_backward_compatibility[inputs0] - IndexEr...
FAILED test_core.py::TestConnection::test_check[inputs1] - AssertionError: as...
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:60: Skipping TestIncremental.test_two_sequential_reads because not found in the config
============== 2 failed, 35 passed, 1 skipped in 88.76s (0:01:28) ==============

@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

1 similar comment
@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834357132
❌ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834357132
🐛 https://gradle.com/s/f2uinvt3cqevg

Build Failed

Test summary info:

=========================== short test summary info ============================
FAILED test_core.py::TestConnection::test_check[inputs1] - AssertionError: as...
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:60: Skipping TestIncremental.test_two_sequential_reads because not found in the config
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/tests/test_core.py:67: Backward compatibility tests are disabled for version 0.2.7.
============== 1 failed, 35 passed, 2 skipped in 87.45s (0:01:27) ==============

@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834495289
❌ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2834495289
🐛 https://gradle.com/s/pyvqgck7hhfh2

Build Failed

Test summary info:

=========================== short test summary info ============================
FAILED test_core.py::TestConnection::test_check[inputs1] - AssertionError: as...
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:60: Skipping TestIncremental.test_two_sequential_reads because not found in the config
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/tests/test_core.py:67: Backward compatibility tests are disabled for version 0.2.7.
============== 1 failed, 35 passed, 2 skipped in 88.49s (0:01:28) ==============

@girarda
Copy link
Contributor Author

girarda commented Aug 10, 2022

/test connector=connectors/source-greenhouse

connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "secrets/config_users_only.json"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these credentials don't work, but I confirmed there are users records in the account configured in "secrets/config.json"

assert records == []


def test_parse_response_invalid_content(applications_stream):
Copy link
Contributor Author

@girarda girarda Aug 10, 2022

Choose a reason for hiding this comment

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

this is not currently handled by low-code, but I'm not sure that

  1. this ever happens
  2. Ignoring bad responses is always the right thing to do (probably not)

Copy link
Contributor

Choose a reason for hiding this comment

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

this test was created as part of the very first PR introducing this connector. So I"m not sure why it's here. Fine by me to remove.

@@ -4,10 +4,12 @@ connector_image: airbyte/source-greenhouse:dev
tests:
spec:
- spec_path: "source_greenhouse/spec.json"
backward_compatibility_tests_config:
disable_for_version: "0.2.7"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to disable this test because the spec is updated

"properties": {
"api_key": {
"title": "API Key",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the spec because the linter was complaining

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Aug 11, 2022
@girarda
Copy link
Contributor Author

girarda commented Aug 11, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2842835763
✅ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2842835763
Python tests coverage:

Name                            Stmts   Miss  Cover
---------------------------------------------------
source_greenhouse/source.py         4      0   100%
source_greenhouse/__init__.py       2      0   100%
---------------------------------------------------
TOTAL                               6      0   100%
	 Name                                                 Stmts   Miss  Cover   Missing
	 ----------------------------------------------------------------------------------
	 source_acceptance_test/base.py                          10      4    60%   15-18
	 source_acceptance_test/config.py                        83      6    93%   78-80, 84-86
	 source_acceptance_test/conftest.py                     164    164     0%   6-282
	 source_acceptance_test/plugin.py                        48     48     0%   6-104
	 source_acceptance_test/tests/test_core.py              329    111    66%   39, 50-58, 63-70, 74-75, 79-80, 164, 202-219, 228-236, 240-245, 251, 284-289, 327-334, 374-376, 379, 439-448, 477-478, 484, 487, 520-530, 543-568, 573-577
	 source_acceptance_test/tests/test_full_refresh.py       52      2    96%   34, 65
	 source_acceptance_test/tests/test_incremental.py       121     25    79%   21-23, 29-31, 36-43, 48-61, 208-214
	 source_acceptance_test/utils/asserts.py                 37      2    95%   57-58
	 source_acceptance_test/utils/common.py                  77     17    78%   15-16, 24-30, 47-54, 64, 67
	 source_acceptance_test/utils/compare.py                 62     23    63%   21-51, 68, 97-99
	 source_acceptance_test/utils/connector_runner.py       110     48    56%   23-26, 32, 36, 39-64, 67-69, 72-74, 77-79, 82-84, 87-89, 92-110, 144-146
	 source_acceptance_test/utils/json_schema_helper.py     105     13    88%   30-31, 38, 41, 65-68, 96, 120, 190-192
	 ----------------------------------------------------------------------------------
	 TOTAL                                                 1321    463    65%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:60: Skipping TestIncremental.test_two_sequential_reads because not found in the config
=================== 39 passed, 1 skipped in 88.97s (0:01:28) ===================

assert records == []


def test_parse_response_invalid_content(applications_stream):
Copy link
Contributor

Choose a reason for hiding this comment

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

this test was created as part of the very first PR introducing this connector. So I"m not sure why it's here. Fine by me to remove.

inject_into: "path"
url_base: "*ref(definitions.requester.url_base)"
applications_stream:
type: DeclarativeStream
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need type: DeclarativeStream? can't we use a default impl since this is probably the only type of stream we'll have for a while?

name: "demographics_answer_options"
primary_key: "id"
schema_loader:
$ref: "*ref(definitions.schema_loader)"
Copy link
Contributor

Choose a reason for hiding this comment

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

it's interesting how verbose / repititive this defintiion is for every stream. It would be really nice if we can DRY this by having a base stream extended by all of these e.g:

base_stream: 
  type: DeclarativeStream
  $options: 
    primary_key: "id"
    schema_loader: 
      $ref: "*ref(definitions.schema_loader)"
    retriever: 
      $ref: ""
       .....

and then each stream just configures the specific option they need

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes!
I DRYed them config


check:
type: CheckStream
stream_names: ["applications"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Greenhouse is a permissioned system, and the user may only have access to certain streams based on the scopes available to them: https://support.greenhouse.io/hc/en-us/articles/115000521723-Manage-Harvest-API-key-permissions

This check is no worse than the current one. But it would be interesting to think through what it would take to support this in the CDK. maybe it requires something like #14908

@girarda
Copy link
Contributor Author

girarda commented Aug 11, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2843223463
❌ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2843223463
🐛 https://gradle.com/s/v4lx6jp4k3f42

Build Failed

Test summary info:

	 =========================== short test summary info ============================
	 FAILED unit_tests/test_streams.py::test_next_page_token_has_next - AssertionE...
	 FAILED unit_tests/test_streams.py::test_next_page_token_has_not_next - assert...
	 FAILED unit_tests/test_streams.py::test_request_params_next_page_token_is_not_none
	 FAILED unit_tests/test_streams.py::test_request_params_next_page_token_is_none
	 �[31m================== �[31m�[1m4 failed�[0m, �[32m2 passed�[0m, �[33m372 warnings�[0m�[31m in 3.54s�[0m�[31m ===================�[0m

@girarda
Copy link
Contributor Author

girarda commented Aug 11, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2843296678
✅ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2843296678
Python tests coverage:

Name                            Stmts   Miss  Cover
---------------------------------------------------
source_greenhouse/source.py         4      0   100%
source_greenhouse/__init__.py       2      0   100%
---------------------------------------------------
TOTAL                               6      0   100%
	 Name                                                 Stmts   Miss  Cover   Missing
	 ----------------------------------------------------------------------------------
	 source_acceptance_test/base.py                          10      4    60%   15-18
	 source_acceptance_test/config.py                        83      6    93%   78-80, 84-86
	 source_acceptance_test/conftest.py                     164    164     0%   6-282
	 source_acceptance_test/plugin.py                        48     48     0%   6-104
	 source_acceptance_test/tests/test_core.py              329    111    66%   39, 50-58, 63-70, 74-75, 79-80, 164, 202-219, 228-236, 240-245, 251, 284-289, 327-334, 374-376, 379, 439-448, 477-478, 484, 487, 520-530, 543-568, 573-577
	 source_acceptance_test/tests/test_full_refresh.py       52      2    96%   34, 65
	 source_acceptance_test/tests/test_incremental.py       121     25    79%   21-23, 29-31, 36-43, 48-61, 208-214
	 source_acceptance_test/utils/asserts.py                 37      2    95%   57-58
	 source_acceptance_test/utils/common.py                  77     17    78%   15-16, 24-30, 47-54, 64, 67
	 source_acceptance_test/utils/compare.py                 62     23    63%   21-51, 68, 97-99
	 source_acceptance_test/utils/connector_runner.py       110     48    56%   23-26, 32, 36, 39-64, 67-69, 72-74, 77-79, 82-84, 87-89, 92-110, 144-146
	 source_acceptance_test/utils/json_schema_helper.py     105     13    88%   30-31, 38, 41, 65-68, 96, 120, 190-192
	 ----------------------------------------------------------------------------------
	 TOTAL                                                 1321    463    65%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:60: Skipping TestIncremental.test_two_sequential_reads because not found in the config
================== 39 passed, 1 skipped in 100.76s (0:01:40) ===================

@girarda
Copy link
Contributor Author

girarda commented Aug 11, 2022

/test connector=connectors/source-greenhouse

🕑 connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2843419553
✅ connectors/source-greenhouse https://github.com/airbytehq/airbyte/actions/runs/2843419553
Python tests coverage:

Name                            Stmts   Miss  Cover
---------------------------------------------------
source_greenhouse/source.py         4      0   100%
source_greenhouse/__init__.py       2      0   100%
---------------------------------------------------
TOTAL                               6      0   100%
	 Name                                                 Stmts   Miss  Cover   Missing
	 ----------------------------------------------------------------------------------
	 source_acceptance_test/base.py                          10      4    60%   15-18
	 source_acceptance_test/config.py                        83      6    93%   78-80, 84-86
	 source_acceptance_test/conftest.py                     164    164     0%   6-282
	 source_acceptance_test/plugin.py                        48     48     0%   6-104
	 source_acceptance_test/tests/test_core.py              329    111    66%   39, 50-58, 63-70, 74-75, 79-80, 164, 202-219, 228-236, 240-245, 251, 284-289, 327-334, 374-376, 379, 439-448, 477-478, 484, 487, 520-530, 543-568, 573-577
	 source_acceptance_test/tests/test_full_refresh.py       52      2    96%   34, 65
	 source_acceptance_test/tests/test_incremental.py       121     25    79%   21-23, 29-31, 36-43, 48-61, 208-214
	 source_acceptance_test/utils/asserts.py                 37      2    95%   57-58
	 source_acceptance_test/utils/common.py                  77     17    78%   15-16, 24-30, 47-54, 64, 67
	 source_acceptance_test/utils/compare.py                 62     23    63%   21-51, 68, 97-99
	 source_acceptance_test/utils/connector_runner.py       110     48    56%   23-26, 32, 36, 39-64, 67-69, 72-74, 77-79, 82-84, 87-89, 92-110, 144-146
	 source_acceptance_test/utils/json_schema_helper.py     105     13    88%   30-31, 38, 41, 65-68, 96, 120, 190-192
	 ----------------------------------------------------------------------------------
	 TOTAL                                                 1321    463    65%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/source_acceptance_test/plugin.py:60: Skipping TestIncremental.test_two_sequential_reads because not found in the config
=================== 39 passed, 1 skipped in 75.66s (0:01:15) ===================

@girarda girarda marked this pull request as ready for review August 11, 2022 23:20
@girarda
Copy link
Contributor Author

girarda commented Aug 12, 2022

/publish connector=connectors/source-greenhouse

🕑 Publishing the following connectors:
connectors/source-greenhouse
https://github.com/airbytehq/airbyte/actions/runs/2843933426


Connector Did it publish? Were definitions generated?
connectors/source-greenhouse

if you have connectors that successfully published but failed definition generation, follow step 4 here ▶️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/greenhouse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet