Skip to content

Commit a288641

Browse files
authored
Source Lever Hiring: initial template blank (#5947)
1 parent 37943d2 commit a288641

24 files changed

+822
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!Dockerfile
3+
!main.py
4+
!source_lever_hiring
5+
!setup.py
6+
!secrets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM python:3.7.11-alpine3.14 as base
2+
3+
# build and load all requirements
4+
FROM base as builder
5+
WORKDIR /airbyte/integration_code
6+
7+
# upgrade pip to the latest version
8+
RUN apk --no-cache upgrade \
9+
&& pip install --upgrade pip \
10+
&& apk --no-cache add tzdata
11+
12+
13+
COPY setup.py ./
14+
# install necessary packages to a temporary folder
15+
RUN pip install --prefix=/install .
16+
17+
# build a clean environment
18+
FROM base
19+
WORKDIR /airbyte/integration_code
20+
21+
# copy all loaded and built libraries to a pure basic image
22+
COPY --from=builder /install /usr/local
23+
# add default timezone settings
24+
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
25+
RUN echo "Etc/UTC" > /etc/timezone
26+
27+
# bash is installed for more convenient debugging.
28+
RUN apk --no-cache add bash
29+
30+
# copy payload code only
31+
COPY main.py ./
32+
COPY source_lever_hiring ./source_lever_hiring
33+
34+
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
35+
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
36+
37+
LABEL io.airbyte.version=0.1.0
38+
LABEL io.airbyte.name=airbyte/source-lever-hiring
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Lever Hiring Source
2+
3+
This is the repository for the Lever Hiring 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/lever-hiring).
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+
```
25+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
26+
27+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
28+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
29+
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
30+
should work as you expect.
31+
32+
#### Building via Gradle
33+
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
34+
35+
To build using Gradle, from the Airbyte repository root, run:
36+
```
37+
./gradlew :airbyte-integrations:connectors:source-lever-hiring:build
38+
```
39+
40+
#### Create credentials
41+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/lever-hiring)
42+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_lever_hiring/spec.json` file.
43+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
44+
See `integration_tests/sample_config.json` for a sample config file.
45+
46+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source lever-hiring test creds`
47+
and place them into `secrets/config.json`.
48+
49+
### Locally running the connector
50+
```
51+
python main.py spec
52+
python main.py check --config secrets/config.json
53+
python main.py discover --config secrets/config.json
54+
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
55+
```
56+
57+
### Locally running the connector docker image
58+
59+
#### Build
60+
First, make sure you build the latest Docker image:
61+
```
62+
docker build . -t airbyte/source-lever-hiring:dev
63+
```
64+
65+
You can also build the connector image via Gradle:
66+
```
67+
./gradlew :airbyte-integrations:connectors:source-lever-hiring:airbyteDocker
68+
```
69+
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
70+
the Dockerfile.
71+
72+
#### Run
73+
Then run any of the connector commands as follows:
74+
```
75+
docker run --rm airbyte/source-lever-hiring:dev spec
76+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-lever-hiring:dev check --config /secrets/config.json
77+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-lever-hiring:dev discover --config /secrets/config.json
78+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-lever-hiring:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
79+
```
80+
## Testing
81+
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.
82+
First install test dependencies into your virtual environment:
83+
```
84+
pip install .[tests]
85+
```
86+
### Unit Tests
87+
To run unit tests locally, from the connector directory run:
88+
```
89+
python -m pytest unit_tests
90+
```
91+
92+
### Integration Tests
93+
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).
94+
#### Custom Integration tests
95+
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
96+
```
97+
python -m pytest integration_tests
98+
```
99+
#### Acceptance Tests
100+
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.
101+
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.
102+
To run your integration tests with acceptance tests, from the connector root, run
103+
```
104+
python -m pytest integration_tests -p integration_tests.acceptance
105+
```
106+
To run your integration tests with docker
107+
108+
### Using gradle to run tests
109+
All commands should be run from airbyte project root.
110+
To run unit tests:
111+
```
112+
./gradlew :airbyte-integrations:connectors:source-lever-hiring:unitTest
113+
```
114+
To run acceptance and custom integration tests:
115+
```
116+
./gradlew :airbyte-integrations:connectors:source-lever-hiring:integrationTest
117+
```
118+
119+
## Dependency Management
120+
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.
121+
We split dependencies between two groups, dependencies that are:
122+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
123+
* required for the testing need to go to `TEST_REQUIREMENTS` list
124+
125+
### Publishing a new version of the connector
126+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
127+
1. Make sure your changes are passing unit and integration tests.
128+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
129+
1. Create a Pull Request.
130+
1. Pat yourself on the back for being an awesome contributor.
131+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
2+
# for more information about how to configure these tests
3+
connector_image: airbyte/source-lever-hiring:dev
4+
tests:
5+
spec:
6+
- spec_path: "source_lever_hiring/spec.json"
7+
connection:
8+
- config_path: "secrets/config.json"
9+
status: "succeed"
10+
- config_path: "integration_tests/invalid_config.json"
11+
status: "failed"
12+
discovery:
13+
- config_path: "secrets/config.json"
14+
basic_read:
15+
- config_path: "secrets/config.json"
16+
configured_catalog_path: "integration_tests/configured_catalog.json"
17+
empty_streams: []
18+
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
19+
# expect_records:
20+
# path: "integration_tests/expected_records.txt"
21+
# extra_fields: no
22+
# exact_order: no
23+
# extra_records: yes
24+
incremental: # TODO if your connector does not implement incremental sync, remove this block
25+
- config_path: "secrets/config.json"
26+
configured_catalog_path: "integration_tests/configured_catalog.json"
27+
future_state_path: "integration_tests/abnormal_state.json"
28+
full_refresh:
29+
- config_path: "secrets/config.json"
30+
configured_catalog_path: "integration_tests/configured_catalog.json"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# Build latest connector image
4+
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2)
5+
6+
# Pull latest acctest image
7+
docker pull airbyte/source-acceptance-test:latest
8+
9+
# Run
10+
docker run --rm -it \
11+
-v /var/run/docker.sock:/var/run/docker.sock \
12+
-v /tmp:/tmp \
13+
-v $(pwd):/test_input \
14+
airbyte/source-acceptance-test \
15+
--acceptance-test-config /test_input
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
id 'airbyte-python'
3+
id 'airbyte-docker'
4+
id 'airbyte-source-acceptance-test'
5+
}
6+
7+
airbytePython {
8+
moduleDirectory 'source_lever_hiring'
9+
}
10+
11+
dependencies {
12+
implementation files(project(':airbyte-integrations:bases:source-acceptance-test').airbyteDocker.outputs)
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# MIT License
3+
#
4+
# Copyright (c) 2020 Airbyte
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
#
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"todo-stream-name": {
3+
"todo-field-name": "todo-abnormal-value"
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# MIT License
3+
#
4+
# Copyright (c) 2020 Airbyte
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
#
24+
25+
26+
import pytest
27+
28+
pytest_plugins = ("source_acceptance_test.plugin",)
29+
30+
31+
@pytest.fixture(scope="session", autouse=True)
32+
def connector_setup():
33+
""" This fixture is a placeholder for external resources that acceptance test might require."""
34+
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
35+
yield
36+
# TODO: clean up test dependencies
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"streams": []
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"todo-wrong-field": "this should be an incomplete config file, used in standard tests"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"fix-me": "TODO"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"todo-stream-name": {
3+
"todo-field-name": "value"
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# MIT License
3+
#
4+
# Copyright (c) 2020 Airbyte
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
#
24+
25+
26+
import sys
27+
28+
from airbyte_cdk.entrypoint import launch
29+
from source_lever_hiring import SourceLeverHiring
30+
31+
if __name__ == "__main__":
32+
source = SourceLeverHiring()
33+
launch(source, sys.argv[1:])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-e ../../bases/source-acceptance-test
2+
-e .

0 commit comments

Comments
 (0)