Skip to content

Commit

Permalink
Troubleshoot Poetry Scripts (#4)
Browse files Browse the repository at this point in the history
* Add custom install script

* Update installer

* Change to pip install

* Remove poetry.lock

* Re-add poetry.lock

* Update poetry version to preview

* Use recommended install script

* Add install package step

* Update publish package script
  • Loading branch information
stkbailey authored Aug 14, 2021
1 parent 90c6760 commit bb4d393
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 30 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ jobs:
python-version: 3.8
- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.pypi_api_token }}

- name: Install Poetry
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
export PATH=$PATH:$HOME/.local/bin
poetry self update --preview
- name: Build and Publish Package
run: |
poetry build
poetry publish -u ${USERNAME} - p ${PASSWORD}
env:
USERNAME: "__token__"
PASSWORD: ${{ secrets.pypi_api_token }}
15 changes: 13 additions & 2 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: 3.8

# Use recommended install script: https://python-poetry.org/docs/
- name: Install Poetry
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
export PATH=$PATH:$HOME/.local/bin
poetry self update --preview
- name: Install Package
run: pip install . pytest
run: poetry install

- name: Test Package
run: pytest
run: |
poetry run pytest
188 changes: 180 additions & 8 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ authors = ["Stephen Bailey"]
license = "Apache 2.0"

[tool.poetry.dependencies]
python = "<3.9,>=3.6.1"
python = "<3.9,>=3.6.2"
requests = "^2.25.1"
singer-sdk = "^0.3.3"
black = "^21.7-beta.0"

[tool.poetry.dev-dependencies]
pytest = "^6.1.2"
Expand Down
6 changes: 4 additions & 2 deletions tap_clockify/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def http_headers(self) -> dict:
"""Return the http headers needed."""
headers = {
"Content-Type": "application/json",
"x-api-key": self.config["api_key"]
"x-api-key": self.config["api_key"],
}
if "user_agent" in self.config:
headers["User-Agent"] = self.config.get("user_agent")
Expand Down Expand Up @@ -56,6 +56,8 @@ def get_url_params(
params["page"] = next_page_token
if self.replication_key:
start_time = self.get_starting_timestamp(context)
start_time_fmt = start_time.strftime('%Y-%m-%dT%H:%M:%SZ') if start_time else None
start_time_fmt = (
start_time.strftime("%Y-%m-%dT%H:%M:%SZ") if start_time else None
)
params["start"] = start_time_fmt
return params
14 changes: 6 additions & 8 deletions tap_clockify/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ClientsStream(ClockifyStream):
class ProjectsStream(ClockifyStream):
name = "projects"
primary_keys = ["id"]
path = "/projects"
path = "/projects"
schema_filepath = SCHEMAS_DIR / "projects.json"

def get_records(self, context: Optional[dict]):
Expand All @@ -34,11 +34,10 @@ def get_records(self, context: Optional[dict]):
class TagsStream(ClockifyStream):
name = "tags"
primary_keys = ["id"]
path = "/tags"
path = "/tags"
schema_filepath = SCHEMAS_DIR / "tags.json"



class UsersStream(ClockifyStream):
name = "users"
primary_keys = ["id"]
Expand All @@ -56,7 +55,7 @@ def get_records(self, context: Optional[dict]):
class TasksStream(ClockifyStream):
name = "tasks"
primary_keys = ["id"]
path = "/projects/{project_id}/tasks"
path = "/projects/{project_id}/tasks"
parent_stream_type = ProjectsStream
ignore_parent_replication_key = True
schema_filepath = SCHEMAS_DIR / "tasks.json"
Expand All @@ -65,7 +64,7 @@ class TasksStream(ClockifyStream):
class TimeEntriesStream(ClockifyStream):
name = "time_entries"
primary_keys = ["id"]
path = "/user/{user_id}/time-entries"
path = "/user/{user_id}/time-entries"
parent_stream_type = UsersStream
replication_key = "started_at"
ignore_parent_replication_key = True
Expand All @@ -79,10 +78,9 @@ def post_process(self, row: dict, context: Optional[dict]) -> dict:
class WorkspacesStream(ClockifyStream):
name = "workspaces"
primary_keys = ["id"]
path = "/workspaces"
path = "/workspaces"
schema_filepath = SCHEMAS_DIR / "workspaces.json"

@property
def url_base(self):
return f'https://api.clockify.me/api/v1'

return f"https://api.clockify.me/api/v1"
5 changes: 3 additions & 2 deletions tap_clockify/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
TasksStream,
TimeEntriesStream,
UsersStream,
WorkspacesStream
WorkspacesStream,
)

STREAM_TYPES = [
Expand All @@ -22,12 +22,13 @@
TasksStream,
TimeEntriesStream,
UsersStream,
WorkspacesStream
WorkspacesStream,
]


class TapClockify(Tap):
"""Clockify tap class."""

name = "tap-clockify"

config_jsonschema = th.PropertiesList(
Expand Down
9 changes: 4 additions & 5 deletions tap_clockify/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from tap_clockify.tap import TapClockify

SAMPLE_CONFIG = {
"start_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"start_date": datetime.datetime.now(datetime.timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%SZ"
),
"api_key": os.environ["TAP_CLOCKIFY_API_KEY"],
"workspace": os.environ["TAP_CLOCKIFY_WORKSPACE"],
}
Expand All @@ -17,9 +19,6 @@
# Run standard built-in tap tests from the SDK:
def test_standard_tap_tests():
"""Run standard tap tests from the SDK."""
tests = get_standard_tap_tests(
TapClockify,
config=SAMPLE_CONFIG
)
tests = get_standard_tap_tests(TapClockify, config=SAMPLE_CONFIG)
for test in tests:
test()

0 comments on commit bb4d393

Please sign in to comment.