From dc7bc829b9c25d30f871fd1de09632aa1a6664d4 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sun, 10 Jul 2022 18:57:28 +0100 Subject: [PATCH] Initial commit --- .github/workflows/merge-to-main.yml | 34 +++++++ .github/workflows/pull-request.yml | 39 ++++++++ .gitignore | 135 ++++++++++++++++++++++++++++ CODEOWNERS | 1 + README.md | 7 ++ app/main.py | 8 ++ renovate.json | 26 ++++++ requirements-dev.txt | 4 + requirements.txt | 0 sonar-project.properties | 8 ++ tests/test_main.py | 0 11 files changed, 262 insertions(+) create mode 100644 .github/workflows/merge-to-main.yml create mode 100644 .github/workflows/pull-request.yml create mode 100644 .gitignore create mode 100644 CODEOWNERS create mode 100644 README.md create mode 100644 app/main.py create mode 100644 renovate.json create mode 100644 requirements-dev.txt create mode 100644 requirements.txt create mode 100644 sonar-project.properties create mode 100644 tests/test_main.py diff --git a/.github/workflows/merge-to-main.yml b/.github/workflows/merge-to-main.yml new file mode 100644 index 0000000..c21b5a8 --- /dev/null +++ b/.github/workflows/merge-to-main.yml @@ -0,0 +1,34 @@ +name: Merge to main +on: + push: + branches: + - main + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: pip install -r requirements.txt && pip install -r requirements-dev.txt + - name: Lint + run: pylint --recursive=yes --output-format=parseable --output=lintreport.txt . + - name: Unit Test + run: | + coverage run -m py.test -v + coverage xml + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + - uses: sonarsource/sonarqube-quality-gate-action@master + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..d1081ac --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,39 @@ +name: CI +on: + pull_request: + paths-ignore: + - 'README.md' + - 'LICENSE.md' + - '.gitignore' + - 'CODEOWNERS' + - 'renovate.json' + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: pip install -r requirements.txt && pip install -r requirements-dev.txt + - name: Lint + run: pylint --recursive=yes --output-format=parseable --output=lintreport.txt . + - name: Unit Test + run: | + coverage run -m py.test -v --junitxml=testresults.xml + coverage xml + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + - uses: sonarsource/sonarqube-quality-gate-action@master + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7f4045e --- /dev/null +++ b/.gitignore @@ -0,0 +1,135 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.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 +lintreport.txt +testresults.xml +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# IDE +.vscode +.idea diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..0d35f6e --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @luketainton \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..86b71e3 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# template + +## Description + +## How to install + +## How to use diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..a6053f8 --- /dev/null +++ b/app/main.py @@ -0,0 +1,8 @@ +#!/usr/local/bin/python3 + +def main(): + # Commands here + + +if __name__ == "__main__": + main() diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..e2cb0cc --- /dev/null +++ b/renovate.json @@ -0,0 +1,26 @@ +{ + "extends": ["config:base"], + "platformCommit": true, + "dependencyDashboardAutoclose": true, + "assignAutomerge": true, + "assigneesFromCodeOwners": true, + "rebaseWhen": "behind-base-branch", + "rollbackPrs": true, + "labels": ["dependencies"], + "packageRules": [ + { + "matchPackagePatterns": ["black", "pylint"], + "labels": ["linting"] + }, + { + "matchPackagePatterns": ["coverage", "pytest"], + "labels": ["unit-tests"] + } + ], + "vulnerabilityAlerts": { + "enabled": true, + "labels": ["security"], + "commitMessagePrefix": "[SECURITY] ", + "prCreation": "immediate" + } +} diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..fcf0dd6 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +black +coverage +pylint +pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..286b4f0 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,8 @@ +sonar.projectKey=luketainton_ +sonar.python.version=3.10 +sonar.python.coverage.reportPaths=coverage.xml +sonar.python.pylint.reportPaths=lintreport.txt +sonar.python.xunit.reportPath=testresults.xml +sonar.sources=app +sonar.tests=tests +sonar.exclusions=,.github/**,.gitignore,CODEOWNERS,CHANGELOG.md,LICENSE.md,README.md,renovate.json,requirements-dev.txt,requirements.txt \ No newline at end of file diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..e69de29