Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
AP-1039 revamp CI (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samira-El authored Aug 16, 2021
1 parent a26598c commit 3075604
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 119 deletions.
31 changes: 0 additions & 31 deletions .circleci/config.yml

This file was deleted.

File renamed without changes.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
pull_request:
push:
branches:
- master

jobs:
lint_and_test:
name: Linting and Testing
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6, 3.7, 3.8 ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Setup virtual environment
run: make venv

- name: Linting
run: make pylint

- name: Tests
run: make test
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
.DEFAULT_GOAL := test
venv:
python3 -m venv venv ;\
. ./venv/bin/activate ;\
pip install --upgrade pip setuptools wheel ;\
pip install -e .[test]

pylint:
. venv/bin/activate ;\
pylint tap_twilio --disable 'broad-except,chained-comparison,empty-docstring,fixme,invalid-name,line-too-long,missing-class-docstring,missing-function-docstring,missing-module-docstring,no-else-raise,no-else-return,too-few-public-methods,too-many-arguments,too-many-branches,too-many-lines,too-many-locals,ungrouped-imports'

test:
pylint tap_twilio --disable 'broad-except,chained-comparison,empty-docstring,fixme,invalid-name,line-too-long,missing-class-docstring,missing-function-docstring,missing-module-docstring,no-else-raise,no-else-return,too-few-public-methods,too-many-arguments,too-many-branches,too-many-lines,too-many-locals,ungrouped-imports,wrong-spelling-in-comment,wrong-spelling-in-docstring,bad-whitespace'
. venv/bin/activate ;\
pytest tests/unit
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,7 @@ To set up authentication simply include your Twilio `account_sid` and `auth_toke
1. Install

```bash
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install .
make venv
```

2. Create your tap's `config.json` file. The `api_key` is available in the twilio Console UI (see **Authentication** above). The `date_window_days` is the integer number of days (between the from and to dates) for date-windowing through the date-filtered endpoints (default = 30). The `start_date` is the absolute beginning date from which incremental loading on the initial load will start.
Expand Down Expand Up @@ -411,17 +408,19 @@ To set up authentication simply include your Twilio `account_sid` and `auth_toke
## To run tests
1. Install python test dependencies in a virtual env and run nose unit and integration tests
Install python test dependencies in a virtual env and run tests
```
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -e .[test]
make venv test
```
2. To run unit tests:
## To lint the code
Install python test dependencies in a virtual env and run linter
```
pytest tests/unit
make venv pylint
```
---
## Licence
GNU AFFERO GENERAL PUBLIC [LICENSE](./LICENSE)
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
],
py_modules=['tap_twilio'],
install_requires=[
'requests==2.25.1',
'requests==2.25.*',
'pipelinewise-singer-python==1.*'
],
extras_require={
'test': [
'pylint',
'pytest'
'pylint==2.9.*',
'pytest==6.2.*'
]
},
python_requires='>=3.6',
entry_points='''
[console_scripts]
tap-twilio=tap_twilio:main
Expand Down
21 changes: 10 additions & 11 deletions tap_twilio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def get_exception_for_status(status):
# "more_info": "http:\/\/www.twilio.com\/docs\/errors\/21201"
# }
def raise_for_error(response):
LOGGER.error('ERROR {}: {}, REASON: {}'.format(response.status_code,\
response.text, response.reason))
LOGGER.error('ERROR %s: %s, REASON: %s', response.status_code, response.text, response.reason)

try:
response.raise_for_status()
except (requests.HTTPError, requests.ConnectionError) as error:
Expand All @@ -76,16 +76,16 @@ def raise_for_error(response):
response = response.json()
if ('status' in response) and ('message' in response):
status = response.get('status')
message = response.get('messate')
message = response.get('message')
error_code = response.get('code', 'N/A')
more_info = response.get('more_info', 'N/A')
error_message = '{}: {}, error code: {}, more info: {}, ERROR: {}'.format(
status, message, error_code, more_info, error)
ex = get_exception_for_status(status)
raise ex(error_message)
raise TwilioError(error)
except (ValueError, TypeError):
raise TwilioError(error)
raise ex(error_message) from ex
raise TwilioError(error) from error
except (ValueError, TypeError) as ex:
raise TwilioError(ex) from ex


class TwilioClient:
Expand Down Expand Up @@ -117,7 +117,7 @@ def check_access(self):
if self.__account_sid is None or self.__auth_token is None:
raise Exception('Error: Missing account_sid or auth_token in config.json.')
if self.__account_sid is None:
raise Exception('Error: Missing account_sid in cofig.json.')
raise Exception('Error: Missing account_sid in config.json.')
headers = {}
# Endpoint: simple API call to return a single record (CompanyInformation) to test access
# https://developer.Twilio.com/default/documentation/Rest-Adv-v8#operations-Company_Information-GetCompanyInfo
Expand All @@ -132,11 +132,10 @@ def check_access(self):
# Basic Authentication
auth=(self.__account_sid, self.__auth_token))
if response.status_code != 200:
LOGGER.error('Error status_code = {}'.format(response.status_code))
LOGGER.error('Error status_code = %s', response.status_code)
raise_for_error(response)
else:
return True

return True

@backoff.on_exception(backoff.expo,
(Server5xxError, ConnectionError, Server429Error),
Expand Down
Loading

0 comments on commit 3075604

Please sign in to comment.