Skip to content
This repository was archived by the owner on Jun 26, 2022. It is now read-only.

Commit 894690b

Browse files
authored
Initial Buildout (#1)
1 parent 9992d7c commit 894690b

30 files changed

+1488
-0
lines changed

.devcontainer/devcontainer.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Python Sonarr Dev",
3+
"context": "..",
4+
"dockerFile": "../Dockerfile.dev",
5+
"settings": {
6+
"terminal.integrated.shell.linux": "/bin/bash",
7+
"python.pythonPath": "/usr/local/bin/python",
8+
"python.linting.enabled": true,
9+
"python.linting.pylintEnabled": true,
10+
"python.linting.pylintPath": "/usr/local/bin/pylint",
11+
"python.formatting.provider": "black",
12+
"editor.formatOnPaste": false,
13+
"editor.formatOnSave": true,
14+
"editor.formatOnType": true,
15+
"files.trimTrailingWhitespace": true
16+
},
17+
"extensions": [
18+
"ms-python.python",
19+
"esbenp.prettier-vscode"
20+
]
21+
}

.editorconfig

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
ident_size = 4
10+
11+
[*.md]
12+
ident_size = 2
13+
trim_trailing_whitespace = false
14+
15+
[*.json]
16+
ident_size = 2
17+
18+
[{.gitignore,.gitkeep,.editorconfig}]
19+
ident_size = 2
20+
21+
[Makefile]
22+
ident_style = tab

.flake8

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length=88
3+
ignore=D202

.github/release-drafter.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
template: |
2+
## What’s Changed
3+
4+
$CHANGES

.github/workflows/ci.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Continuous Integration
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
branches:
10+
- master
11+
12+
jobs:
13+
linting:
14+
name: Linting
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checking out code from GitHub
18+
uses: actions/checkout@v1
19+
- name: Set up Python 3.7
20+
uses: actions/setup-python@v1
21+
with:
22+
python-version: 3.7
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip setuptools wheel
26+
pip install -r requirements_test.txt
27+
pip install -r requirements.txt
28+
pip install pre-commit
29+
pip list
30+
pre-commit --version
31+
- name: Run pre-commit on all files
32+
run: |
33+
pre-commit run --all-files --show-diff-on-failure
34+
test:
35+
name: Python ${{ matrix.python }} on ${{ matrix.os }}
36+
runs-on: ${{ matrix.os }}-latest
37+
needs: [linting]
38+
strategy:
39+
matrix:
40+
os: [ubuntu]
41+
python: [3.7, 3.8]
42+
steps:
43+
- name: Checking out code from GitHub
44+
uses: actions/checkout@v1
45+
- name: Set up Python ${{ matrix.python }}
46+
uses: actions/setup-python@v1
47+
with:
48+
python-version: ${{ matrix.python }}
49+
- name: Install dependencies
50+
run: |
51+
python -m pip install --upgrade pip setuptools wheel
52+
pip install -r requirements_test.txt
53+
pip install -r requirements.txt
54+
pip list
55+
- name: Pytest with coverage reporting
56+
run: pytest --cov=sonarr --cov-report=xml
57+
- name: Upload coverage to Codecov
58+
if: matrix.python == 3.8 && matrix.os == 'ubuntu'
59+
uses: codecov/[email protected]
60+
with:
61+
token: ${{ secrets.CODECOV_TOKEN }}
62+
file: ./coverage.xml
63+
flags: unittests
64+
name: codecov-umbrella

.github/workflows/publish.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
twine upload dist/*

.github/workflows/release-drafter.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
update_release_draft:
10+
name: Update Release Draft
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: release-drafter/release-drafter@v5
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.isort.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[settings]
2+
multi_line_output=3
3+
line_length=88
4+
include_trailing_comma=True
5+
project=sonarr

.pre-commit-config.yaml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
repos:
3+
- repo: https://github.com/ambv/black
4+
rev: 19.10b0
5+
hooks:
6+
- id: black
7+
args: [--safe, --quiet, --target-version, py36]
8+
- repo: https://github.com/asottile/blacken-docs
9+
rev: v1.6.0
10+
hooks:
11+
- id: blacken-docs
12+
additional_dependencies: [black==19.3b0]
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v2.5.0
15+
hooks:
16+
- id: trailing-whitespace
17+
- id: end-of-file-fixer
18+
- id: check-merge-conflict
19+
- id: debug-statements
20+
- id: check-docstring-first
21+
- id: check-json
22+
- id: check-yaml
23+
- id: requirements-txt-fixer
24+
- id: check-byte-order-marker
25+
- id: check-case-conflict
26+
- id: fix-encoding-pragma
27+
args: ["--remove"]
28+
- id: check-ast
29+
- id: detect-private-key
30+
- id: forbid-new-submodules
31+
- repo: https://github.com/pre-commit/pre-commit
32+
rev: v2.1.1
33+
hooks:
34+
- id: validate_manifest
35+
- repo: https://github.com/pre-commit/mirrors-isort
36+
rev: v4.3.21
37+
hooks:
38+
- id: isort
39+
- repo: https://github.com/pre-commit/mirrors-pylint
40+
rev: v2.4.4
41+
hooks:
42+
- id: pylint
43+
- repo: https://github.com/pre-commit/mirrors-mypy
44+
rev: v0.761
45+
hooks:
46+
- id: mypy
47+
- repo: https://gitlab.com/pycqa/flake8
48+
rev: 3.7.9
49+
hooks:
50+
- id: flake8
51+
additional_dependencies: ["flake8-docstrings"]
52+
- repo: https://github.com/adrienverge/yamllint.git
53+
rev: v1.20.0
54+
hooks:
55+
- id: yamllint
56+
exclude: ^\.github/workflows/*\.yml$
57+
- repo: https://github.com/asottile/pyupgrade
58+
rev: v2.1.0
59+
hooks:
60+
- id: pyupgrade
61+
args: [--py36-plus]

.yamllint

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
ignore: |
3+
.github/
4+
rules:
5+
braces:
6+
level: error
7+
min-spaces-inside: 0
8+
max-spaces-inside: 1
9+
min-spaces-inside-empty: -1
10+
max-spaces-inside-empty: -1
11+
brackets:
12+
level: error
13+
min-spaces-inside: 0
14+
max-spaces-inside: 0
15+
min-spaces-inside-empty: -1
16+
max-spaces-inside-empty: -1
17+
colons:
18+
level: error
19+
max-spaces-before: 0
20+
max-spaces-after: 1
21+
commas:
22+
level: error
23+
max-spaces-before: 0
24+
min-spaces-after: 1
25+
max-spaces-after: 1
26+
comments:
27+
level: error
28+
require-starting-space: true
29+
min-spaces-from-content: 2
30+
comments-indentation:
31+
level: error
32+
document-end:
33+
level: error
34+
present: false
35+
document-start:
36+
level: error
37+
present: true
38+
empty-lines:
39+
level: error
40+
max: 1
41+
max-start: 0
42+
max-end: 1
43+
hyphens:
44+
level: error
45+
max-spaces-after: 1
46+
indentation:
47+
level: error
48+
spaces: 2
49+
indent-sequences: true
50+
check-multi-line-strings: false
51+
key-duplicates:
52+
level: error
53+
line-length:
54+
level: warning
55+
max: 120
56+
allow-non-breakable-words: true
57+
allow-non-breakable-inline-mappings: true
58+
new-line-at-end-of-file:
59+
level: error
60+
new-lines:
61+
level: error
62+
type: unix
63+
trailing-spaces:
64+
level: error
65+
truthy:
66+
level: error

Dockerfile.dev

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM python:3
7+
8+
# Avoid warnings by switching to noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
12+
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
13+
# will be updated to match your local UID/GID (when using the dockerFile property).
14+
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
15+
ARG USERNAME=vscode
16+
ARG USER_UID=1000
17+
ARG USER_GID=$USER_UID
18+
19+
# Uncomment the following COPY line and the corresponding lines in the `RUN` command if you wish to
20+
# include your requirements in the image itself. It is suggested that you only do this if your
21+
# requirements rarely (if ever) change.
22+
# COPY requirements.txt /tmp/pip-tmp/
23+
24+
# Configure apt and install packages
25+
RUN apt-get update \
26+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
27+
#
28+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
29+
&& apt-get -y install git openssh-client iproute2 procps lsb-release \
30+
#
31+
# Install pylint
32+
&& pip --disable-pip-version-check --no-cache-dir install pylint \
33+
#
34+
# Update Python environment based on requirements.txt
35+
# && pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
36+
# && rm -rf /tmp/pip-tmp \
37+
#
38+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
39+
&& groupadd --gid $USER_GID $USERNAME \
40+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
41+
# [Optional] Add sudo support for the non-root user
42+
&& apt-get install -y sudo \
43+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
44+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
45+
#
46+
# Clean up
47+
&& apt-get autoremove -y \
48+
&& apt-get clean -y \
49+
&& rm -rf /var/lib/apt/lists/*
50+
51+
# Switch back to dialog for any ad-hoc use of apt-get
52+
ENV DEBIAN_FRONTEND=dialog
53+
54+
# Install Python dependencies from requirements
55+
COPY requirements.txt requirements_test.txt requirements_dev.txt ./
56+
57+
RUN pip3 install -r requirements_test.txt; \
58+
pip3 install -r requirements_dev.txt; \
59+
pip install -Ur requirements.txt; \
60+
rm -f requirements.txt requirements_test.txt requirements_dev.txt

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include README.md
2+
include LICENSE.md
3+
graft sonarr
4+
recursive-exclude * *.py[co]

0 commit comments

Comments
 (0)