diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2e8d740 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Semantic Release + +on: + push: + branches: [ master ] + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Python Semantic Release + uses: relekang/python-semantic-release@v7.2.1 + with: + pypi_token: ${{ secrets.PYPI_TOKEN }} + + pages: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: gh-pages + path: docs/build/html + - name: GitHub pages + - run: | + python -m pip install --upgrade pip + pip install sphinx sphinx-autobuild + sphinx-build -M html "docs" "docs/build" + git config user.name github-actions + git config user.email github-actions@github.com + cd docs/build/html + git add . + git commit -m "github pages" + git push \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5802f18 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: Run unit tests on every push + +on: push + +jobs: + test: + name: Python ${{ matrix.python-version }} tests + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [2.7, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache pip + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies (Python ${{ matrix.python-version }}) + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Run tests on Python ${{ matrix.python-version }} + env: + GITHUB_API_TOKENS: ${{ secrets.GH_API_TOKENS }} + run: make test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1829053..0000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -sudo: required -language: python -python: - - 2.7 - - 3.6 - -cache: - - pip - - packages - -install: - - make install - - pip install requests typing - -script: - - make test - -# jobs instead of deploy to deploy only once (for Python3 build) -jobs: - fast_finish: true - include: - - stage: upload to PYPI, build docs and create a release - # python-semantic-release fails with Travis Python3.5 - python: 3.6 - install: make install_dev - script: make html - - deploy: - - provider: script - skip_cleanup: true - on: - branch: master - script: make publish - - - provider: releases - skip-cleanup: true - api_key: $GH_TOKEN - on: - tags: true - file: dist/* - - - provider: pages - skip-cleanup: true - github-token: $GH_TOKEN - keep-history: true - on: - branch: master - local-dir: docs/build/html - -after_failure: - - pip freeze \ No newline at end of file diff --git a/README.md b/README.md index d16750d..95493d3 100644 --- a/README.md +++ b/README.md @@ -1,115 +1,2 @@ -# Python interface for code hosting platforms API -It is intended to facilitate research of Open Source projects. -At this point, it is basically functional but is missing: - -- tests -- documentation -- good architecture - -Feel free to contribute any of those. - -### Installation - -```bash -pip install --user --upgrade strudel.scraper -``` - - -### Usage - -```python -import stscraper as scraper -import pandas as pd - -gh_api = scraper.GitHubAPI() -# so far only GiHub, Bitbucket and Gitlab are supported -# bb_api = scraper.BitbucketAPI() -# gl_api = scraper.GitLabAPI() - -# repo_issues is a generator that can be used -# to instantiate a pandas dataframe -issues = pd.DataFrame(gh_api.repo_issues('cmustrudel/strudel.scraper')) -``` - - - -### Settings - -GitHub and GitLab APIs limit request rate for unauthenticated requests -(although GitLab limit is much more generous). -There are several ways to set your API keys, listed below in order of priority. - -**Important note:** API objects are reused in subsequent calls. -The same keys used to instantiate the first API object will be used by -ALL other instances. - -#### Class instantiation: - -```python -import stscraper - -gh_api = stscraper.GitHubAPI(tokens="comman-separated list of tokens") -``` - -#### At runtime: - -```python -import stscraper -import stutils - -# IMPORTANT: do this before creation of the first API object! -stutils.CONFIG['GITHUB_API_TOKENS'] = 'comma-separated list of tokens' -stutils.CONFIG['GITLAB_API_TOKENS'] = 'comma-separated list of tokens' - -# any api instance created after this, will use the provided tokens -gh_api = stscraper.GitHubAPI() -``` - -#### settings file: - -``` -project root - \ - |- my_module - | \- my_file.py - |- settings.py -``` - -```python -# settings.py - -GITHUB_API_TOKENS = 'comma-separated list of tokens' -GITLAB_API_TOKENS = 'comma-separated list of tokens' -``` - -```python -# my_file.py -import stscraper - -# keys from settings.py will be reused automatically -gh_api = stscraper.GitHubAPI() -``` - -#### Environment variable: - - -```bash -# somewhere in ~/.bashrc -export GITHUB_API_TOKENS='comma-separated list of tokens' -export GITLAB_API_TOKENS='comma-separated list of tokens' -``` - -```python -# somewhere in the code -import stscraper - -# keys from environment variables will be reused automatically -gh_api = stscraper.GitHubAPI() -``` - - -#### Hub config: - -If you have [hub](https://github.com/github/hub) installed and everything else -fails, its configuration will be reused for GitHub API. \ No newline at end of file +Please see https://cmustrudel.github.io/strudel.scraper/ for documentation. \ No newline at end of file diff --git a/stscraper/github.py b/stscraper/github.py index 233297b..ea70690 100644 --- a/stscraper/github.py +++ b/stscraper/github.py @@ -359,7 +359,7 @@ def v4(self, query, object_path=(), **params): get the first record, e.g. by calling `next()` on the result: >>> user_info = next(self.v4(''' - ... query ($user: String!) { + ... query ($user: String!) { ... user(login:$user) { ... login, name, avatarUrl, websiteUrl ... company, bio, location, name, twitterUsername, isHireable