Skip to content

WIP: Frontend tests #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'standard'
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
}
}
32 changes: 12 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [ 3.5, 3.6, 3.7 ]
python: [ "3.6", "3.7", "3.8", "3.9", "3.10" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: pip install tox tox-gh-actions
- name: Run tests
run: tox
- name: Coverage
if: ${{ matrix.python == 3.7 }}
run: |
pip install coverage[toml] django==2.0
coverage run manage.py test --settings=test_settings
- name: Upload coverage
if: ${{ matrix.python == 3.7 }}
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python }}
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: lint

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
dist/
env/
demo/__pycache__/
demo/build/
*.sqlite3
.direnv/
node_modules/
.envrc
package.json
package-lock.json
.tox/
91 changes: 91 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
default_language_version:
python: python3.10
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-ast
- id: check-merge-conflict
- id: check-case-conflict
- id: detect-private-key
- id: check-added-large-files
- id: check-json
- id: check-symlinks
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
args: [--fix=lf]
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.0.1
hooks:
- id: reorder-python-imports
args:
- --py3-plus
- --application-directories=.:src
exclude: migrations/
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: rst-backticks
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: pyupgrade
args:
- --py310-plus
exclude: migrations/
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.4.0
hooks:
- id: django-upgrade
args:
- --target-version=4.0
- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.2.2
hooks:
- id: add-trailing-comma
args:
- --py36-plus
- repo: https://github.com/hadialqattan/pycln
rev: v1.2.5
hooks:
- id: pycln
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: |
(?x)^(
.*/migrations/.*
)$
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-tidy-imports
- flake8-print
args: [--max-line-length=120]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.25.0
hooks:
- id: eslint
args: [--fix]
additional_dependencies:
- "eslint@8.25.0"
- "eslint-plugin-prettier@4.2.1"
- "eslint-config-standard@17.0.0"
- "eslint-plugin-import@2.26.0"
- "eslint-plugin-n@15.3.0"
- "eslint-plugin-promise@6.1.0"
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To run the demo project for testing::

$ git clone git://github.com/jojax/django-js-error-hook.git
$ cd django-js-error-hook
$ virtualenv env --python=python3
$ python -m venv env
$ source env/bin/activate
(env) $ pip install -e .
(env) $ pip install -e demo
Expand Down Expand Up @@ -92,7 +92,10 @@ Then install the urls::

In your template, simply add the js_error_hook script::

<script type="text/javascript" src="{% url 'js-error-handler-js' %}"></script>
<script type="text/javascript">
var djangoJSErrorHandlerUrl = "{% url 'js-error-handler' %}";
</script>
<script type="text/javascript" defer src="{% static 'django_js_error_hook/utils.js' %}"></script>

Now every JavaScript error will be logged in your logging error stream. (Mail, Sentry, ...)

Expand All @@ -106,4 +109,3 @@ against various versions of Python and Django:

pip install tox
tox

2 changes: 1 addition & 1 deletion demo/demoproject/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def main():
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
"forget to activate a virtual environment?",
) from exc
execute_from_command_line(sys.argv)

Expand Down
Loading