Skip to content

Commit

Permalink
Merge pull request #26 from tutorcruncher/github-actions
Browse files Browse the repository at this point in the history
Setup Github Actions
  • Loading branch information
JonathanMarriott authored Aug 8, 2022
2 parents 225f755 + 46f8543 commit 05c8b50
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 15 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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.9

- 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.9'

- 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 }}
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
black==22.6.0
django>=1.10
flake8==5.0.4
tox==3.25.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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>'
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>'
)
assert widget.render("a", "b", {}) == expected_output % json.dumps(options)
4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ deps =
django40: django==4.0.*
setenv =
PYTHONPATH = {toxinidir}

[flake8]
max-line-length = 120
max-complexity = 10

0 comments on commit 05c8b50

Please sign in to comment.