osmith has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-ci/+/39912?usp=email )
Change subject: lint: run 'ruff' on various repositories
......................................................................
lint: run 'ruff' on various repositories
Lint the python code with "ruff check" and "ruff format" where they
are
known to pass.
Related:
https://docs.astral.sh/ruff/
Change-Id: I5c2ede1a7b2a204ca3deb24c55008c7585c289a0
---
M lint/lint_diff.sh
1 file changed, 45 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/12/39912/1
diff --git a/lint/lint_diff.sh b/lint/lint_diff.sh
index 4b95b9f..408d79f 100755
--- a/lint/lint_diff.sh
+++ b/lint/lint_diff.sh
@@ -4,12 +4,21 @@
GIT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || true)"
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
ERROR=0
+PROJECT="${GERRIT_PROJECT}"
if [ "$OSMO_LINT" = 0 ]; then
echo "Skipping lint_diff.sh (OSMO_LINT=0)"
exit 0
fi
+get_project() {
+ if [ -n "$PROJECT" ] || ! [ -e .gitreview ]; then
+ return
+ fi
+
+ PROJECT="$(grep project= .gitreview | cut -d = -f2)"
+}
+
check_git_dir() {
if [ -z "$GIT_DIR" ]; then
echo "ERROR: path is not a git repository: $PWD"
@@ -70,6 +79,40 @@
fi
}
+test_ruff() {
+ local i
+ local check_projects="
+ osmo-ci
+ osmo-dev
+ osmo-ttcn3-hacks
+ "
+ local format_projects="
+ osmo-ttcn3-hacks
+ "
+
+ if ! command -v ruff >/dev/null; then
+ return
+ fi
+
+ for i in $check_projects; do
+ if [ "$i" = "$PROJECT" ]; then
+ echo "Running 'ruff check'..."
+ echo
+ ruff check
+ break
+ fi
+ done
+
+ for i in $format_projects; do
+ if [ "$i" = "$PROJECT" ]; then
+ echo "Running 'ruff format --diff'..."
+ echo
+ ruff format --diff
+ break
+ fi
+ done
+}
+
show_error() {
echo
echo "Please fix the linting errors above. More information:"
@@ -106,8 +149,10 @@
< gerrit_report.json
}
+get_project
check_git_dir
set_commit
+test_ruff
test_docker_run_rm
test_checkpatch
test_clang_format
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ci/+/39912?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I5c2ede1a7b2a204ca3deb24c55008c7585c289a0
Gerrit-Change-Number: 39912
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>