-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathcoding-style.sh
More file actions
executable file
·34 lines (30 loc) · 1.4 KB
/
Copy pathcoding-style.sh
File metadata and controls
executable file
·34 lines (30 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
function cat_readme() {
echo ""
echo "Usage: ./coding-style.sh DELIVERY_DIR REPORTS_DIR"
echo " DELIVERY_DIR Should be the directory where your project files are"
echo " REPORTS_DIR Should be the directory where we output the reports"
echo " Take note that existing reports will be overriden"
echo ""
}
if [ $# == 1 ] && [ $1 == "--help" ]; then
cat_readme
elif [ $# = 2 ];
then
DELIVERY_DIR=$(readlink -f "$1")
REPORTS_DIR=$(readlink -f "$2")
EXPORT_FILE="$REPORTS_DIR"/coding-style-reports.log
### delete existing report file
rm -f $EXPORT_FILE
### Pull new version of docker image and clean olds
sudo docker pull ghcr.io/epitech/coding-style-checker:latest && sudo docker image prune -f
### generate reports
SELINUX_FIX=""
getenforce | grep -x "Enforcing" &>/dev/null && SELINUX_FIX=":z"
DELIVERY_VOL="${DELIVERY_DIR}:/mnt/delivery${SELINUX_FIX}"
REPORTS_VOL="${REPORTS_DIR}:/mnt/reports${SELINUX_FIX}"
sudo docker run --rm -i -v $DELIVERY_VOL -v $REPORTS_VOL ghcr.io/epitech/coding-style-checker:latest "/mnt/delivery" "/mnt/reports"
[[ -f $EXPORT_FILE ]] && echo "$(wc -l < $EXPORT_FILE) coding style error(s) reported in $EXPORT_FILE, $(grep -c ": MAJOR:" $EXPORT_FILE) major, $(grep -c ": MINOR:" $EXPORT_FILE) minor, $(grep -c ": INFO:" $EXPORT_FILE) info"
else
cat_readme
fi