From 0c2ef9dc47ad6178ceca0d662ea35a65dc9daba1 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Aug 2022 13:09:28 +0100 Subject: [PATCH 1/3] Setup gh actions and linting --- .github/workflows/tests.yml | 51 +++++++++++++++++++++++++++++++++++++ .travis.yml | 12 --------- Makefile | 18 +++++++++++++ requirements.txt | 4 +++ setup.py | 2 +- tests/legacy.py | 2 +- tests/test_widgets.py | 11 +++++++- tox.ini | 4 +++ 8 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml create mode 100644 Makefile create mode 100644 requirements.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..bdbed94 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,51 @@ +name: Tests +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install Dependencies + run: make install + + - name: Lint + run: make lint + + - name: Tests + run: make test + + publish: + needs: test + if: "success() && startsWith(github.ref, 'refs/tags/')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: set up python + uses: actions/setup-python@v1 + with: + python-version: '3.8' + + - name: install + run: | + make install + pip install -U wheel twine + - name: build + run: python setup.py sdist bdist_wheel + + - run: twine check dist/* + + - name: upload to pypi + run: twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.pypi_password }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 964d9a0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: python - -script: - - ls -hlR - -deploy: -- provider: pypi - user: samuelcolvin - password: - secure: JT5xecDyHp/zkc4K0MaOc89n9MtqnUbprIg07XJc4l59dTr6DSUihweDzi+6V8l4j+OWcxER9+ytnztcQIJp+smk4KNmKxNQIa61T2HmRZp7AwFszG7Z32alayllCocrwbOjChjvf7APgxQBFe5wG+f+4mwDgH5+XbY5TEAldLxnN9CERp5ai2+M/zFys3DRXmzrd6DEsf68/7gndnH2EU2mTaUwHT6gijbkr06JR1y4pDIO5Pb229Feb/Cua6KPQ6PDQYTZECSBNcNWMXNJYpRCXstqesPuebECFUnS8mar7M5sVimEC1LvWWt7eup8Hvm3xxcPWurbsAql1WGEWhn5SHOt2jRDYMODk1z+IhhuHKx8xfke/cxe27Jpw+PJ0m125wVgMaq6bPVFTxmnd6j8veqEb0JV85In/SWoGMgt/hfeDi7OBsrRgSPQqYaIvtLdgY7oHZ8RbVvlzXFsinQPjtCR5hjVd6d7JA0SHwG/HqPC2R/91jKR++sCkNmSRunIT9pYVKkBrTY1B63/HPK2P+3kcOsEvutaFURcwQ6PIIPo2dfWLNfRudHLpkg2LLNnigWV6rbP5YY0SRqGQpxicP1lnZp0WRxNolEPBYB/X1bl3aVUMAeIK9Cu1jxffrL1F+nGrbydH+a5RyIugJ/Sgkd46fNuMvrMZqHzxQI= - on: - tags: true diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d67b15d --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +black = black -S -l 120 --target-version py39 + +.PHONY: install +install: + pip install --progress-bar off -r requirements.txt + +.PHONY: black +black: + $(black) tests/ + +.PHONY: lint +lint: + flake8 tests/ + $(black) --check tests/ + +.PHONY: test +test: + tox \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..de6b970 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +black==22.6.0 +django>=3 +flake8==5.0.4 +tox==3.25.1 \ No newline at end of file diff --git a/setup.py b/setup.py index c90b4a0..7747591 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ import pypandoc long_description = pypandoc.convert('README.md', 'rst') -VERSION = '2.8.2' +VERSION = '2.8.3' setup( name='django-bootstrap3-datetimepicker-2', diff --git a/tests/legacy.py b/tests/legacy.py index f9d7aad..59d9969 100644 --- a/tests/legacy.py +++ b/tests/legacy.py @@ -12,5 +12,5 @@ def build_attrs(self, base_attrs=None, extra_attrs=None, **kwargs): def is_legacy(): - x,y,z = [int(v) for v in django.__version__.split(".")] + x, y, z = [int(v) for v in django.__version__.split(".")] return x == 1 and y < 11 diff --git a/tests/test_widgets.py b/tests/test_widgets.py index 0dc8512..86c2158 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -8,5 +8,14 @@ def test_rendering(): options = {"pickTime": True, "format": "YYYY-MM-DD HH:mm"} widget = (DateTimePickerDjango110 if is_legacy() else DateTimePicker)(options=options) - expected_output = '\n
\n \n \n \n \n
\n ' + expected_output = ( + '\n
\n \n \n \n \n
\n ' + ) assert widget.render("a", "b", {}) == expected_output % json.dumps(options) diff --git a/tox.ini b/tox.ini index a950b1e..676e745 100644 --- a/tox.ini +++ b/tox.ini @@ -15,3 +15,7 @@ deps = django40: django==4.0.* setenv = PYTHONPATH = {toxinidir} + +[flake8] +max-line-length = 120 +max-complexity = 10 From 5378d8df3fbdf5b6e5ad0a6980550d4284ede67e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Aug 2022 13:11:46 +0100 Subject: [PATCH 2/3] Up python version --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bdbed94..a2cce25 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.9 - name: Install Dependencies run: make install @@ -33,7 +33,7 @@ jobs: - name: set up python uses: actions/setup-python@v1 with: - python-version: '3.8' + python-version: '3.9' - name: install run: | From 46f854347d1d6b3e2fcd62539a70655748ff83e3 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 8 Aug 2022 14:08:45 +0100 Subject: [PATCH 3/3] Set python req --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index de6b970..8099395 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ black==22.6.0 -django>=3 +django>=1.10 flake8==5.0.4 tox==3.25.1 \ No newline at end of file