Skip to content

Commit 2606fd2

Browse files
committed
Update package and CI setup
1 parent e981a6d commit 2606fd2

File tree

8 files changed

+142
-79
lines changed

8 files changed

+142
-79
lines changed

.fussyfox.yml

-4
This file was deleted.

.github/dependabot.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
version: 2
22
updates:
3+
- package-ecosystem: pip
4+
directory: "/"
5+
schedule:
6+
interval: daily
37
- package-ecosystem: github-actions
48
directory: "/"
59
schedule:

.github/workflows/ci.yml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
11+
analyze:
12+
name: CodeQL
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
- name: Initialize CodeQL
18+
uses: github/codeql-action/init@v1
19+
with:
20+
languages: python
21+
- name: Perform CodeQL Analysis
22+
uses: github/codeql-action/analyze@v1
23+
24+
msgcheck:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/setup-python@v2
28+
- uses: actions/checkout@v2
29+
- run: sudo apt install -y gettext aspell libenchant-dev
30+
- uses: actions/[email protected]
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('lint-requirements.txt') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
- run: python -m pip install -r lint-requirements.txt
37+
- run: msgcheck -n stdimage/locale/*/LC_MESSAGES/*.po
38+
39+
lint:
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
lint-command:
44+
- "bandit -r . -x ./tests"
45+
- "black --check --diff ."
46+
- "flake8 ."
47+
- "isort --check-only --diff ."
48+
- "pydocstyle ."
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/setup-python@v2
52+
- uses: actions/checkout@v2
53+
- uses: actions/[email protected]
54+
with:
55+
path: ~/.cache/pip
56+
key: ${{ runner.os }}-pip-${{ hashFiles('lint-requirements.txt') }}
57+
restore-keys: |
58+
${{ runner.os }}-pip-
59+
- run: python -m pip install -r lint-requirements.txt
60+
- run: ${{ matrix.lint-command }}
61+
62+
63+
dist:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Install gettext
67+
run: sudo apt-get install gettext -y
68+
- uses: actions/[email protected]
69+
- run: python -m pip install --upgrade pip setuptools wheel twine readme-renderer
70+
- uses: actions/[email protected]
71+
- run: python setup.py sdist bdist_wheel
72+
- run: python -m twine check dist/*
73+
- uses: actions/upload-artifact@v2
74+
with:
75+
path: dist/*
76+
77+
pytest:
78+
runs-on: ubuntu-latest
79+
needs:
80+
- lint
81+
- msgcheck
82+
strategy:
83+
matrix:
84+
python-version:
85+
- "3.7"
86+
- "3.8"
87+
- "3.9"
88+
django-version:
89+
- "2.2"
90+
- "3.1"
91+
steps:
92+
- name: Set up Python ${{ matrix.python-version }}
93+
uses: actions/[email protected]
94+
with:
95+
python-version: ${{ matrix.python-version }}
96+
- uses: actions/[email protected]
97+
- name: Install dependencies
98+
run: |
99+
python -m pip install --upgrade pip setuptools codecov
100+
pip install django~=${{ matrix.django-version }}
101+
- name: Test with pytest
102+
run: python setup.py test
103+
- run: codecov

.github/workflows/tests.yml

-45
This file was deleted.

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ include stdimage/locale/*/LC_MESSAGES/django.mo
33
prune tests
44
prune .github
55
exclude .*
6+
exclude lint-requirements.txt

lint-requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bandit==1.7.0
2+
black==20.8b1
3+
flake8==3.9.0
4+
isort==5.7.0
5+
msgcheck==3.1
6+
pydocstyle==6.0.0

setup.cfg

+8-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ classifier =
2020
Topic :: Software Development
2121
Programming Language :: Python :: 3
2222
Programming Language :: Python :: 3 :: Only
23+
Programming Language :: Python :: 3.7
24+
Programming Language :: Python :: 3.8
25+
Programming Language :: Python :: 3.9
2326
Framework :: Django
27+
Framework :: Django :: 2.2
28+
Framework :: Django :: 3.1
29+
30+
python_requires = >=3.7
2431

2532
[options]
2633
include_package_data = True
@@ -53,17 +60,7 @@ test = pytest
5360
[tool:pytest]
5461
norecursedirs=venv env .eggs
5562
DJANGO_SETTINGS_MODULE=tests.settings
56-
addopts = --cov=stdimage --cov-report xml --tb=short -rxs --nomigrations
57-
58-
[tox:tox]
59-
envlist = py{36,37}-dj{111,22,master}
60-
61-
[testenv]
62-
deps =
63-
dj111: https://github.com/django/django/archive/stable/1.11.x.tar.gz#egg=django
64-
dj22: https://github.com/django/django/archive/stable/2.2.x.tar.gz#egg=django
65-
djmaster: https://github.com/django/django/archive/master.tar.gz#egg=django
66-
commands = python setup.py test
63+
addopts = --cov=stdimage --nomigrations
6764

6865
[flake8]
6966
max-line-length = 88

setup.py

+20-19
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,54 @@
55
import subprocess # nosec
66
from distutils.cmd import Command
77
from distutils.command.build import build as _build
8+
from distutils.command.install import install as _install
89

910
from setuptools import setup
10-
from setuptools.command.install_lib import install_lib as _install_lib
1111

1212
BASE_DIR = os.path.dirname((os.path.abspath(__file__)))
1313

1414

1515
class compile_translations(Command):
16-
description = 'Compile i18n translations using gettext.'
16+
description = "Compile i18n translations using gettext."
1717
user_options = []
1818

1919
def initialize_options(self):
20-
pass
20+
self.build_lib = None
2121

2222
def finalize_options(self):
23-
pass
23+
self.set_undefined_options("build", ("build_lib", "build_lib"))
2424

2525
def run(self):
26-
pattern = 'stdimage/locale/*/LC_MESSAGES/django.po'
26+
pattern = "stdimage/locale/*/LC_MESSAGES/django.po"
2727
for file in glob.glob(pattern):
28-
cmd = ['msgfmt', '-c']
2928
name, ext = os.path.splitext(file)
30-
31-
cmd += ['-o', '%s.mo' % name]
32-
cmd += ['%s.po' % name]
29+
cmd = ["msgfmt", "-c", "-o", f"{self.build_lib}/{name}.mo", file]
3330
self.announce(
34-
'running command: %s' % ' '.join(cmd),
35-
level=distutils.log.INFO)
31+
"running command: %s" % " ".join(cmd), level=distutils.log.INFO
32+
)
3633
subprocess.check_call(cmd, cwd=BASE_DIR) # nosec
3734

3835

3936
class build(_build):
40-
sub_commands = [('compile_translations', None)] + _build.sub_commands
37+
sub_commands = [
38+
*_build.sub_commands,
39+
("compile_translations", None),
40+
]
4141

4242

43-
class install_lib(_install_lib):
44-
def run(self):
45-
self.run_command('compile_translations')
46-
_install_lib.run(self)
43+
class install(_install):
44+
sub_commands = [
45+
*_install.sub_commands,
46+
("compile_translations", None),
47+
]
4748

4849

4950
setup(
5051
name='django-stdimage',
5152
use_scm_version=True,
5253
cmdclass={
53-
'build': build,
54-
'install_lib': install_lib,
55-
'compile_translations': compile_translations,
54+
"build": build,
55+
"install": install,
56+
"compile_translations": compile_translations,
5657
},
5758
)

0 commit comments

Comments
 (0)