Skip to content

Commit

Permalink
CI pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 11, 2024
1 parent 05147f6 commit 6ed2e71
Show file tree
Hide file tree
Showing 10 changed files with 678 additions and 74 deletions.
29 changes: 19 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,35 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.18.0
rev: 1.21.0
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.9"
rev: "v0.6.4"
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/biomejs/pre-commit
rev: "v0.4.0"
hooks:
- id: biome-check
additional_dependencies: ["@biomejs/biome@1.8.1"]
args: [--unsafe]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.1.3
rev: 2.2.3
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.18
rev: v0.19
hooks:
- id: validate-pyproject
- repo: local
hooks:
- id: prettier
name: prettier
entry: npx prettier@3.3.3 --no-semi --write
language: system
types_or: [css, scss]
require_serial: true
- id: eslint
name: eslint
entry: yarn eslint
language: system
types_or: [javascript]
require_serial: true
verbose: true
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Change log
Next version
~~~~~~~~~~~~

- Pruned the CI matrix.


0.16 (2024-07-30)
~~~~~~~~~~~~~~~~~

Expand Down
38 changes: 0 additions & 38 deletions biome.json

This file was deleted.

17 changes: 10 additions & 7 deletions cabinet/management/commands/archive_cabinet_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from pathlib import Path
from zipfile import ZIP_DEFLATED, ZipFile

from cabinet.models import Folder
from django.core.management import BaseCommand

from cabinet.models import Folder


def _get_random_suffix():
return random.choices(string.ascii_lowercase, k=4)
Expand All @@ -29,12 +30,14 @@ def handle(self, **options):

if arc_path in arc_paths:
filename = Path(file.file_name)
arc_path = Path(*path) / "".join([
filename.stem,
"_",
*_get_random_suffix(),
*filename.suffixes,
])
arc_path = Path(*path) / "".join(
[
filename.stem,
"_",
*_get_random_suffix(),
*filename.suffixes,
]
)

zip_file.write(file.file.path, arc_path)
arc_paths.add(arc_path)
Expand Down
17 changes: 17 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import globals from "globals";
import pluginJs from "@eslint/js";


export default [
{files: ["**/*.js"], languageOptions: {sourceType: "script"}},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
{
rules: {
"no-unused-vars": [
"error",
{argsIgnorePattern: "^_", varsIgnorePattern: "^_"}
]
},
},
];
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "module",
"devDependencies": {
"@eslint/js": "^9.10.0",
"eslint": "^9.10.0",
"globals": "^15.9.0"
}
}
9 changes: 2 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = { text = "BSD-3-Clause" }
authors = [
{ name = "Matthias Kestenholz", email = "mk@feinheit.ch" },
]
requires-python = ">=3.9"
requires-python = ">=3.10"
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
Expand All @@ -21,7 +21,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down Expand Up @@ -51,7 +50,7 @@ include = [
path = "cabinet/__init__.py"

[tool.ruff]
target-version = "py39"
target-version = "py310"

fix = true
show-fixes = true
Expand All @@ -73,8 +72,6 @@ lint.extend-select = [
"I",
# flake8-gettext
"INT",
# pep8-naming
"N",
# pygrep-hooks
"PGH",
# flake8-pie
Expand All @@ -84,8 +81,6 @@ lint.extend-select = [
"PLW",
# unused noqa
"RUF100",
# flake8-simplify
"SIM",
# flake8-tidy-imports
"TID",
# pyupgrade
Expand Down
21 changes: 12 additions & 9 deletions tests/testapp/test_cabinet.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import tempfile
import io
import itertools
import json
import os
import shutil
import tempfile
from pathlib import Path
from unittest.mock import patch
from zipfile import ZipFile

from django import forms
from django.conf import settings
Expand All @@ -17,10 +20,7 @@

from cabinet.base import AbstractFile, DownloadMixin, determine_accept_file_functions
from cabinet.models import File, Folder, get_file_model
from pathlib import Path
from testapp.models import Stuff
from unittest.mock import patch
from zipfile import ZipFile


class CabinetTestCase(TestCase):
Expand All @@ -38,7 +38,7 @@ def login(self):
client.login(username="test", password="test")
return client

def assertNoMediaFiles(self): # noqa: N802
def assertNoMediaFiles(self):
File.objects.all().delete()
files = list(
itertools.chain.from_iterable(i[2] for i in os.walk(settings.MEDIA_ROOT))
Expand Down Expand Up @@ -553,7 +553,10 @@ class CustomFile(AbstractFile, NonModelMixin, DownloadMixin):
],
)

@patch("cabinet.management.commands.archive_cabinet_folder._get_random_suffix", return_value="asdf")
@patch(
"cabinet.management.commands.archive_cabinet_folder._get_random_suffix",
return_value="asdf",
)
def test_archive_management_command(self, patched__get_random_suffix):
output = "archive.zip"
folder = Folder.objects.create(name="Top")
Expand All @@ -567,13 +570,13 @@ def test_archive_management_command(self, patched__get_random_suffix):
File.objects.all().update(file_name="hello.txt")

with tempfile.TemporaryDirectory() as tmp_dir:
output = Path(tmp_dir) / 'output.zip'
call_command('archive_cabinet_folder', folder_id=folder.id, output=output)
output = Path(tmp_dir) / "output.zip"
call_command("archive_cabinet_folder", folder_id=folder.id, output=output)
with ZipFile(output, "r") as zip_file:
self.assertEqual(
zip_file.namelist(),
[
"Top/Sub/hello.txt",
"Top/Sub/hello_asdf.txt",
]
],
)
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
py{39,310}-dj{32,41,42}
py{310,311,312}-dj{32,41,42,50,main}
py{310}-dj{32,42}
py{310,311,312}-dj{32,42,50,51,main}
docs

[testenv]
Expand All @@ -12,9 +12,9 @@ commands =
coverage report -m
deps =
dj32: Django>=3.2,<4.0
dj41: Django>=4.1,<4.2
dj42: Django>=4.2,<5.0
dj50: Django>=5.0,<5.1
dj51: Django>=5.1,<5.2
djmain: https://github.com/django/django/archive/main.tar.gz

[testenv:docs]
Expand Down
Loading

0 comments on commit 6ed2e71

Please sign in to comment.