Skip to content

Commit

Permalink
Merge 6fb3215 into 7f87094
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnekaunisto committed Oct 12, 2020
2 parents 7f87094 + 6fb3215 commit 328df3b
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 3 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/python-package-integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

# For running integration tests and uploading coverage. Separate file to minimize quota usage.
name: Python package Integration Tests

on:
push:
paths:
- .github/workflows/**
- simple_youtube_api/**
- tests/**
- setup.py
branches: 'master'
pull_request:
branches: 'master'
paths:
- .github/workflows/**
- simple_youtube_api/**
- tests/**
- setup.py

jobs:
pre-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
os: [windows-latest, ubuntu-latest, macos-latest]

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

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install pycodestyle
pip install .[test]
- name: Lint with pycodestyle
run: |
# stop the build if there are Python syntax errors or undefined names
pycodestyle --max-line-length=127 --count --show-pep8 --show-source ./simple_youtube_api ./tests
- name: Run unit tests with pytest
run: |
pytest tests/unit_test/
integ-test:
runs-on: ubuntu-latest
needs: [pre-build]
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pycodestyle
pip install .[test]
- name: Create Credential Files
run: |
mkdir credentials
echo "${{ secrets.YOUTUBE_DEVELOPER_KEY }}" > "credentials/developer_key"
echo "${{ secrets.CHANNEL_CREDENTIALS }}" > "credentials/credentials.storage"
echo "${{ secrets.CLIENT_SECRET }}" > "credentials/client_secret.json"
- name: Run all tests
run: pytest tests/ --doctest-modules -v --cov simple_youtube_api --cov-report term-missing

- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls

54 changes: 54 additions & 0 deletions .github/workflows/python-package-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

# Only for running unit tests, doesn't use YouTube Quota so can be run more freely.
name: Python package Unit Tests

on:
push:
branches: '**'
pull_request:
branches: '**'

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
os: [windows-latest, ubuntu-latest, macos-latest]

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

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pycodestyle
pip install .[test]
- name: Lint with pycodestyle
run: |
# stop the build if there are Python syntax errors or undefined names
pycodestyle --max-line-length=127 --count --show-pep8 --show-source ./simple_youtube_api ./tests
- name: Run unit tests with pytest
run: |
pytest tests/unit_test/
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run_tests(self):
except ImportError:
raise ImportError(
"Running tests requires additional dependencies."
"\nPlease run (pip install moviepy[test])"
"\nPlease run (pip install simple-youtube-api[test])"
)

errno = pytest.main(self.pytest_args.split(" "))
Expand Down
2 changes: 1 addition & 1 deletion simple_youtube_api/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def require_youtube_auth(f, video, *a, **k):

@decorator.decorator
def require_channel_or_youtube_auth(f, video, *a, **k):
if video.youtube is not None or video.channel != None:
if video.youtube is not None or video.channel is not None:
return f(video, *a, **k)
else:
raise Exception(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_test/test_youtube_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_parse_video():
+ "video.json"
)

with open(data_path, "r") as f:
with open(data_path, "r", encoding="utf8") as f:
data = json.loads(f.read())

video = YouTubeVideo()
Expand Down

0 comments on commit 328df3b

Please sign in to comment.