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

Lint templates #597

Merged
merged 6 commits into from
Aug 10, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: build-container
on:
push:
branches:
- 'main'
- "main"
tags:
- 'v*'
- "v*"

jobs:
docker:
Expand Down
73 changes: 36 additions & 37 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [main]
schedule:
- cron: '44 16 * * 0'
- cron: "44 16 * * 0"

jobs:
analyze:
Expand All @@ -21,41 +21,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
language: ["javascript", "python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
194 changes: 99 additions & 95 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,55 @@ name: tests

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
lint:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ 3.11 ]
python-version: [3.11]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
- uses: actions/cache@v1
with:
path: ~/.cache/pypoetry/virtualenvs
key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-
- name: Install dependencies
run: |
poetry install
- name: check format with black
run: |
poetry run black --version
poetry run black --check .
- name: check import order with isort
run: |
poetry run isort --version
poetry run isort -c .
- name: Lint with pylint
run: |
poetry run pylint --version
poetry run pylint --fail-under=9 myhpi
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
- uses: actions/cache@v1
with:
path: ~/.cache/pypoetry/virtualenvs
key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-
- name: Install dependencies
run: |
poetry install
- name: check format with black
run: |
poetry run black --version
poetry run black --check .
- name: check import order with isort
run: |
poetry run isort --version
poetry run isort -c .
- name: Lint with pylint
run: |
poetry run pylint --version
poetry run pylint --fail-under=9 myhpi
- name: Lint templates with djhtml
run: |
poetry run djhtml --version
poetry run djhtml --check myhpi

test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ 3.11, 3.12 ]
database: [ sqlite, postgres ]
python-version: [3.11, 3.12]
database: [sqlite, postgres]
include:
- database: sqlite
database_url: "sqlite:///data/db.sqlite3"
Expand All @@ -56,70 +60,70 @@ jobs:
DJANGO_SETTINGS_MODULE: myhpi.tests.settings

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
#- uses: Gr1N/setup-poetry@v4
#- uses: actions/cache@v1
# with:
# path: ~/.cache/pypoetry/virtualenvs
# key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
# restore-keys: |
# myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-
- name: Setup python venv and poetry
run: |
#sudo apt-get install python-venv
python -m venv env
source env/bin/activate
curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
- name: Install dependencies
# always install all -E extras to use a single cache
run: |
sudo apt-get install gettext
source env/bin/activate
poetry run python -m pip install setuptools -U
poetry install -E mysql -E pgsql
python tools/install_bootstrap.py
- name: Prepare files for test run
continue-on-error: true
run: |
cp .env.example .env
source env/bin/activate
poetry run python manage.py compilemessages --settings myhpi.settings
poetry run python manage.py collectstatic --settings myhpi.settings
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
#- uses: Gr1N/setup-poetry@v4
#- uses: actions/cache@v1
# with:
# path: ~/.cache/pypoetry/virtualenvs
# key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
# restore-keys: |
# myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-
- name: Setup python venv and poetry
run: |
#sudo apt-get install python-venv
python -m venv env
source env/bin/activate
curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
- name: Install dependencies
# always install all -E extras to use a single cache
run: |
sudo apt-get install gettext
source env/bin/activate
poetry run python -m pip install setuptools -U
poetry install -E mysql -E pgsql
python tools/install_bootstrap.py
- name: Prepare files for test run
continue-on-error: true
run: |
cp .env.example .env
source env/bin/activate
poetry run python manage.py compilemessages --settings myhpi.settings
poetry run python manage.py collectstatic --settings myhpi.settings

- name: Setup postgres
uses: harmon758/postgresql-action@v1
with:
postgresql version: '11' # See https://hub.docker.com/_/postgres for available versions
postgresql db: myHPI
postgresql user: user
postgresql password: pass
if: matrix.database == 'postgres'
- name: Setup postgres
uses: harmon758/postgresql-action@v1
with:
postgresql version: "11" # See https://hub.docker.com/_/postgres for available versions
postgresql db: myHPI
postgresql user: user
postgresql password: pass
if: matrix.database == 'postgres'

- name: Setup postgres dependency
run: |
source env/bin/activate
poetry run python -m pip install psycopg2
if: matrix.database == 'postgres'
- name: Setup postgres dependency
run: |
source env/bin/activate
poetry run python -m pip install psycopg2
if: matrix.database == 'postgres'

#- name: Migrate db
# run: |
# source env/bin/activate
# # python manage.py migrate --run-syncdb
#- name: Migrate db
# run: |
# source env/bin/activate
# # python manage.py migrate --run-syncdb

- name: Test apps
env:
DATABASE_URL: ${{ matrix.database_url }}
run: |
source env/bin/activate
poetry run coverage run --source=myhpi manage.py test myhpi.tests
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source env/bin/activate
pip install coveralls
coveralls --service=github
if: matrix.python-version == '3.9' && matrix.database == 'sqlite'
- name: Test apps
env:
DATABASE_URL: ${{ matrix.database_url }}
run: |
source env/bin/activate
poetry run coverage run --source=myhpi manage.py test myhpi.tests
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source env/bin/activate
pip install coveralls
coveralls --service=github
if: matrix.python-version == '3.9' && matrix.database == 'sqlite'
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3.12
repos:
- repo: https://github.com/myint/autoflake
rev: v2.2.1
rev: v2.3.1
hooks:
- id: autoflake
args:
Expand All @@ -16,9 +16,15 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/djlint/djLint
rev: v1.34.1
hooks:
- id: djlint-reformat-django
args: ["--quiet"]
- id: djlint-django
- repo: local
hooks:
- id: prettier-eslint
Expand Down
Loading
Loading