Skip to content

Commit 8217ae8

Browse files
committed
Initial commit
0 parents  commit 8217ae8

File tree

20 files changed

+480
-0
lines changed

20 files changed

+480
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- README.md
9+
- Dockerfile
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/setup-python@v2
15+
- uses: actions/checkout@master
16+
with:
17+
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
18+
19+
- name: Install Sphinx theme
20+
run: pip install sphinx-rtd-theme
21+
22+
- name: Build and Commit
23+
uses: sphinx-notes/pages@v2
24+
25+
- name: Push changes
26+
uses: ad-m/github-push-action@master
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
branch: gh-pages
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Lint and test Python
2+
3+
on: [pull_request, push]
4+
jobs:
5+
6+
lint_python:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repository
10+
uses: actions/checkout@v2
11+
12+
- name: Python setup
13+
uses: actions/setup-python@v2
14+
15+
- name: Install project dependencies
16+
run: pip install -r requirements.txt
17+
18+
- name: Install testing/linting dependencies
19+
run: pip install bandit flake8 pytest pyupgrade safety coverage
20+
21+
- name: Scan for security issues with Bandit
22+
run: bandit --recursive --skip B101 . # B101 is assert statements
23+
24+
- name: Lint with Flake8
25+
run: |
26+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
27+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --show-source --statistics
28+
29+
- run: safety check --full-report --ignore=44715 --output safety-check.txt || true
30+
31+
- uses: actions/upload-artifact@v3
32+
with:
33+
name: safety-check-results
34+
path: safety-check.txt
35+
36+
- name: Determine test coverage
37+
run: |
38+
coverage run -m pytest .
39+
coverage report -m --fail-under=60
40+
coverage html
41+
42+
- uses: actions/upload-artifact@v3
43+
with:
44+
name: test-coverage-results
45+
path: htmlcov/

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches: ['main', 'dev']
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push-image:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Run Snyk to check for vulnerabilities
23+
uses: snyk/actions/python-3.8@master
24+
env:
25+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
26+
with:
27+
args: --severity-threshold=high
28+
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@v1
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@v3
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@v2
44+
with:
45+
context: .
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Snyk results
2+
.dccache
3+
4+
Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
cover/
56+
57+
# Translations
58+
*.mo
59+
*.pot
60+
61+
# Django stuff:
62+
*.log
63+
local_settings.py
64+
db.sqlite3
65+
db.sqlite3-journal
66+
67+
# Flask stuff:
68+
instance/
69+
.webassets-cache
70+
71+
# Scrapy stuff:
72+
.scrapy
73+
74+
# Sphinx documentation
75+
docs/_build/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
# .python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# poetry
101+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102+
# This is especially recommended for binary packages to ensure reproducibility, and is more
103+
# commonly ignored for libraries.
104+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105+
#poetry.lock
106+
107+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
108+
__pypackages__/
109+
110+
# Celery stuff
111+
celerybeat-schedule
112+
celerybeat.pid
113+
114+
# SageMath parsed files
115+
*.sage.py
116+
117+
# Environments
118+
.env
119+
.venv
120+
env/
121+
venv/
122+
ENV/
123+
env.bak/
124+
venv.bak/
125+
126+
# Spyder project settings
127+
.spyderproject
128+
.spyproject
129+
130+
# Rope project settings
131+
.ropeproject
132+
133+
# mkdocs documentation
134+
/site
135+
136+
# mypy
137+
.mypy_cache/
138+
.dmypy.json
139+
dmypy.json
140+
141+
# Pyre type checker
142+
.pyre/
143+
144+
# pytype static type analyzer
145+
.pytype/
146+
147+
# Cython debug symbols
148+
cython_debug/
149+
150+
# PyCharm
151+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
152+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
153+
# and can be added to the global gitignore or merged into this file. For a more nuclear
154+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
155+
#.idea/

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"python.linting.pylintEnabled": false,
3+
"python.linting.enabled": true,
4+
"python.linting.flake8Enabled": true
5+
}

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM python:3.8-slim-buster
4+
5+
WORKDIR /app
6+
7+
COPY requirements.txt requirements.txt
8+
RUN pip3 install -r requirements.txt
9+
10+
COPY ./app .
11+
12+
CMD [ "python3", "app.py"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Tristan Nolde
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.MD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[![GitHub license](https://img.shields.io/github/license/TrisNol/sample-python-repo.svg)](https://github.com/TrisNol/sample-python-repo/blob/master/LICENSE)
2+
[![Github all releases](https://img.shields.io/github/downloads/TrisNol/sample-python-repo/total.svg)](https://github.com/users/TrisNol/packages/container/package/sample-python-repo)
3+
[![GitHub forks](https://img.shields.io/github/forks/TrisNol/sample-python-repo.svg?style=social&label=Fork&maxAge=2592000)](https://github.com/TrisNol/sample-python-repo)
4+
# Sample Python Repo
5+
This repo contains a skeleton for Python projects containing some basic DevOps´ components like CI/CD pipelines.
6+
7+
## Linting
8+
The code of this repo will be linted with [PyLint](https://pylint.org/) automatically on each push and pull-request to ensure that the files are correctly formatted in order to improve readability.
9+
10+
## Tests
11+
You can add your tests in the test/ directory. By providing the prefix test_ the files will be recognized and executed by PyTest.
12+
13+
## Documentation
14+
The documentation is created with the help of [Sphinx](https://www.sphinx-doc.org/en/master/), which generates a html-based docu that is exposed via GitHub pages. In order to see the documentation, some configuration in GitHub needs to be done. Head to the repo´s settings and enable GitHub pages. Set the source to branch `gh-pages`. The documentation should now be hosted at `http[s]:<username>.github.io/<repo-name>`
15+
16+
In order to adapt the config, change the specifics in ```./docs/conf.py```.
17+
To manually build the documentation execute the following command - and install sphinx if you haven´t already - ```sphinx-build ./docs ./docs/_build```.
18+
However, the documentation will be built automatically on each push and added to the repo by a GitHub Action - so you don´t have to generate it yourself each time.

app/__init__.py

Whitespace-only changes.

app/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
if __name__ == '__main__':
3+
print('Hello there')

0 commit comments

Comments
 (0)