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

Add missing endpoints available in singer-io/tap-github #93

Merged
merged 50 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
214bbbf
Add assignees stream
Ry-DS Mar 10, 2022
d2e10df
Fix issues with assignee stream
Ry-DS Mar 10, 2022
08aa7e7
Add collaborators stream
Ry-DS Mar 10, 2022
231596b
Add review comments and reviews stream
Ry-DS Mar 10, 2022
4d967cf
Fix review comments stream and use repo parent instead
Ry-DS Mar 10, 2022
e3b01bd
Fix mypy issue
Ry-DS Mar 10, 2022
f2d7f53
Fix tests
Ry-DS Mar 12, 2022
7f17a65
add milestone and commit comment streams
Ry-DS Mar 12, 2022
313b742
Fix mypy
Ry-DS Mar 12, 2022
9ea76f5
Fix tests
Ry-DS Mar 13, 2022
2b66a73
commit wip todo streams
Ry-DS Mar 13, 2022
b27871d
fix formatting
Ry-DS Mar 13, 2022
ff14da1
[ci skip] format todo file and fix arraytype usage
Ry-DS Mar 13, 2022
f146c2a
[ci skip] more regex magic to convert everything to classes
Ry-DS Mar 13, 2022
89fb408
Add paths [ci skip]
Ry-DS Mar 13, 2022
d0352c7
Move all streams to main file
Ry-DS Mar 13, 2022
fc70b2a
Add replication keys
Ry-DS Mar 13, 2022
7730b86
fix tests (change type to datetime)
Ry-DS Mar 14, 2022
f68c260
introduce streams enum
Ry-DS Mar 17, 2022
3132b36
Fix up organization stream
Ry-DS Mar 17, 2022
cf7c467
Reverse order of testing versions
Ry-DS Mar 18, 2022
9258fd3
remove unsupported types from class
Ry-DS Mar 18, 2022
38e41a0
Fix format
Ry-DS Mar 18, 2022
c3d621e
Try use capital types to pass ci
Ry-DS Mar 18, 2022
549e399
Fix tap not including org streams on organization given
Ry-DS Mar 18, 2022
47dc14d
Add test for org stream
Ry-DS Mar 18, 2022
46257e1
Add rest of org streams
Ry-DS Mar 18, 2022
8f702cb
[ci skip] Temp changes for testing
Ry-DS Mar 18, 2022
1f5aad3
Fix parent context being missing
Ry-DS Mar 18, 2022
25c05c5
Set ignore parent replication to true for project
Ry-DS Mar 18, 2022
abf8407
fix mypy issue
Ry-DS Mar 18, 2022
53cca95
fix mistyped params
Ry-DS Mar 19, 2022
17192aa
Add parent keys
Ry-DS Mar 19, 2022
b423cd2
Fix mistyped params
Ry-DS Mar 19, 2022
b35d675
Fix mistyped ids in events
Ry-DS Mar 19, 2022
66f050c
[ci skip] Remove pointless comment
Ry-DS Mar 21, 2022
ac6b554
Change ignore parent key to true
Ry-DS Mar 22, 2022
6b6d934
update ignore_parent_replication and remove unneeded import
Ry-DS Mar 25, 2022
ef162de
Simple comment [ci skip]
Ry-DS Mar 25, 2022
47e42d9
Work on comments [ci skip]
Ry-DS Mar 25, 2022
91bbcd3
Work on comments [ci skip]
Ry-DS Mar 25, 2022
e6298e0
Fix mistyped stuff (good catch Laurent) and more comment addressing
Ry-DS Mar 25, 2022
643c99b
Update fixture comment [ci skip]
Ry-DS Mar 27, 2022
45a2981
Merge remote-tracking branch 'oviohub/83-missing-streams' into 83-mis…
Ry-DS Mar 27, 2022
3ff49ec
Add bunch of meltano lab sample projects
Ry-DS Mar 27, 2022
0b3f52f
update state partitioning keys
Ry-DS Mar 27, 2022
36801e5
Merge branch 'main' into 83-missing-streams
Ry-DS Mar 31, 2022
0ec1d16
Fix merge
Ry-DS Mar 31, 2022
36136ed
Add ORG_LEVEL_TOKEN to be used only for specific streams
ericboucher Apr 5, 2022
202845b
Add docstring to alternative_sync_chidren
ericboucher Apr 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test_tap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ORG_LEVEL_TOKEN: ${{secrets.ORG_LEVEL_TOKEN}}
strategy:
matrix:
python-version: ["3.10", 3.9, 3.8, 3.7]
ericboucher marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
16 changes: 13 additions & 3 deletions tap_github/tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Tests standard tap features using the built-in SDK tests library."""
import os
import logging

from unittest import mock

from singer_sdk.testing import get_standard_tap_tests

Expand Down Expand Up @@ -34,11 +38,17 @@ def test_standard_tap_tests_for_username_list_mode(username_list_config):
test()


# This token needs to have read:org access for the organization listed in fixtures.py
# Default is "MeltanoLabs"
ORG_LEVEL_TOKEN = os.environ.get("ORG_LEVEL_TOKEN")


@mock.patch.dict(os.environ, {"GITHUB_TOKEN": ORG_LEVEL_TOKEN or ""})
def test_standard_tap_tests_for_organization_list_mode(organization_list_config):
"""Run standard tap tests from the SDK."""
if not ORG_LEVEL_TOKEN:
logging.warning('No "ORG_LEVEL_TOKEN" found. Skipping organization tap tests.')
return
tests = get_standard_tap_tests(TapGitHub, config=organization_list_config)
for test in tests:
test()


# TODO: Create additional tests as appropriate for your tap.
32 changes: 30 additions & 2 deletions tap_github/tests/test_tap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os
import logging
import pytest

from unittest.mock import patch

from tap_github.tap import TapGitHub

from .fixtures import repo_list_config
Expand All @@ -22,6 +26,27 @@ def test_validate_repo_list_config(repo_list_config):
assert partitions == repo_list_context


def alternative_sync_chidren(self, child_context: dict) -> None:
ericboucher marked this conversation as resolved.
Show resolved Hide resolved
for child_stream in self.child_streams:
# Use org:write access level credentials for collaborators stream
if child_stream.name in ["collaborators"]:
ORG_LEVEL_TOKEN = os.environ.get("ORG_LEVEL_TOKEN")
if not ORG_LEVEL_TOKEN:
logging.warning(
'No "ORG_LEVEL_TOKEN" found. Skipping collaborators stream sync.'
)
continue
SAVED_GTHUB_TOKEN = os.environ.get("GITHUB_TOKEN")
os.environ["GITHUB_TOKEN"] = ORG_LEVEL_TOKEN
child_stream.sync(context=child_context)
os.environ["GITHUB_TOKEN"] = SAVED_GTHUB_TOKEN or ""
continue

# default behavior:
if child_stream.selected or child_stream.has_selected_descendents:
child_stream.sync(context=child_context)


@pytest.mark.repo_list(repo_list_2)
def test_get_a_repository_in_repo_list_mode(capsys, repo_list_config):
"""
Expand All @@ -38,8 +63,11 @@ def test_get_a_repository_in_repo_list_mode(capsys, repo_list_config):
# )
# discard previous output to stdout (potentially from other tests)
capsys.readouterr()
tap2 = TapGitHub(config=repo_list_config, catalog=catalog)
tap2.sync_all()
with patch(
"singer_sdk.streams.core.Stream._sync_children", alternative_sync_chidren
):
tap2 = TapGitHub(config=repo_list_config, catalog=catalog)
tap2.sync_all()
captured = capsys.readouterr()
# Verify we got the right number of records (one per repo in the list)
assert captured.out.count('{"type": "RECORD", "stream": "repositories"') == len(
Expand Down