Skip to content
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

Add code-style checks to Github CI Actions #3564

Merged
merged 2 commits into from
Sep 8, 2023
Merged
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
8 changes: 6 additions & 2 deletions .github/workflows/hypha-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install python dependencies
run: pip install `grep "ruff" requirements-dev.txt`
- name: Run python linting
run: pip install `grep -E "ruff|djhtml|black" requirements-dev.txt`
- name: Run ruff
run: ruff --format github .
- name: Run black
run: black . --check
- name: Run djhtml
run: djhtml hypha/ --check

test-be:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fmt:
python -m ruff --fix .
python -m black .
npx prettier . --write
djhtml hypha/

.PHONY: cov-html
cov-html:
Expand All @@ -52,9 +53,10 @@ lint:
@echo "Checking python code style with ruff"
ruff .
black . --check
@echo "Checking html file indendation."
djhtml hypha/ --check
@echo "Checking js and css code style."
npm run lint
npx prettier . --check


.PHONY: lint-fix
Expand Down
9 changes: 7 additions & 2 deletions hypha/apply/templates/forms/includes/multi_input_field.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{% load heroicons %}
<div class="form__item{% if field.help_text %} form__group--wrap{% endif %}{% if field.errors %} form__error{% endif %}{% if not field.initial %} multi-input-field-hidden{% endif %}{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"{% if is_application and field.field.group_number > 1 %} data-hidden="{% if not show_all_group_fields %}true{% else %}false{% endif %}"{% endif %}" data-multi-field-for="{{ field.field.multi_input_id }}">
<div
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file the indentation has been been mis-behaving b/w of an extra quotes after "endif"

{% endif %}" data-multi-field-for

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broke the <div> attributes into newlines to align things better and also make it readable.

class="form__item{% if field.help_text %} form__group--wrap{% endif %}{% if field.errors %} form__error{% endif %}{% if not field.initial %} multi-input-field-hidden{% endif %}{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"
{% if is_application and field.field.group_number > 1 %} data-hidden="{% if not show_all_group_fields %}true{% else %}false{% endif %}"{% endif %}
data-multi-field-for="{{ field.field.multi_input_id }}"
>
{{ field }}

{% if field.errors %}<h6 class="form__error-text">{{ field.errors.as_text|linebreaksbr }}</h6>{% endif %}
</div>

{% if field.field.multi_input_add_button %}
<button class="link link--button link--button--narrow multi-input-add-btn mt-2{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"
<button
class="link link--button link--button--narrow multi-input-add-btn mt-2{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}"
type="button" data-multi-field-id="{{ field.field.multi_input_id }}"
data-multi-visibility-index="{{ field.field.visibility_index }}"
data-multi-max-index="{{ field.field.max_index }}"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"dev:build:tailwind": "tailwindcss -i ./hypha/static_src/src/tailwind/main.css -o ./hypha/static_compiled/css/tailwind-output.css",
"dev:build:images": "npm run build:images",
"dev:build:fonts": "npm run build:fonts",
"lint:prettier": "prettier . --check",
"lint:sass": "stylelint \"hypha/static_src/src/sass/**/*.scss\"",
"lint:js": "eslint \"hypha/static_src/src/javascript/**/*.js\"",
"collectstatic": "python manage.py collectstatic --no-post-process --noinput --verbosity 0 --settings=hypha.settings.dev",
Expand Down
Loading