Skip to content

Commit

Permalink
ci(push): update super-linter action
Browse files Browse the repository at this point in the history
  • Loading branch information
streambinder committed Sep 3, 2024
1 parent ac9e6c8 commit f6b1b86
Show file tree
Hide file tree
Showing 27 changed files with 417 additions and 412 deletions.
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Unciæ <a href="https://github.com/streambinder/unciae"><img align="left" src="https://github.com/streambinder.png?size=96"></a>
# Unciæ <a href="https://github.com/streambinder/unciae"><img alt="documentation" align="left" src="https://github.com/streambinder.png?size=96"></a>

This is the safe place to put every mini-project worth to be kept whilst not deserving its own repository.
2 changes: 1 addition & 1 deletion .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ linters-settings:
check-blank: true
govet:
# report about shadowed variables
check-shadowing: true
shadow: true
gocyclo:
# minimal code complexity to report, 30 by default
min-complexity: 15
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker://github/super-linter:latest
- uses: super-linter/super-linter@v7.1.0
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_UNCIAE }}
VALIDATE_ALL_CODEBASE: false
Expand Down
1 change: 1 addition & 0 deletions arduino/ask_reliability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project wraps up the source code used to run Radio Frequency (RF) communica
Connect the Arduino boards via USB.
Open up `ask_transmitter.ino` and `ask_receiver.ino` as separated projects on Arduino IDE and load them to each specific board.
Follow the flow by connecting to the USB/Serial ports (`ttyUSB` ports mapping could very likely be different):

```bash
# transmitter
screen -S tx /dev/ttyUSB0; screen -X -S tx quit
Expand Down
2 changes: 1 addition & 1 deletion backup/restup/hooks/acl_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "$(realpath "$(dirname "$0")")/acl_common.sh"

mkdir -p "${DIR_ACL}"
find "${DIR_ACL}" -type f -delete
getfacl -pR / > "/var/acls/root.acl" 2> /dev/null || echo -n
getfacl -pR / >"/var/acls/root.acl" 2>/dev/null || echo -n
2 changes: 1 addition & 1 deletion backup/restup/hooks/db_common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

# shellcheck disable=SC2034
DIR_DB="/var/databases"
DIR_DB="/var/databases"
10 changes: 5 additions & 5 deletions backup/restup/hooks/db_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ source "$(realpath "$(dirname "$0")")/db_common.sh"

mkdir -p "${DIR_DB}"
find "${DIR_DB}" -type f -delete
mysql -sN -u root -p'2dkNKCVT9AgFaV8g' -e "SHOW DATABASES;" | \
grep -Ev "(Database|information_schema|performance_schema)" | \
while read -r db; do
mysqldump -u root -p'2dkNKCVT9AgFaV8g' "${db}" --add-drop-table > "${DIR_DB}/${db}.sql"
done
mysql -sN -u root -p'2dkNKCVT9AgFaV8g' -e "SHOW DATABASES;" |
grep -Ev "(Database|information_schema|performance_schema)" |
while read -r db; do
mysqldump -u root -p'2dkNKCVT9AgFaV8g' "${db}" --add-drop-table >"${DIR_DB}/${db}.sql"
done
2 changes: 1 addition & 1 deletion backup/restup/hooks/fw_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# shellcheck disable=SC2034
FW_FNAME="/etc/sysconfig/iptables"
IPTABLES_SAVE="/sbin/iptables-save"
IPTABLES_SAVE="/sbin/iptables-save"
2 changes: 1 addition & 1 deletion backup/restup/hooks/fw_pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# shellcheck disable=SC1090,SC1091
source "$(realpath "$(dirname "$0")")/fw_common.sh"

"${IPTABLES_SAVE}" > "${FW_FNAME}"
"${IPTABLES_SAVE}" >"${FW_FNAME}"
10 changes: 5 additions & 5 deletions backup/restup/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __validate_config(self):
for t in self.tasks:
for mandatory_token in ["repository", "password", "path"]:
if mandatory_token not in t or t[mandatory_token] is None:
raise Exception(
raise RuntimeError(
"{} key is mandatory for a task object".format(mandatory_token)
)
for recommended_token in ["retention"]:
Expand All @@ -43,15 +43,15 @@ def __validate_config(self):
path_checks += ["postspawn"] if "postspawn" in t else []
for path_entry in path_checks:
if not os.path.exists(t[path_entry]):
raise Exception(
raise RuntimeError(
"{} path {} does not exist".format(path_entry, t[path_entry])
)

def __wait(self):
for thread in self.__threads:
thread.join()

def __t_print(self, payload, file=sys.stdout):
def __t_print(self, payload):
try:
self.__mutex.acquire()
if isinstance(payload, (bytes, bytearray)):
Expand Down Expand Up @@ -165,7 +165,7 @@ def run(self):
cfg_path = sys.argv[1]

try:
with open(cfg_path, "r") as yml_stream:
with open(cfg_path, "r", encoding="utf-8") as yml_stream:
Restup(yaml.safe_load(yml_stream)).run()
except Exception as e:
except OSError as e:
print(e, file=sys.stderr)
32 changes: 16 additions & 16 deletions git/committer-changer/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# auxiliary functions

function help() {
echo -e "Usage:\n\t$(basename "$0") old@committ.er new_committer_name:new@committ.er"
exit 0
echo -e "Usage:\n\t$(basename "$0") old@committ.er new_committer_name:new@committ.er"
exit 0
}
function rprint() { echo -en "\r\e[0K$*"; }
function pprint() { echo -e "\r\e[0K$*"; }
Expand All @@ -14,19 +14,19 @@ function pprint() { echo -e "\r\e[0K$*"; }
# arguments parsing

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
help
;;
*)
if [ -z "${COMMITTER_OLD}" ]; then
COMMITTER_OLD=$1
else
COMMITTER_NEW=$1
fi
;;
esac
shift
case "$1" in
-h | --help)
help
;;
*)
if [ -z "${COMMITTER_OLD}" ]; then
COMMITTER_OLD=$1
else
COMMITTER_NEW=$1
fi
;;
esac
shift
done

# arguments validation
Expand All @@ -35,7 +35,7 @@ COMMITTER_NEW_NAME="$(awk -F':' '{print $1}' <<<"${COMMITTER_NEW}")"
COMMITTER_NEW_EMAIL="$(awk -F':' '{print $2}' <<<"${COMMITTER_NEW}")"

if [ -z "${COMMITTER_OLD}" ] || [ -z "${COMMITTER_NEW_NAME}" ] || [ -z "${COMMITTER_NEW_EMAIL}" ]; then
help
help
fi

# effective script
Expand Down
16 changes: 8 additions & 8 deletions git/history-touchup/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# auxiliary functions

function help() {
echo -e "Usage:\n\t$(basename "$0")"
exit 0
echo -e "Usage:\n\t$(basename "$0")"
exit 0
}
function rprint() { echo -en "\r\e[0K$*"; }
function pprint() { echo -e "\r\e[0K$*"; }
Expand All @@ -14,12 +14,12 @@ function pprint() { echo -e "\r\e[0K$*"; }
# arguments parsing

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
help
;;
esac
shift
case "$1" in
-h | --help)
help
;;
esac
shift
done

# arguments validation
Expand Down
2 changes: 1 addition & 1 deletion image/reasize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Finally, to apply resize in both directions:
reasize/runner.sh -t /path/to/images 1024x768
```

Omitting `-t`/`--target` flag will let the tool use the current working directory.
Omitting `-t`/`--target` flag will let the tool use the current working directory.
98 changes: 49 additions & 49 deletions image/reasize/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# auxiliary functions

function help() {
echo -e "Usage:\n\t$(basename "$0") <MAX_WIDTHxMAX_HEIGHT> [-t <path>]"
exit 0
echo -e "Usage:\n\t$(basename "$0") <MAX_WIDTHxMAX_HEIGHT> [-t <path>]"
exit 0
}
function rprint() { echo -en "\r\e[0K$*"; }
function pprint() { echo -e "\r\e[0K$*"; }
Expand All @@ -14,73 +14,73 @@ function pprint() { echo -e "\r\e[0K$*"; }
# arguments parsing

while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
help
;;
-t | --target)
TARGET="$2"
shift
;;
*)
SIZE=$1
;;
esac
shift
case "$1" in
-h | --help)
help
;;
-t | --target)
TARGET="$2"
shift
;;
*)
SIZE=$1
;;
esac
shift
done

# arguments validation

if [ -z "${TARGET}" ]; then
TARGET="$(pwd)"
TARGET="$(pwd)"
fi

if [ -z "${SIZE}" ]; then
help
help
fi

SIZE_W="$(awk -F'x' '{print $1}' <<<"${SIZE,,}" | xargs)"
SIZE_H="$(awk -F'x' '{print $2}' <<<"${SIZE,,}" | xargs)"

if [ -z "${SIZE_W}" ] && [ -z "${SIZE_H}" ]; then
echo "At least a resolution argument must be given"
exit 1
echo "At least a resolution argument must be given"
exit 1
fi

# effective script

find "${TARGET}" -type f -exec file {} \; | grep -o -P '^.+: \w+ image' | awk -F':' '{print $1}' | while read -r fname; do

pname="${fname//${TARGET}\//}"
rprint "Checking ${pname}"

# get image data

if ! img_data="$(exiftool "${fname}")"; then
continue
fi

# get image resolution
img_res_w="$(awk -F': ' '/^Image Width/ {print $2}' <<<"${img_data}" | xargs)"
img_res_h="$(awk -F': ' '/^Image Height/ {print $2}' <<<"${img_data}" | xargs)"
if [ -z "${img_res_w}" ] || [ -z "${img_res_h}" ]; then
continue
fi

# calculate resize
img_res=""
if [ -n "${SIZE_W}" ] && [ "${img_res_w}" -gt "${SIZE_W}" ]; then
img_res="${SIZE_W}x"
fi
if [ -n "${SIZE_H}" ] && [ -z "${img_res}" ] && [ "${img_res_h}" -gt "${SIZE_H}" ]; then
img_res="x${SIZE_H}"
fi

# process resize
if [ -n "${img_res}" ]; then
pprint "Resizing ${pname} to ${img_res} from ${img_res_w}x${img_res_h} ($(du -sh "${fname}" | awk '{print $1}'))"
mogrify -resize "${img_res}" "${fname}"
fi
pname="${fname//${TARGET}\//}"
rprint "Checking ${pname}"

# get image data

if ! img_data="$(exiftool "${fname}")"; then
continue
fi

# get image resolution
img_res_w="$(awk -F': ' '/^Image Width/ {print $2}' <<<"${img_data}" | xargs)"
img_res_h="$(awk -F': ' '/^Image Height/ {print $2}' <<<"${img_data}" | xargs)"
if [ -z "${img_res_w}" ] || [ -z "${img_res_h}" ]; then
continue
fi

# calculate resize
img_res=""
if [ -n "${SIZE_W}" ] && [ "${img_res_w}" -gt "${SIZE_W}" ]; then
img_res="${SIZE_W}x"
fi
if [ -n "${SIZE_H}" ] && [ -z "${img_res}" ] && [ "${img_res_h}" -gt "${SIZE_H}" ]; then
img_res="x${SIZE_H}"
fi

# process resize
if [ -n "${img_res}" ]; then
pprint "Resizing ${pname} to ${img_res} from ${img_res_w}x${img_res_h} ($(du -sh "${fname}" | awk '{print $1}'))"
mogrify -resize "${img_res}" "${fname}"
fi

done

Expand Down
Loading

0 comments on commit f6b1b86

Please sign in to comment.