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

pre-commit setup #238

Merged
merged 14 commits into from
Dec 13, 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
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# http://editorconfig.org

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.py]
max_line_length = 88

[*.{html,json}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = false

[*.{scss,js}]
indent_style = space
indent_size = 4
70 changes: 35 additions & 35 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
name: Create and publish a Docker image

on:
push:
branches: ['main']
push:
branches: ["main"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
type=ref,event=branch
type=sha
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
type=ref,event=branch
type=sha

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
36 changes: 18 additions & 18 deletions .github/workflows/docker-test-build.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: Docker test build

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
contents: read

jobs:
build-image:
runs-on: ubuntu-latest
build-image:
runs-on: ubuntu-latest

# steps taken (and trimmed) from docker-publish.yml
steps:
- name: Checkout repository
uses: actions/checkout@v2
# steps taken (and trimmed) from docker-publish.yml
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: false
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: false
28 changes: 14 additions & 14 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Linters

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
contents: read

jobs:
black:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: black
uses: psf/black@stable
black:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: black
uses: psf/black@stable
114 changes: 57 additions & 57 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
name: Tests

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
contents: read

env:
DJANGO_SETTINGS_MODULE: tracdjangoplugin.settings_tests
# passlib has a conditional import for `crypt` which is going away in python 3.13
# and therefore throwing warnings
PYTHONWARNINGS: >
error,
default:::passlib.utils,
DJANGO_SETTINGS_MODULE: tracdjangoplugin.settings_tests
# passlib has a conditional import for `crypt` which is going away in python 3.13
# and therefore throwing warnings
PYTHONWARNINGS: >
error,
default:::passlib.utils,

jobs:
noshadows:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install "tinycss2>=1.2.0"
- run: python noshadows.py --tests
noshadows:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install "tinycss2>=1.2.0"
- run: python noshadows.py --tests

tracdjangoplugin:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install system package dependencies
run: |
sudo apt-get update
sudo apt-get -y install subversion
- name: Install requirements
run: python -m pip install -r requirements.txt
- name: Run tests
run: python -m django test tracdjangoplugin.tests
tracdjangoplugin:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install system package dependencies
run: |
sudo apt-get update
sudo apt-get -y install subversion
- name: Install requirements
run: python -m pip install -r requirements.txt
- name: Run tests
run: python -m django test tracdjangoplugin.tests

traccheck:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install system package dependencies
run: |
sudo apt-get update
sudo apt-get -y install subversion
- name: Install requirements
run: python -m pip install -r requirements.txt
- name: Lint Trac configuration
run: python traccheck.py lint trac-env/
- name: Check frozen Trac components
run: python traccheck.py components --check .TRACFREEZE.txt trac-env/
traccheck:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install system package dependencies
run: |
sudo apt-get update
sudo apt-get -y install subversion
- name: Install requirements
run: python -m pip install -r requirements.txt
- name: Lint Trac configuration
run: python traccheck.py lint trac-env/
- name: Check frozen Trac components
run: python traccheck.py components --check .TRACFREEZE.txt trac-env/
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
default_language_version:
python: python3

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v5.0.0"
hooks:
- id: check-added-large-files
args: ["--maxkb=1024"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
exclude_types: [json, sql]
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: "v3.19.0"
hooks:
- id: pyupgrade
args: [--py312]

- repo: https://github.com/adamchainz/django-upgrade
rev: "1.22.2"
hooks:
- id: django-upgrade
args: [--target-version, "5.0"]

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.4.2"
hooks:
- id: prettier
exclude_types: [html, css, javascript, json, scss]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.5.0"
hooks:
- id: pyproject-fmt
3 changes: 1 addition & 2 deletions DjangoPlugin/tracdjangoplugin/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def __init__(self, application):
def __call__(self, environ, start_response):
request_started.send(sender=self.__class__)
try:
for data in self.application(environ, start_response):
yield data
yield from self.application(environ, start_response)
finally:
request_finished.send(sender=self.__class__)
4 changes: 1 addition & 3 deletions DjangoPlugin/tracdjangoplugin/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ def _format_changeset_link(self, formatter, ns, chgset, label, fullmatch=None):
return tag.a(label, class_="changeset", href=href)

# Fallback to the default implementation.
return super(GitHubBrowserWithSVNChangesets, self)._format_changeset_link(
formatter, ns, chgset, label, fullmatch
)
return super()._format_changeset_link(formatter, ns, chgset, label, fullmatch)


class PlainLoginComponent(Component):
Expand Down
Loading
Loading