Skip to content

Commit

Permalink
Merge/tvsw (#33)
Browse files Browse the repository at this point in the history
* Edit docs coverage badge

* Add tests with branch coverage

* Update readme

* Add lint with flake8

* Fix bug where the exception sent as a message was not the one originally thrown

* Add support for Imgur gallery images

* Add mypy type checking

* Add DbC

* Add dev dependencies

* Add github pages workflow

* Add git-crypt to lint

* Add pyreverse

* Update failing test due to API error

* Add icontract linting
  • Loading branch information
fabiosangregorio committed Sep 2, 2020
1 parent 6db36b2 commit b8a5dbe
Show file tree
Hide file tree
Showing 59 changed files with 1,081 additions and 1,343 deletions.
16 changes: 2 additions & 14 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ version: "2"
checks:
argument-count:
config:
threshold: 5
threshold: 7
method-complexity:
config:
threshold: 7
threshold: 15
plugins:
duplication:
enabled: true
Expand All @@ -20,17 +20,5 @@ plugins:
config:
threshold: "C"
exclude_patterns:
- "config/"
- "db/"
- "dist/"
- "features/"
- "**/node_modules/"
- "script/"
- "**/spec/"
- "**/test/"
- "**/tests/"
- "Tests/"
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"
- "**/secret_*.py"
39 changes: 17 additions & 22 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,15 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.cache/pip # This path is specific to Ubuntu
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache CI dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip # This path is specific to Ubuntu
key: ${{ runner.os }}-pip-${{ hashFiles('./.github/workflows/requirements/docs.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements/requirements.txt') }}-${{ hashFiles('**/docs.txt') }}-${{ hashFiles('**/test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r ./.github/workflows/requirements/docs.txt
pip install -r ./requirements/requirements.txt
pip install -r ./requirements/docs.txt
pip install -r ./requirements/test.txt
- name: Unlock git-crypt files
uses: zemuldo/git-crypt-unlock@v3.0-alpha-1
Expand All @@ -50,35 +43,37 @@ jobs:
GPG_KEY_GRIP: ${{ secrets.GPG_KEY_GRIP }}
GPG_KEY_PASS: ${{ secrets.GPG_KEY_PASS }}

- name: Generate project dependency graphs
run: |
pyreverse --ignore="tests" -o png -p telereddit telereddit
mv classes_telereddit.png docs/images/classes_telereddit.png
mv packages_telereddit.png docs/images/packages_telereddit.png
- name: Generate documentation
run: |
rm -rf docs/telereddit
pdoc --html --output-dir="docs/" --template-dir="docs/templates" --config show_source_code=False --force .
env:
TELEREDDIT_MACHINE: GITHUB

- name: Run documentation coverage
- name: Run docstr coverage
run: |
mkdir documentation-reports
docstr-coverage telereddit --percentage-only --exclude=tests --skipinit 2>&1 | tee ./documentation-reports/docstr-coverage.txt
docstr-coverage telereddit --verbose=3 --exclude=tests --skipinit 2>&1 | tee ./documentation-reports/docstr-coverage.txt
- name: Run pydocstyle
run: |
(pydocstyle telereddit 2>&1 | tee ./documentation-reports/pydocstyle-coverage.txt; exit ${PIPESTATUS[0]})
- name: Upload documentation reports as artifact
uses: actions/upload-artifact@v2
with:
name: documentation-reports
path: ./documentation-reports/
path: ./documentation-reports/docstr-coverage.txt

- name: Commit changes
uses: EndBug/add-and-commit@v4
with:
message: "Commit from Github Actions: docs workflow changes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy docs to Gtihub Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/telereddit
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: github-pages

on:
push:
branches:
- master

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip # This path is specific to Ubuntu
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements/requirements.txt') }}-${{ hashFiles('**/docs.txt') }}-${{ hashFiles('**/test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r ./requirements/requirements.txt
pip install -r ./requirements/docs.txt
pip install -r ./requirements/test.txt
- name: Unlock git-crypt files
uses: zemuldo/git-crypt-unlock@v3.0-alpha-1
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_KEY_GRIP: ${{ secrets.GPG_KEY_GRIP }}
GPG_KEY_PASS: ${{ secrets.GPG_KEY_PASS }}

- name: Generate documentation
run: |
rm -rf docs/telereddit
pdoc --html --output-dir="docs/" --template-dir="docs/templates" --config show_source_code=False --force .
env:
TELEREDDIT_MACHINE: GITHUB

- name: Deploy docs to Github Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/telereddit
21 changes: 17 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,33 @@ jobs:
with:
python-version: 3.8

- name: Cache CI dependencies
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip # This path is specific to Ubuntu
key: ${{ runner.os }}-pip-${{ hashFiles('./.github/workflows/requirements/lint.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements/lint.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r ./.github/workflows/requirements/lint.txt
pip install -r ./requirements/lint.txt
- name: Unlock git-crypt files
uses: zemuldo/git-crypt-unlock@v3.0-alpha-1
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_KEY_GRIP: ${{ secrets.GPG_KEY_GRIP }}
GPG_KEY_PASS: ${{ secrets.GPG_KEY_PASS }}

- name: Check black code formatting
run: python -m black telereddit --check

- name: Check flake8 linting
run: python -m flake8 --config setup.cfg telereddit
run: python -m flake8 --config setup.cfg telereddit

- name: Check mypy linting
run: mypy telereddit

- name: Check icontract linting
run: pyicontract-lint --format verbose telereddit
3 changes: 0 additions & 3 deletions .github/workflows/requirements/docs.txt

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/requirements/lint.txt

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/requirements/test.txt

This file was deleted.

14 changes: 3 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,14 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.cache/pip # This path is specific to Ubuntu
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache CI dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip # This path is specific to Ubuntu
key: ${{ runner.os }}-pip-${{ hashFiles('./.github/workflows/requirements/test.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements/requirements.txt') }}-${{ hashFiles('**/test.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r ./.github/workflows/requirements/test.txt
pip install -r ./requirements/requirements.txt
pip install -r ./requirements/test.txt
- name: Run tests and generate report
run: |
Expand Down
56 changes: 8 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ __pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
Expand All @@ -25,16 +22,6 @@ wheels/
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
Expand All @@ -47,40 +34,6 @@ coverage.xml
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
Expand All @@ -103,10 +56,17 @@ venv.bak/

# mypy
.mypy_cache/
.mypy

# IDE
.vscode
.idea

# Python
__pycache__

documentation-reports
documentation-reports

html
.mutmut-cache
.metadata
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ Get it on [telegram.me](https://telegram.me/tele_reddit_bot)!

## Bugs and feature requests
If you want to report a bug or would like a feature to be added, feel free to open an issue.


## Versioning
We follow Semantic Versioning. The version X.Y.Z indicates:

* X is the major version (backward-incompatible),
* Y is the minor version (backward-compatible), and
* Z is the patch version (backward-compatible bug fix).

## License
**[GPL v3](https://www.gnu.org/licenses/gpl-3.0)** - Copyright 2020 © <a href="http://fabio.sangregorio.dev"
Expand Down
Binary file added docs/images/classes_telereddit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b8a5dbe

Please sign in to comment.