Skip to content

Commit b85dc3f

Browse files
committed
Updated lint action
1 parent 47266d4 commit b85dc3f

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

scripts/check_isort

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
#! /bin/bash -e
1+
#! /bin/bash
22

33
ROOT_DIR="$(git rev-parse --show-toplevel)"
44
source "${ROOT_DIR}/scripts/helpers"
55

6+
header "Checking imports order with isort"
7+
68
if [ -n "$(check_if_installed docker)" ]; then
7-
docker run -v "${PWD}:/code" sergioteula/pytools isort -c .
9+
docker run -v "${PWD}:/code" sergioteula/pytools isort -c --color .
810
elif [ -n "$(check_if_installed isort)" ]; then
9-
isort -c .
11+
isort -c --color .
12+
else
13+
error "isort is not installed"
14+
exit 1
15+
fi
16+
17+
EXIT_CODE="$?"
18+
if [ "$EXIT_CODE" = "0" ]; then
19+
success "Imports are correctly ordered"
1020
else
11-
echo "Please install Docker or isort"
21+
error "Imports order is not correct"
1222
exit 1
1323
fi

scripts/helpers

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
#! /bin/bash -e
22

3+
BLUE="\033[0;34m"
4+
GREEN="\033[0;32m"
5+
RED="\033[0;31m"
6+
YELLOW="\033[0;33m"
7+
NC="\033[0m"
8+
LINE="--------------------------------------------------------------------"
9+
310
check_if_installed() {
411
if [ -x "$(command -v "${1}")" ]; then
512
echo "${1} is installed"
613
fi
714
}
15+
16+
header(){
17+
echo -e "\n${BLUE}${*}\n${LINE}${NC}"
18+
}
19+
20+
subheader(){
21+
echo -e "\n${BLUE}# ${*}${NC}"
22+
}
23+
24+
warning(){
25+
echo -e "${YELLOW}WARNING: ${*}${NC}\n"
26+
}
27+
28+
error(){
29+
echo -e "${RED}ERROR: ${*}${NC}\n"
30+
}
31+
32+
success(){
33+
echo -e "${GREEN}${*}${NC}\n"
34+
}

0 commit comments

Comments
 (0)