Skip to content

Commit

Permalink
ci: migrate release automation unit test from travis to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
user2589 committed Jul 25, 2020
1 parent bc24d8d commit c3299f7
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 166 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 [email protected]
cd docs/build/html
git add .
git commit -m "github pages"
git push
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

115 changes: 1 addition & 114 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Please see https://cmustrudel.github.io/strudel.scraper/ for documentation.
2 changes: 1 addition & 1 deletion stscraper/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3299f7

Please sign in to comment.