Add linters to scripts and drone pipeline
continuous-integration/drone/push Build is passing Details

master
Drew Bednar 1 year ago
parent 4027ad3902
commit 1f7c5a77e6

@ -4,11 +4,12 @@ type: docker
name: CI Test Pipeline
steps:
- name: Unit Tests
- name: Unit Tests and Linters
image: python:3.11-bullseye
# Todo add command for lint checks
commands:
- bash -c './scripts/run_unit_tests.sh'
- bash -xc './scripts/run_linters.sh'
- bash -xc './scripts/run_unit_tests.sh'
group: test-lint
- name: Lint Chart
image: pelotech/drone-helm3

@ -16,8 +16,17 @@ source "$(dirname "$0")/_common.sh"
function project_bootstrap() {
_setup_env
pip install -U pip pip-tools=='7.3.0'
# Check if requirements.txt exists, if not, compile it from requirements.in
if [ ! -f requirements.txt ]; then
pip-compile requirements.in
fi
# Check if dev-requirements.txt exists, if not, compile it from dev-requirements.in
if [ ! -f dev-requirements.txt ]; then
pip-compile dev-requirements.in
fi
pip-sync requirements.txt dev-requirements.txt
}

@ -0,0 +1,28 @@
#! /usr/bin/env bash
# shellcheck source=/dev/null
source "$(dirname "$0")/_common.sh"
if [ "${DRONE}" == "true" ]; then
_setup_env
pip install -r requirements.txt -r dev-requirements.txt
fi
# Run linting commands and capture their return codes
"${VIRTUAL_ENV}/bin/python3" -m isort --check ./speech_collect ./tests ./tasks.py
ISORT_EXIT_CODE=$?
"${VIRTUAL_ENV}/bin/python3" -m black --check ./speech_collect ./tests ./tasks.py
BLACK_EXIT_CODE=$?
"${VIRTUAL_ENV}/bin/python3" -m ruff ./speech_collect ./tests ./tasks.py
RUFF_EXIT_CODE=$?
# Check if any linting command failed
if [ $ISORT_EXIT_CODE -ne 0 ] || [ $BLACK_EXIT_CODE -ne 0 ] || [ $RUFF_EXIT_CODE -ne 0 ]; then
echo "Some linting checks failed"
# Exit with a non-zero status, you can choose which error code to return
exit 1
fi
echo "All linting checks passed"

@ -43,6 +43,12 @@ def build_image(c, dev=True, registry_user=None, registry_token=None, push=False
c.run(f"docker push {image_name}")
@task
def lint(c):
"""Runs all linters against the project."""
c.run("./scripts/run_linters.sh", pty=True)
@task
def delint(c):
"""Applies automated linters to project"""

Loading…
Cancel
Save