Skip to content

Commit

Permalink
Initial switch to Github CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowmoose committed Sep 6, 2019
1 parent fdb62a4 commit 3a1dc4f
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 43 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pytest.yml
@@ -0,0 +1,46 @@
name: Pytest

on:
push:
schedule:
- cron: '0 8 * * *'

jobs:
run-tests:
name: ${{ matrix.os }}, ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
strategy:
max-parallel: 9
matrix:
os: [ubuntu, windows, macOS]
python-version: [3.5, 3.6, 3.7]

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

- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest-cov
pip install flake8
pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest --cov=./ --cov-report=xml --verbose redditdownloader/tests/
- name: Upload coverage to Codecov
run: |
pip install codecov
codecov -t ${{secrets.CODECOV_TOKEN}} --name "${{ matrix.os }}, ${{ matrix.python-version }}"
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

15 changes: 3 additions & 12 deletions Dockerfile
@@ -1,18 +1,9 @@
FROM python:3.7-slim

WORKDIR ./rmd/

ADD redditdownloader/classes ./classes
ADD redditdownloader/tests ./tests
ADD redditdownloader/web ./web
ADD docs ./docs
ADD main.py ./
ADD requirements.txt ./


ADD redditdownloader ./redditdownloader

RUN mkdir ./settings/

RUN pip install -r ./requirements.txt
RUN pip install -r ./redditdownloader/requirements.txt

ENTRYPOINT [ "python", "-u", "./main.py", "--settings", "./settings/settings.json"]
ENTRYPOINT [ "python", "-u", "./redditdownloader/main.py", "--settings", "./settings/settings.json"]
Binary file removed redditdownloader/tests/envs/all_sources.zip.enc
Binary file not shown.
Binary file removed redditdownloader/tests/envs/controlled_sources.zip.enc
Binary file not shown.
Binary file removed redditdownloader/tests/envs/rmd_version_4.zip.enc
Binary file not shown.
3 changes: 3 additions & 0 deletions redditdownloader/tests/full_runs/test_terminal_download.py
Expand Up @@ -22,6 +22,9 @@ def setUp(self):
sql.init_from_settings()
session = sql.session()

def tearDown(self):
sql.close()

def test_db_exists(self):
""" The Database file should be created """
self.assertTrue(isfile(self.db_path), 'The Database was not created!')
Expand Down
12 changes: 4 additions & 8 deletions redditdownloader/tests/mock.py
Expand Up @@ -3,7 +3,6 @@
from tempfile import gettempdir
from shutil import rmtree
import uuid
from tools.encryptor import Cryptor
import zipfile
import json

Expand All @@ -30,7 +29,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
if cls.dir:
rmtree(cls.dir, ignore_errors=True)
rmtree(cls.dir)

def temp_file(self, filename=None, ext=None):
""" Generate a temporary filepath scoped within this temp directory. """
Expand All @@ -50,24 +49,21 @@ class EnvironmentTest(StagedTest):
@classmethod
def setUpClass(cls):
super().setUpClass()
src = os.path.abspath(os.path.join(os.path.dirname(__file__), './envs', '%s.zip.enc' % cls.env))
src = os.path.abspath(os.path.join(os.path.dirname(__file__), './envs', '%s.zip' % cls.env))
if not cls.env:
raise Exception('Environment name is not set for this EnvironmentTest!')
if not os.path.isfile(src):
raise Exception('Unknown env file: %s' % src)
crypt = Cryptor()
zo = os.path.join(cls.dir, "__tmp.zip")
crypt.decrypt(src, zo) # Decrypt zip archive.
zip_ref = zipfile.ZipFile(zo, 'r')
zip_ref = zipfile.ZipFile(src, 'r')
zip_ref.extractall(cls.dir) # Extract zip archive.
zip_ref.close()
os.remove(zo)
js = os.path.join(cls.dir, 'settings.json') # Edit "settings.json", if it exists, to insert test dir path.
if os.path.isfile(js):
cls.settings_file = js
with open(js, 'r') as o:
txt = o.read()
txt = txt.replace('[TEST_DIR]', json.dumps(cls.dir))
txt = txt.replace('[REFRESH_TOKEN]', json.dumps(os.environ['RMD_REFRESH_TOKEN']))
with open(js, 'w') as o:
o.write(txt)

Expand Down
2 changes: 0 additions & 2 deletions requirements-dev.txt

This file was deleted.

0 comments on commit 3a1dc4f

Please sign in to comment.