Skip to content

Commit

Permalink
add pre-commit hooks (#6)
Browse files Browse the repository at this point in the history
* run linter

* add Linter action
  • Loading branch information
abe-101 authored Jun 19, 2024
1 parent c405071 commit 5b090f7
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 14 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Linter

on:
pull_request:
branches: ['master', 'main']
paths-ignore: ['docs/**']

push:
branches: ['master', 'main']
paths-ignore: ['docs/**']

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# Consider using pre-commit.ci for open source project
- name: Run pre-commit
uses: abe-101/[email protected]
with:
extra_args: --hook-stage push
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
exclude: '^docs/|/migrations/|devcontainer.json'
default_stages: [commit]

default_language_version:
python: python3.12

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.16.0'
hooks:
- id: django-upgrade
args: ['--target-version', '4.2']

# Run the Ruff linter.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
# Linter
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
# Formatter
- id: ruff-format

- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.34.1
hooks:
- id: djlint-reformat-django
- id: djlint-django



# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
2 changes: 0 additions & 2 deletions djstripe_example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

import os
from pathlib import Path
import environ

Expand Down Expand Up @@ -111,7 +110,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

Expand Down
13 changes: 10 additions & 3 deletions djstripe_example/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Dj-Stripe Example Project">
<meta name="author" content="Abe Hanoka">
<meta name="keywords"
content="Dj-Stripe, Stripe, Django, Payment Integration">
<title>Dj-Stripe Example Project</title>
<script src="https://js.stripe.com/v3/"></script>
<link rel="stylesheet" href="https://unpkg.com/mvp.css" />
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
</head>
<body>
{% block content %} {% endblock %}
{% block content %}
{% endblock content %}
</body>
</html>
11 changes: 5 additions & 6 deletions djstripe_example/templates/checkout_redirect.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{% extends "base.html" %} {% block content %}

<script type="application/javascript">
{% extends "base.html" %}
{% block content %}
<script type="application/javascript">
const stripe = Stripe("{{ stripe_public_key }}");
stripe.redirectToCheckout({
sessionId: "{{ checkout_session_id }}",
});
</script>

{% endblock %}
</script>
{% endblock content %}
1 change: 1 addition & 0 deletions djstripe_example/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import include, path

Expand Down
1 change: 1 addition & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ version = "0.1.0"
description = ""
authors = ["Jerome Leclanche <[email protected]>"]
# Uncomment if using a local copy
# package-mode = false
package-mode = false

[tool.poetry.dependencies]
python = "^3.9"
django = "^4.2"
django-environ = "^0.11.2"
# Choose between using the latest verion or a local copy
dj-stripe = {git = "https://github.com/dj-stripe/dj-stripe.git"}
# dj-stripe = { path = "../dj-stripe" }
# dj-stripe = {git = "https://github.com/dj-stripe/dj-stripe.git"}
dj-stripe = { path = "../dj-stripe" }

[tool.poetry.dev-dependencies]

Expand Down

0 comments on commit 5b090f7

Please sign in to comment.