Updates for linting and CI
continuous-integration/drone/push Build is failing Details

pull/1/head
Drew Bednar 1 year ago
parent c9f60a3661
commit c1cd5095fc

@ -1,18 +1,19 @@
kind: pipeline kind: pipeline
type: docker type: docker
name: CI Test Pipeline name: CI Test/Lint Pipeline
steps: steps:
- name: greeting
image: alpine
commands:
- echo "Welcome to drone\n"
- name: Unit Tests - name: Unit Tests
image: python:3.11-bullseye image: python:3.11-bullseye
commands: commands:
- bash -c './scripts/run_unit_tests.sh' - bash -c './scripts/run_unit_tests.sh'
- name: Lint Check
parallel: true
image: python:3.11-bullseye
commands:
- bash -c './scripts/run_lint_checks.sh'
trigger: trigger:
event: event:
- pull_request - pull_request

@ -3,6 +3,7 @@ profile = "black"
line_length = 120 line_length = 120
force_single_line = true force_single_line = true
filter_files = true filter_files = true
skip_glob = ["env/*"]
[tool.black] [tool.black]
line-length = 120 line-length = 120

@ -0,0 +1,14 @@
#! /usr/bin/env bash
set -exu
# shellcheck source=/dev/null
source "$(dirname "$0")/_common.sh"
if [ "${DRONE:-false}" == "true" ]; then
_setup_env
pip install -r dev-requirements.txt
fi
pushd "$(dirname "$0")/../"
"${VIRTUAL_ENV}/bin/python" -m invoke lint --verbose
popd

@ -1,3 +1,6 @@
import sys
from invoke import Failure
from invoke import task from invoke import task
@ -18,3 +21,37 @@ def serve_dev(c, debugger=True, reload=True, threads=True, port=8888, host="0.0.
def test(c): def test(c):
"""executes test suite""" """executes test suite"""
c.run("pytest -vvv tests/", pty=True) c.run("pytest -vvv tests/", pty=True)
@task
def lint(c, verbose=False):
"""Executes linter checks"""
exit_code = 0
c.run("echo 'Checking isort'")
try:
c.run(f"isort {'-v' if verbose else ''} --check .", pty=True)
except Failure:
exit_code = 1
c.run("echo 'Lint check black'")
try:
c.run(f"black {'-v' if verbose else ''} --check .", pty=True)
except Failure:
exit_code = 1
c.run("echo 'Lint check with ruff'")
try:
c.run(f"ruff check {'-v' if verbose else ''} .", pty=True)
except Failure:
exit_code = 1
if exit_code:
c.run("echo 'ERROR: failed lint checks' >&2 ")
sys.exit(exit_code)
@task
def delint(c):
"""Runs code formaters isort, black"""
c.run("isort .", pty=True)
c.run("black .", pty=True)

Loading…
Cancel
Save