Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Formatter and linter for more file types #522

Draft
wants to merge 10 commits into
base: staging
Choose a base branch
from
Draft
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
20 changes: 11 additions & 9 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a bug report to help us improve
title: ''
title: ""
labels: bug, contribution
assignees: maltezacharias

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
title: ""
labels: contribution
assignees: ''

assignees: ""
---
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
title: ""
labels: contribution
assignees: maltezacharias

---

**Is your feature request related to a problem? Please describe.**
Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
**Topic:**
*Please describe what this pull request does/improves/fixes in a short sentence*
_Please describe what this pull request does/improves/fixes in a short sentence_

**Relevant issues:**
*Consider using the 'Closes' keyword in order to automatically close the issue upon merge.*
_Consider using the 'Closes' keyword in order to automatically close the issue upon merge._

**Further description:**

Expand Down
153 changes: 77 additions & 76 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,97 +7,98 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: Install gettext
run: sudo apt-get update && sudo apt-get install gettext
- name: Cache python packages
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r ./backend/requirements.txt
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: Install gettext
run: sudo apt-get update && sudo apt-get install gettext
- name: Cache python packages
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r ./backend/requirements.txt

- name: Generate updated .po file
run: django-admin makemessages -l en --no-location
- name: Generate updated .po file
run: django-admin makemessages -l en --no-location

- name: "[TEST] Check for fuzzy translations"
id: fuzzy_translations
continue-on-error: true
run: bash -c 'if [ $(cat ./backend/locale/en/LC_MESSAGES/django.po | grep "#, fuzzy" | wc -l) -gt 0 ];
then echo "Unresolved fuzzy translations are present"; exit 1; fi'
- name: "[TEST] Check for fuzzy translations"
id: fuzzy_translations
continue-on-error: true
run:
bash -c 'if [ $(cat ./backend/locale/en/LC_MESSAGES/django.po | grep "#, fuzzy" | wc -l) -gt 0 ];
then echo "Unresolved fuzzy translations are present"; exit 1; fi'

- name: "[TEST] Check for missing translations"
id: missing_translations
continue-on-error: true
# https://stackoverflow.com/a/14799019/3342058
run: |
if [ $(awk '$NF == "msgstr \"\"" { c++ } END { print c ? c : "0" }' FS="\n" RS= ./backend/locale/en/LC_MESSAGES/django.po) -gt 0 ];
then echo "Missing translations are present"; exit 1;
fi
- name: "[TEST] Check for missing translations"
id: missing_translations
continue-on-error: true
# https://stackoverflow.com/a/14799019/3342058
run: |
if [ $(awk '$NF == "msgstr \"\"" { c++ } END { print c ? c : "0" }' FS="\n" RS= ./backend/locale/en/LC_MESSAGES/django.po) -gt 0 ];
then echo "Missing translations are present"; exit 1;
fi

# Workaround because continue-on-error does not fail test
- name: Stop if tests failed
run: |
echo "Tests failed. Please check the individual test logs for more details"
exit 1
if: ${{ steps.fuzzy_translations.outcome == 'failure' || steps.missing_translations.outcome == 'failure' }}
# Workaround because continue-on-error does not fail test
- name: Stop if tests failed
run: |
echo "Tests failed. Please check the individual test logs for more details"
exit 1
if: ${{ steps.fuzzy_translations.outcome == 'failure' || steps.missing_translations.outcome == 'failure' }}

test-migrations:
name: Test if makemigrations was executed
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: Cache python packages
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r ./backend/requirements.txt
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: Cache python packages
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r ./backend/requirements.txt

- name: "[TEST] Check if migrations were made"
run: PYTHONPATH="./backend:$PYTHONPATH" django-admin makemigrations --settings=match4healthcare.settings.development --check --dry-run
- name: "[TEST] Check if migrations were made"
run: PYTHONPATH="./backend:$PYTHONPATH" django-admin makemigrations --settings=match4healthcare.settings.development --check --dry-run

test-code-style:
name: Test if code is properly formatted
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: Cache python packages
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r ./backend/requirements.txt
- name: set PY
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
- name: Cache pre-commit libraries
uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml', '.flake8', '.isort.cfg') }}
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- name: Cache python packages
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r ./backend/requirements.txt
- name: set PY
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
- name: Cache pre-commit libraries
uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml', '.flake8', '.isort.cfg') }}

- name: "[TEST] Check if code was properly formatted"
uses: pre-commit/action@v1.0.1
- name: "[TEST] Check if code was properly formatted"
uses: pre-commit/action@v1.0.1
1 change: 1 addition & 0 deletions .jinjalint.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
indent_size = 2
111 changes: 64 additions & 47 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,64 +1,81 @@
exclude: |
(?x)(
^backend/backups/|
^backend/run/|
^database/backups/|
^database/data/
)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: end-of-file-fixer
exclude: |
(?x)(
^backend/static/|
^backend/backups/|
^backend/run/|
^database/backups/|
^database/data/
)
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: end-of-file-fixer
exclude: ^backend/static/
- id: requirements-txt-fixer
- id: trailing-whitespace
exclude: ^backend/static/
# Note that this does not mix with git setup check-in LF check-out CRLF,
# see https://github.com/pre-commit/pre-commit-hooks#mixed-line-ending
- id: mixed-line-ending
exclude: ^backend/static/
# Note that this does not mix with git setup check-in LF check-out CRLF,
# see https://github.com/pre-commit/pre-commit-hooks#mixed-line-ending
- id: mixed-line-ending
args: [--fix=lf]
exclude: |
(?x)(
^backend/static/|
^backend/backups/|
^backend/run/|
^database/backups/|
^database/data/
)
- repo: https://github.com/timothycrosley/isort
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
hooks:
- id: isort
# args: [--filter-files]
# use black or autopep8 to automatically format files to pep8
- repo: https://github.com/psf/black
# use black or autopep8 to automatically format files to pep8
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
- id: black
args: [--line-length=100]
language_version: python3
exclude: |
(?x)(
^backend/apps/[a-z]*/migrations/[0-9A-z]*.py|
^backend/backups/|
^backend/run/|
^database/backups/|
^database/data/
)
- repo: https://gitlab.com/pycqa/flake8
(?x)(
^backend/apps/[a-z]*/migrations/[0-9A-z]*.py
)
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
additional_dependencies: [flake8-import-order,flake8-builtins,flake8-docstrings,flake8-logging-format,flake8-todos]
- id: flake8
additional_dependencies:
[
flake8-import-order,
flake8-builtins,
flake8-docstrings,
flake8-logging-format,
flake8-todos,
]
exclude: |
(?x)(
^backend/apps/[a-z]*/migrations/[0-9A-z]*.py|
^backend/backups/|
^backend/run/|
^database/backups/|
^database/data/
)
(?x)(
^backend/apps/[a-z]*/migrations/[0-9A-z]*.py
)
- repo: https://github.com/prettier/prettier
rev: 2.0.5
hooks:
- id: prettier
args: [--loglevel=warn]
files: "\\.(\
css|less|scss\
|js|jsx\
|md|markdown|mdown|mkdn\
|yaml|yml\
)$"
exclude: |
(?x)(
^[0-9A-z/_\-\.]*.min.js|
^[0-9A-z/_\-\.]*.min.css|
^backend/static/css/[0-9A-z/_\-\.]*[0-9]|
^backend/static/js/[0-9A-z/_\-\.]*[0-9]
)
- repo: https://github.com/motet-a/jinjalint
rev: master
hooks:
- id: jinjalint
args: [--config=.jinjalint.cfg]
types: [file] # restore the default `types` matching
files: \.html$
Loading