-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ADD: django * ADD: pylint * UPDATE: ignore IDE * ADD: github workflows * ADD: bandit * ADD: flake8 * ADD: django * UPDATE: rename settings * ADD: Dockerfile * REMOVE: themes from docker * FIX: flake8 apps * ADD: coverage * FIX: line break * FIX: settings file * FIX: no input * ADD: static root * ADD: flake8 config * FORMAT * ADD: bandit config * ADD: base template * ADD: django pylint plugin * UPDATE: exlude test settings for bandit * WIP: ignore static in docker until used * FIX: exclude test setting
- Loading branch information
1 parent
25a483a
commit 5b29dc0
Showing
17 changed files
with
945 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[flake8] | ||
exclude = | ||
rechnung/settings.py | ||
rechnung/test_settings.py | ||
**/migrations/ | ||
|
||
max-line-length = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "daily" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Django CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: False | ||
max-parallel: 4 | ||
matrix: | ||
python-version: [ '3.13' ] | ||
test-type: [ 'unit', 'integration' ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: Load cached venv | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: poetry install --no-interaction | ||
- name: Install Firefox | ||
uses: browser-actions/setup-firefox@latest | ||
if: ${{ matrix.test-type == 'integration' }} | ||
|
||
- name: Run Tests | ||
run: | | ||
poetry run python manage.py collectstatic --settings=rechnung.test_settings --no-input | ||
poetry run coverage run manage.py test --settings=rechnung.test_settings | ||
if: ${{ matrix.test-type == 'unit' }} | ||
- name: Run Tests | ||
run: | | ||
poetry run python manage.py collectstatic --settings=rechnung.test_settings --no-input | ||
poetry run coverage run manage.py test -k Integration --settings=rechnung.test_settings | ||
if: ${{ matrix.test-type == 'integration' }} | ||
|
||
- name: Create Report | ||
run: | | ||
poetry run coverage json | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: Segelzwerg/rechnung |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Docker Image Build & Publish | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME_GHCR: ghcr.io/${{ github.repository_owner }}/${{ github.repository }} | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ 3.13 ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.IMAGE_NAME_GHCR }} | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | ||
type=sha | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
platforms: linux/amd64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
PYTHON_VERSION=${{ matrix.python-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: Whist-Team/actions/setup-poetry@v2 | ||
with: | ||
python-version: 3.13 | ||
|
||
- name: Lint sources with flake8 | ||
run: poetry run flake8 rechnung --count --show-source --statistics | ||
- uses: articulate/actions-markdownlint@v1 | ||
with: | ||
ignore: static/ | ||
- name: Lint sources with pylint | ||
run: poetry run pylint --load-plugins=pylint_django --django-settings-module=rechnung.test_settings rechnung | ||
|
||
security: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Run bandit | ||
uses: tj-actions/bandit@v5 | ||
with: | ||
targets: | | ||
rechnung | ||
options: "-r -c pyproject.toml -x rechnung/test_settings.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ARG PYTHON_VERSION=3.13 | ||
FROM python:${PYTHON_VERSION} AS poetry | ||
RUN pip install poetry | ||
WORKDIR /app | ||
COPY pyproject.toml poetry.lock ./ | ||
RUN poetry export -f requirements.txt --output requirements.txt | ||
LABEL authors="Segelzwerg" | ||
|
||
FROM python:${PYTHON_VERSION}-slim | ||
WORKDIR /app | ||
COPY --from=poetry /app/requirements.txt . | ||
RUN pip install -r requirements.txt | ||
COPY rechnung ./rechnung/ | ||
#COPY static/ ./static/ | ||
COPY templates/ ./templates/ | ||
COPY manage.py ./manage.py | ||
CMD python manage.py migrate --settings=$DJANGO_SETTINGS_MODUE; python manage.py collectstatic --no-input --settings=$DJANGO_SETTINGS_MODUE; django-admin compilemessages; gunicorn --bind=0.0.0.0 --timeout 600 rechnung.wsgi | ||
Check warning on line 17 in Dockerfile
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Rechnung | ||
|
||
Django App for invoices |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
"""Run administrative tasks.""" | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rechnung.test_settings') | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.