|
| 1 | +# *How to access the token from Zenefits* |
| 2 | + |
| 3 | +Login into the Zenefits portal. <br> |
| 4 | +Follow the steps in the given link [Here](https://developers.zenefits.com/docs/sync-with-zenefits-button), This will generate and Bearer token for the user which can be used to interact with the API using the source-zenefits connector. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +# Zenefits Source |
| 9 | + |
| 10 | +This is the repository for the Zenefits source connector, written in Python. |
| 11 | +For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/zenefits). |
| 12 | + |
| 13 | +## Local development |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | +**To iterate on this connector, make sure to complete this prerequisites section.** |
| 17 | + |
| 18 | +#### Minimum Python version required `= 3.7.0` |
| 19 | + |
| 20 | +#### Build & Activate Virtual Environment and install dependencies |
| 21 | +From this connector directory, create a virtual environment: |
| 22 | +``` |
| 23 | +python -m venv .venv |
| 24 | +``` |
| 25 | + |
| 26 | +This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your |
| 27 | +development environment of choice. To activate it from the terminal, run: |
| 28 | +``` |
| 29 | +source .venv/bin/activate |
| 30 | +pip install -r requirements.txt |
| 31 | +pip install '.[tests]' |
| 32 | +``` |
| 33 | +If you are in an IDE, follow your IDE's instructions to activate the virtualenv. |
| 34 | + |
| 35 | +Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is |
| 36 | +used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`. |
| 37 | +If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything |
| 38 | +should work as you expect. |
| 39 | + |
| 40 | +#### Building via Gradle |
| 41 | +You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow. |
| 42 | + |
| 43 | +To build using Gradle, from the Airbyte repository root, run: |
| 44 | +``` |
| 45 | +./gradlew :airbyte-integrations:connectors:source-zenefits:build |
| 46 | +``` |
| 47 | + |
| 48 | +#### Create credentials |
| 49 | +**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/zenefits) |
| 50 | +to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_zenefits/spec.yaml` file. |
| 51 | +Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information. |
| 52 | +See `integration_tests/sample_config.json` for a sample config file. |
| 53 | + |
| 54 | +**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source zenefits test creds` |
| 55 | +and place them into `secrets/config.json`. |
| 56 | + |
| 57 | +### Locally running the connector |
| 58 | +``` |
| 59 | +python main.py spec |
| 60 | +python main.py check --config secrets/config.json |
| 61 | +python main.py discover --config secrets/config.json |
| 62 | +python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json |
| 63 | +``` |
| 64 | + |
| 65 | +### Locally running the connector docker image |
| 66 | + |
| 67 | +#### Build |
| 68 | +First, make sure you build the latest Docker image: |
| 69 | +``` |
| 70 | +docker build . -t airbyte/source-zenefits:dev |
| 71 | +``` |
| 72 | + |
| 73 | +You can also build the connector image via Gradle: |
| 74 | +``` |
| 75 | +./gradlew :airbyte-integrations:connectors:source-zenefits:airbyteDocker |
| 76 | +``` |
| 77 | +When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in |
| 78 | +the Dockerfile. |
| 79 | + |
| 80 | +#### Run |
| 81 | +Then run any of the connector commands as follows: |
| 82 | +``` |
| 83 | +docker run --rm airbyte/source-zenefits:dev spec |
| 84 | +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zenefits:dev check --config /secrets/config.json |
| 85 | +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zenefits:dev discover --config /secrets/config.json |
| 86 | +docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-zenefits:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json |
| 87 | +``` |
| 88 | +## Testing |
| 89 | +Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named. |
| 90 | +First install test dependencies into your virtual environment: |
| 91 | +``` |
| 92 | +pip install .[tests] |
| 93 | +``` |
| 94 | +### Unit Tests |
| 95 | +To run unit tests locally, from the connector directory run: |
| 96 | +``` |
| 97 | +python -m pytest unit_tests |
| 98 | +``` |
| 99 | + |
| 100 | +### Integration Tests |
| 101 | +There are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector). |
| 102 | +#### Custom Integration tests |
| 103 | +Place custom tests inside `integration_tests/` folder, then, from the connector root, run |
| 104 | +``` |
| 105 | +python -m pytest integration_tests |
| 106 | +``` |
| 107 | +#### Acceptance Tests |
| 108 | +Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information. |
| 109 | +If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py. |
| 110 | +To run your integration tests with acceptance tests, from the connector root, run |
| 111 | +``` |
| 112 | +python -m pytest integration_tests -p integration_tests.acceptance |
| 113 | +``` |
| 114 | +To run your integration tests with docker |
| 115 | + |
| 116 | +### Using gradle to run tests |
| 117 | +All commands should be run from airbyte project root. |
| 118 | +To run unit tests: |
| 119 | +``` |
| 120 | +./gradlew :airbyte-integrations:connectors:source-zenefits:unitTest |
| 121 | +``` |
| 122 | +To run acceptance and custom integration tests: |
| 123 | +``` |
| 124 | +./gradlew :airbyte-integrations:connectors:source-zenefits:integrationTest |
| 125 | +``` |
| 126 | + |
| 127 | +## Dependency Management |
| 128 | +All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development. |
| 129 | +We split dependencies between two groups, dependencies that are: |
| 130 | +* required for your connector to work need to go to `MAIN_REQUIREMENTS` list. |
| 131 | +* required for the testing need to go to `TEST_REQUIREMENTS` list |
| 132 | + |
| 133 | +### Publishing a new version of the connector |
| 134 | +You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what? |
| 135 | +1. Make sure your changes are passing unit and integration tests. |
| 136 | +1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)). |
| 137 | +1. Create a Pull Request. |
| 138 | +1. Pat yourself on the back for being an awesome contributor. |
| 139 | +1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master. |
0 commit comments