Skip to content

Commit 57c186c

Browse files
Write and setup tests with CI (GH-4)
2 parents 3eda89d + beb3429 commit 57c186c

File tree

12 files changed

+149
-5
lines changed

12 files changed

+149
-5
lines changed

.github/workflows/tests.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
12+
strategy:
13+
matrix:
14+
include:
15+
- python: "3.6"
16+
env: py36-django32
17+
os: ubuntu-20.04 # 3.6 is not available on ubuntu-20.04
18+
- python: "3.8"
19+
env: py38-django32
20+
- python: "3.10"
21+
env: py310-django32
22+
23+
- python: "3.8"
24+
env: py38-django40
25+
- python: "3.9"
26+
env: py39-django40
27+
- python: "3.10"
28+
env: py310-django40
29+
30+
- python: "3.9"
31+
env: py39-django41
32+
- python: "3.10"
33+
env: py310-django41
34+
- python: "3.11"
35+
env: py311-django41
36+
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: Set up Python ${{ matrix.python }}
40+
uses: actions/setup-python@v2
41+
with:
42+
python-version: ${{ matrix.python }}
43+
- name: Install dependencies
44+
run: |
45+
pip install --upgrade pip
46+
python -m pip install -e .
47+
pip install tox tox-gh-actions
48+
- name: Run tests using tox
49+
run: tox -e ${{ matrix.env }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
2+
.tox
23
*.egg-info
34
mermaid.js

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,35 @@ Django template tag for showing mermaid diagrams.
55
[![PyPI](https://img.shields.io/pypi/v/django-mermaid.svg)](https://pypi.org/project/django-mermaid/)
66
[![License](https://img.shields.io/pypi/l/django-mermaid.svg)](https://github.com/ArtyomVancyan/django-mermaid/blob/master/LICENSE)
77
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://makeapullrequest.com)
8+
[![Tests](https://github.com/ArtyomVancyan/django-mermaid/actions/workflows/tests.yml/badge.svg)](https://github.com/ArtyomVancyan/django-mermaid/actions/workflows/tests.yml)
89

910
## Install
1011

1112
```shell
1213
python -m pip install django-mermaid
1314
```
1415

16+
## Configuration
17+
18+
Add the `django_mermaid.apps.MermaidConfig` to your `INSTALLED_APPS` setting:
19+
20+
```python
21+
INSTALLED_APPS = [
22+
..., # other apps
23+
'django_mermaid.apps.MermaidConfig',
24+
]
25+
```
26+
27+
## Usage
28+
29+
Once you have installed the app, you can use the `mermaid` template tag in your templates.
30+
31+
```html
32+
{% load mermaid %}
33+
34+
{% mermaid "graph LR; A-->B;" %}
35+
```
36+
1537
## Contribute
1638

1739
Any contribution is welcome. If you have any ideas or suggestions, feel free to open an issue or a pull request. And

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools>=42.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.pytest.ini_options]
6+
testpaths = ["tests"]
7+
filterwarnings = ["ignore::DeprecationWarning"]

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ packages =
2828
install_requires =
2929
urllib3
3030
Django
31+
include_package_data = yes
3132
package_dir =
3233
=src
3334
zip_safe = no

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from distutils import dir_util
12
from os.path import dirname, join
23
from urllib.request import urlretrieve
34

45
from setuptools import setup
56

67
if __name__ == "__main__":
7-
urlretrieve(
8-
"https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.4.3/mermaid.js",
9-
join(dirname(__file__), "src", "django_mermaid", "static", "mermaid.js")
10-
)
8+
cdn = "https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.4.3/mermaid.js"
9+
static = join(dirname(__file__), "src", "django_mermaid", "static")
10+
dir_util.create_tree(static, ["mermaid.js"])
11+
urlretrieve(cdn, join(static, "mermaid.js"))
1112
setup()

src/django_mermaid/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.1"
1+
__version__ = "0.0.2"

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from django.conf import settings
2+
3+
4+
def pytest_configure():
5+
settings.configure(
6+
INSTALLED_APPS=[
7+
"django_mermaid.apps.MermaidConfig"
8+
],
9+
TEMPLATES=[
10+
{
11+
"BACKEND": "django.template.backends.django.DjangoTemplates",
12+
},
13+
]
14+
)

tests/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tox==3.24.3
2+
pytest==6.2.5
3+
pytest-django==4.5.2

0 commit comments

Comments
 (0)