Skip to content

Commit 05c8b50

Browse files
Merge pull request #26 from tutorcruncher/github-actions
Setup Github Actions
2 parents 225f755 + 46f8543 commit 05c8b50

File tree

8 files changed

+89
-15
lines changed

8 files changed

+89
-15
lines changed

.github/workflows/tests.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Tests
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.9
16+
17+
- name: Install Dependencies
18+
run: make install
19+
20+
- name: Lint
21+
run: make lint
22+
23+
- name: Tests
24+
run: make test
25+
26+
publish:
27+
needs: test
28+
if: "success() && startsWith(github.ref, 'refs/tags/')"
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: set up python
34+
uses: actions/setup-python@v1
35+
with:
36+
python-version: '3.9'
37+
38+
- name: install
39+
run: |
40+
make install
41+
pip install -U wheel twine
42+
- name: build
43+
run: python setup.py sdist bdist_wheel
44+
45+
- run: twine check dist/*
46+
47+
- name: upload to pypi
48+
run: twine upload dist/*
49+
env:
50+
TWINE_USERNAME: __token__
51+
TWINE_PASSWORD: ${{ secrets.pypi_password }}

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
black = black -S -l 120 --target-version py39
2+
3+
.PHONY: install
4+
install:
5+
pip install --progress-bar off -r requirements.txt
6+
7+
.PHONY: black
8+
black:
9+
$(black) tests/
10+
11+
.PHONY: lint
12+
lint:
13+
flake8 tests/
14+
$(black) --check tests/
15+
16+
.PHONY: test
17+
test:
18+
tox

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black==22.6.0
2+
django>=1.10
3+
flake8==5.0.4
4+
tox==3.25.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pypandoc
77
long_description = pypandoc.convert('README.md', 'rst')
88

9-
VERSION = '2.8.2'
9+
VERSION = '2.8.3'
1010

1111
setup(
1212
name='django-bootstrap3-datetimepicker-2',

tests/legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ def build_attrs(self, base_attrs=None, extra_attrs=None, **kwargs):
1212

1313

1414
def is_legacy():
15-
x,y,z = [int(v) for v in django.__version__.split(".")]
15+
x, y, z = [int(v) for v in django.__version__.split(".")]
1616
return x == 1 and y < 11

tests/test_widgets.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,14 @@
88
def test_rendering():
99
options = {"pickTime": True, "format": "YYYY-MM-DD HH:mm"}
1010
widget = (DateTimePickerDjango110 if is_legacy() else DateTimePicker)(options=options)
11-
expected_output = '\n <div class="input-group date" id="_pickers">\n <input class="form-control" name="a" type="text" value="b"/>\n <span class="input-group-addon">\n <span class="glyphicon glyphicon-calendar"></span>\n </span>\n </div>\n <script>\n (function(window) {\n var callback = function() {\n $(function(){$("#_pickers:has(input:not([readonly],[disabled]))").datetimepicker(%s);});\n };\n if(window.addEventListener)\n window.addEventListener("load", callback, false);\n else if (window.attachEvent)\n window.attachEvent("onload", callback);\n else window.onload = callback;\n })(window);\n </script>'
11+
expected_output = (
12+
'\n <div class="input-group date" id="_pickers">\n <input class="form-control" name="a" type="text"'
13+
' value="b"/>\n <span class="input-group-addon">\n <span class="glyphicon'
14+
' glyphicon-calendar"></span>\n </span>\n </div>\n <script>\n (function(window) {\n '
15+
' var callback = function() {\n '
16+
' $(function(){$("#_pickers:has(input:not([readonly],[disabled]))").datetimepicker(%s);});\n };\n '
17+
' if(window.addEventListener)\n window.addEventListener("load", callback, false);\n '
18+
' else if (window.attachEvent)\n window.attachEvent("onload", callback);\n else'
19+
' window.onload = callback;\n })(window);\n </script>'
20+
)
1221
assert widget.render("a", "b", {}) == expected_output % json.dumps(options)

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ deps =
1515
django40: django==4.0.*
1616
setenv =
1717
PYTHONPATH = {toxinidir}
18+
19+
[flake8]
20+
max-line-length = 120
21+
max-complexity = 10

0 commit comments

Comments
 (0)