Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #58

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"template": "[email protected]:vorausrobotik/voraus-python-template.git",
"commit": "9ef5161b20a68d274ecf3828467c3f44f4747bca",
"checkout": null,
"context": {
"cookiecutter": {
"full_name": "Jan-Frederik Schmidt",
"email": "[email protected]",
"github_user": "",
"project_name": "shop-db2",
"repo_name": "shop-db2",
"package_name": "shop-db2",
"import_name": "shop_db2",
"project_short_description": "The simple way to manage purchases and user interactions in a small community.",
"url": "https://github.com/g3n35i5/shop-db2",
"_debug": "False",
"_extensions": ["extensions.git_extension.GitExtension"],
"_copy_without_render": ["docs/_templates/license_compliance.rst.j2"],
"_template": "[email protected]:vorausrobotik/voraus-python-template.git"
}
},
"directory": null
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @g3n35i5
100 changes: 100 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: CI pipeline

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
python-version: ["3.8", "3.9"]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install wkhtmltopdf
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get install xvfb libfontconfig wkhtmltopdf
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install wkhtmltopdf
fi

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

- name: Install tox
run: python -m pip install --upgrade pip tox tox-gh-actions

- name: Write example configuration file
run: cp configuration.example.py configuration.py

- name: Run tests
run: tox

- name: Upload coverage artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: pytest-${{ matrix.python-version }}
path: reports/*

coverage:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: reports

- uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install tox
run: python -m pip install --upgrade pip tox

- name: Combine coverage results
run: tox run -e combine-test-reports

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: reports/coverage.xml

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Install tox
run: python -m pip install --upgrade tox

- name: Run static checks
run: tox -e lint
47 changes: 47 additions & 0 deletions .github/workflows/pr_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Pull Request Lint

on:
pull_request:
types: [opened, edited, synchronize, labeled, unlabeled]

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title and description
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: false
# Configure additional validation for the subject based on a regex.
# This ensures the subject does start with an uppercase character.
subjectPattern: ^(?![a-z])(?![a-zA-Z]+s\s(?<!ss\s)).+[^\.\?\!]$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that:
- The subject does start with an uppercase character
- The subject does not end with a dot, question or exclamation mark
- The subject uses imperative mood
# If the PR contains one of these newline-delimited labels, the
# validation is skipped.
ignoreLabels: |
rebase
- name: Validate PR body is filled
env:
BODY_CONTEXT: ${{ toJson(github.event.pull_request.body) }}
run: |
if [ "$BODY_CONTEXT" = "null" ];\
then\
echo "Error: The pull request body is empty." &&\
echo "Please add a description why the change is necessary and link tickets." &&\
(exit 1);
else\
echo "PR Body is not empty. Check passed.";\
fi\
15 changes: 15 additions & 0 deletions .github/workflows/python_template_update_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Python template update checks
on:
push:
branches:
- "chore/update-template**"
jobs:
fail-if-rej-files-exist:
name: "Check for rejected files"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Assert that 0 files ending with '.rej' are in the current working directory.
# `xargs` returns 0 on success, otherwise status codes between 1 and 127, see
# https://man7.org/linux/man-pages/man1/xargs.1.html for details.
- run: find . -iname "*.rej" | wc -l | xargs -I % test % -eq 0
68 changes: 64 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ configuration.py
coverage.xml
.codacy-coverage
codacy-coverage.json
shopdb/uploads/*
!shopdb/uploads/valid*
!shopdb/uploads/broken*
!shopdb/uploads/non_quadratic.png
src/shop_db2/uploads/*
!src/shop_db2/uploads/valid*
!src/shop_db2/uploads/broken*
!src/shop_db2/uploads/non_quadratic.png
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -114,3 +114,63 @@ venv.bak/

# mypy
.mypy_cache/


# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# General
output/
.tox/
reports/
.coverage
.coverage.*
MANIFEST
docs/shop-db2*
docs/modules.rst
docs/ossLicenses.json
docs/license_compliance.rst
.env

# Build and package files
**/*.egg-info/
**/build/**/*
node_modules/
dist/
.jfrog/
*.class
*.py[cod]
*.jar
shop-db2-[0-9]*

# Log files
**/log/**/*
*.log

# IDEs
.idea/
.vscode/

# Virtual environments
venv/
.venv/
.conda/

# Generated by OS
.DS_Store
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Jan-Frederik Schmidt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 3 additions & 2 deletions Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager

import configuration as config
from shopdb.api import app, db, set_app
from shop_db2.api import app, db, set_app

import configuration as config # isort: skip

set_app(config.ProductiveConfig)
migrate = Migrate(app, db)
Expand Down
Loading
Loading