Skip to content

Commit e0b74f5

Browse files
rst0gitavagin
authored andcommitted
make: replace flake8 with ruff
Ruff (https://github.com/astral-sh/ruff) is a Python linter written in Rust, designed to replace Flake8. It is significantly faster and actively maintained. In addition to replacing flake8 with ruff, this patch also creates separate makefile targets for ruff, shellcheck and codespell, so that they can be tested independently. RUFF_FLAGS can be used to specify options such as '--fix'. Example: make lint make ruff RUFF_FLAGS=--fix Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
1 parent 7fd4a15 commit e0b74f5

File tree

11 files changed

+33
-26
lines changed

11 files changed

+33
-26
lines changed

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ task:
3636
ln -sf /usr/include/google/protobuf/descriptor.proto images/google/protobuf/descriptor.proto
3737
dnf config-manager --set-enabled crb # Same as CentOS 8 powertools
3838
dnf -y install epel-release epel-next-release
39-
dnf -y install --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python-devel python-PyYAML python-protobuf python-junit_xml python3-importlib-metadata python-flake8 xmlto libdrm-devel
39+
dnf -y install --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python-devel python-PyYAML python-protobuf python-junit_xml python3-importlib-metadata xmlto libdrm-devel
4040
# The image has a too old version of nettle which does not work with gnutls.
4141
# Just upgrade to the latest to make the error go away.
4242
dnf -y upgrade nettle nettle-devel
@@ -111,7 +111,7 @@ task:
111111
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm || :
112112
yum install -y dnf-plugins-core
113113
yum config-manager --set-enabled powertools
114-
yum install -y --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python3-devel python3-flake8 python3-PyYAML python3-protobuf python3-importlib-metadata python3-junit_xml xmlto libdrm-devel
114+
yum install -y --allowerasing asciidoc gcc git gnutls-devel libaio-devel libasan libcap-devel libnet-devel libnl3-devel libbsd-devel libselinux-devel make protobuf-c-devel protobuf-devel python3-devel python3-PyYAML python3-protobuf python3-importlib-metadata python3-junit_xml xmlto libdrm-devel
115115
alternatives --set python /usr/bin/python3
116116
systemctl stop sssd
117117
# Even with selinux in permissive mode the selinux tests will be executed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
image: registry.fedoraproject.org/fedora:latest
1515
steps:
1616
- name: Install tools
17-
run: sudo dnf -y install git make python3-flake8 xz clang-tools-extra which codespell git-clang-format ShellCheck
17+
run: sudo dnf -y install git make ruff xz clang-tools-extra which codespell git-clang-format ShellCheck
1818

1919
- uses: actions/checkout@v2
2020

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Other conventions can be learned from the source code itself. In short, make sur
5959

6060
Important: These tools are there to advise you, but should not be considered as a "source of truth", as tools also make nasty mistakes from time to time which can completely break code readability.
6161

62-
The following command can be used to automatically run a code linter for Python files (flake8), Shell scripts (shellcheck),
62+
The following command can be used to automatically run a code linter for Python files (ruff), Shell scripts (shellcheck),
6363
text spelling (codespell), and a number of CRIU-specific checks (usage of print macros and EOL whitespace for C files).
6464

6565
```

Makefile

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -426,20 +426,23 @@ help:
426426
@echo ' amdgpu_plugin - Make AMD GPU plugin'
427427
.PHONY: help
428428

429-
lint:
430-
flake8 --version
431-
flake8 --config=scripts/flake8.cfg test/zdtm.py
432-
flake8 --config=scripts/flake8.cfg test/inhfd/*.py
433-
flake8 --config=scripts/flake8.cfg test/others/rpc/config_file.py
434-
flake8 --config=scripts/flake8.cfg lib/pycriu/images/pb2dict.py
435-
flake8 --config=scripts/flake8.cfg lib/pycriu/images/images.py
436-
flake8 --config=scripts/flake8.cfg scripts/criu-ns
437-
flake8 --config=scripts/flake8.cfg test/others/criu-ns/run.py
438-
flake8 --config=scripts/flake8.cfg crit/*.py
439-
flake8 --config=scripts/flake8.cfg crit/crit/*.py
440-
flake8 --config=scripts/flake8.cfg scripts/uninstall_module.py
441-
flake8 --config=scripts/flake8.cfg coredump/ coredump/coredump
442-
flake8 --config=scripts/flake8.cfg scripts/github-indent-warnings.py
429+
ruff:
430+
@ruff --version
431+
ruff ${RUFF_FLAGS} --config=scripts/ruff.toml \
432+
test/zdtm.py \
433+
test/inhfd/*.py \
434+
test/others/rpc/config_file.py \
435+
lib/pycriu/images/pb2dict.py \
436+
lib/pycriu/images/images.py \
437+
scripts/criu-ns \
438+
test/others/criu-ns/run.py \
439+
crit/*.py \
440+
crit/crit/*.py \
441+
scripts/uninstall_module.py \
442+
coredump/ coredump/coredump \
443+
scripts/github-indent-warnings.py
444+
445+
shellcheck:
443446
shellcheck --version
444447
shellcheck scripts/*.sh
445448
shellcheck scripts/ci/*.sh scripts/ci/apt-install
@@ -448,7 +451,11 @@ lint:
448451
shellcheck -x test/others/crit/*.sh test/others/criu-coredump/*.sh
449452
shellcheck -x test/others/config-file/*.sh
450453
shellcheck -x test/others/action-script/*.sh
454+
455+
codespell:
451456
codespell -S tags
457+
458+
lint: ruff shellcheck codespell
452459
# Do not append \n to pr_perror, pr_pwarn or fail
453460
! git --no-pager grep -E '^\s*\<(pr_perror|pr_pwarn|fail)\>.*\\n"'
454461
# Do not use %m with pr_* or fail
@@ -459,7 +466,7 @@ lint:
459466
! git --no-pager grep -En '^\s*\<pr_(err|warn|msg|info|debug)\>.*);$$' | grep -v '\\n'
460467
# No EOL whitespace for C files
461468
! git --no-pager grep -E '\s+$$' \*.c \*.h
462-
.PHONY: lint
469+
.PHONY: lint ruff shellcheck codespell
463470

464471
codecov: SHELL := $(shell which bash)
465472
codecov:

scripts/build/Dockerfile.alpine

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ RUN apk add \
4141
go \
4242
e2fsprogs \
4343
py-yaml \
44-
py3-flake8 \
4544
py3-importlib-metadata \
4645
asciidoctor
4746

scripts/build/Dockerfile.archlinux

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ RUN pacman -Syu --noconfirm \
3131
bash \
3232
go \
3333
python-yaml \
34-
flake8 \
3534
asciidoctor \
3635
python-junit-xml \
3736
python-importlib-metadata \

scripts/build/Dockerfile.centos8

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ RUN yum install -y --allowerasing \
2626
protobuf-c-devel \
2727
protobuf-devel \
2828
python3-devel \
29-
python3-flake8 \
3029
python3-PyYAML \
3130
python3-protobuf \
3231
python3-pip \

scripts/ci/prepare-for-fedora-rawhide.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dnf install -y \
2323
procps-ng \
2424
protobuf-c-devel \
2525
protobuf-devel \
26-
python3-flake8 \
2726
python3-PyYAML \
2827
python3-protobuf \
2928
python3-junit_xml \

scripts/ci/run-ci-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -x -e
44
CI_PKGS=(protobuf-c-compiler libprotobuf-c-dev libaio-dev libgnutls28-dev
55
libgnutls30 libprotobuf-dev protobuf-compiler libcap-dev
66
libnl-3-dev gdb bash libnet-dev util-linux asciidoctor
7-
libnl-route-3-dev time flake8 libbsd-dev python3-yaml
7+
libnl-route-3-dev time libbsd-dev python3-yaml
88
libperl-dev pkg-config python3-protobuf python3-pip
99
python3-importlib-metadata python3-junit.xml libdrm-dev)
1010

scripts/ci/vagrant.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ setup() {
3838
ssh default sudo dnf upgrade -y
3939
ssh default sudo dnf install -y gcc git gnutls-devel nftables-devel libaio-devel \
4040
libasan libcap-devel libnet-devel libnl3-devel libbsd-devel make protobuf-c-devel \
41-
protobuf-devel python3-flake8 python3-protobuf python3-importlib-metadata \
42-
python3-junit_xml rubygem-asciidoctor iptables libselinux-devel libbpf-devel
41+
protobuf-devel python3-protobuf python3-importlib-metadata python3-junit_xml \
42+
rubygem-asciidoctor iptables libselinux-devel libbpf-devel
4343
# Disable sssd to avoid zdtm test failures in pty04 due to sssd socket
4444
ssh default sudo systemctl mask sssd
4545
ssh default cat /proc/cmdline

0 commit comments

Comments
 (0)