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