[buildbot] Add linting with flake8 tool
LEDE Commits
lede-commits at lists.infradead.org
Fri Apr 12 23:33:01 PDT 2024
ynezz pushed a commit to buildbot.git, branch main:
https://git.openwrt.org/815fc1af29a293c0095b7e6e0e6cba068fe081b9
commit 815fc1af29a293c0095b7e6e0e6cba068fe081b9
Author: Petr Štetiar <ynezz at true.cz>
AuthorDate: Sat Dec 23 06:13:02 2023 +0000
Add linting with flake8 tool
flake8 is a Python tool that glues together pycodestyle, pyflakes,
mccabe, and third-party plugins to check the style and quality of some
Python code.
Currently we've issue in phase2 in checksum step:
/bin/sh: 2: Syntax error: ")" unexpected
And it seems, that flake8 is able to spot places which might lead to
such issues during runtime:
phase2/master.cfg:733:151: W605 invalid escape sequence '\('
phase2/master.cfg:733:155: W605 invalid escape sequence '\)'
phase2/master.cfg:733:158: W605 invalid escape sequence '\('
phase2/master.cfg:733:162: W605 invalid escape sequence '\)'
So lets enable flake8 checking on the CI so we can spot similar places
in the future and address them before deployment.
We dont want to make current ongoing work on phase2 code harder, thus we
don't touch that part yet, so we whitelist most of the checks for now.
References: f0faed2970dd ("phase2: compute checksums")
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
.flake8 | 4 ++++
.github/workflows/build-push.yml | 3 +++
.gitignore | 1 +
phase1/master.cfg | 41 ++++++++++++++++++++++++++++------------
requirements-dev.txt | 1 +
5 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..66380a1
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,4 @@
+[flake8]
+max-line-length = 140
+per-file-ignores =
+ phase2/master.cfg: E101,E117,E128,E201,E202,E203,E221,E225,E251,E266,E302,E305,E501,W191
diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml
index 4f5b3f4..1ae0f27 100644
--- a/.github/workflows/build-push.yml
+++ b/.github/workflows/build-push.yml
@@ -40,6 +40,9 @@ jobs:
- name: Lint with ruff
run: ruff phase*/master.cfg
+ - name: Lint with flake8
+ run: flake8 phase*/master.cfg
+
- name: Stylecheck with black
run: black phase1/master.cfg
diff --git a/.gitignore b/.gitignore
index 0d4e15f..5c68e09 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,4 @@ phase[12]/twistd.*
!.ruff.toml
!tests
!tests/**/*
+!.flake8
diff --git a/phase1/master.cfg b/phase1/master.cfg
index 2d6f304..e9c6b71 100644
--- a/phase1/master.cfg
+++ b/phase1/master.cfg
@@ -107,7 +107,7 @@ pb_port = inip1.get("port") or 9989
# a shorter alias to save typing.
c = BuildmasterConfig = {}
-####### PROJECT IDENTITY
+# PROJECT IDENTITY
# the 'title' string will appear at the top of this buildbot
# installation's html.WebStatus home page (linked to the
@@ -124,7 +124,7 @@ c["titleURL"] = ini["general"].get("title_url")
c["buildbotURL"] = inip1.get("buildbot_url")
-####### BUILDWORKERS
+# BUILDWORKERS
# The 'workers' list defines the set of recognized buildworkers. Each element is
# a Worker object, specifying a unique worker name and password. The same
@@ -292,7 +292,7 @@ def prioritizeBuilders(master, builders):
c["prioritizeBuilders"] = prioritizeBuilders
-####### CHANGESOURCES
+# CHANGESOURCES
# find targets
targets = dict()
@@ -358,7 +358,7 @@ c["change_source"].append(
)
)
-####### SCHEDULERS
+# SCHEDULERS
# Configure the Schedulers, which decide how to react to incoming changes.
@@ -541,7 +541,7 @@ c["schedulers"].append(
schedulers.Triggerable(name="trigger", builderNames=builderNames, priority=20)
)
-####### BUILDERS
+# BUILDERS
# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which workers can execute them. Note that any particular build will
@@ -882,7 +882,11 @@ def prepareFactory(target):
name="gitverify",
description="Ensuring that Git HEAD is pointing to a branch or tag",
descriptionDone="Git HEAD is sane",
- command='git rev-parse --abbrev-ref HEAD | grep -vxqF HEAD || git show-ref --tags --dereference 2>/dev/null | sed -ne "/^$(git rev-parse HEAD) / { s|^.*/||; s|\\^.*||; p }" | grep -qE "^v[0-9][0-9]\\."',
+ command=(
+ "git rev-parse --abbrev-ref HEAD | grep -vxqF HEAD || "
+ "git show-ref --tags --dereference 2>/dev/null | sed -ne "
+ '"/^$(git rev-parse HEAD) / { s|^.*/||; s|\\^.*||; p }" | grep -qE "^v[0-9][0-9]\\."'
+ ),
haltOnFailure=True,
)
)
@@ -944,7 +948,9 @@ def prepareFactory(target):
name="newconfig",
descriptionDone=".config seeded",
command=Interpolate(
- "printf 'CONFIG_TARGET_%(kw:target)s=y\\nCONFIG_TARGET_%(kw:target)s_%(kw:subtarget)s=y\\nCONFIG_SIGNED_PACKAGES=%(kw:usign:#?|y|n)s\\n' >> .config",
+ "printf 'CONFIG_TARGET_%(kw:target)s=y\\n"
+ "CONFIG_TARGET_%(kw:target)s_%(kw:subtarget)s=y\\n"
+ "CONFIG_SIGNED_PACKAGES=%(kw:usign:#?|y|n)s\\n' >> .config",
target=target,
subtarget=subtarget,
usign=GetUsignKey,
@@ -1145,7 +1151,11 @@ def prepareFactory(target):
name="kernelversion",
property="kernelversion",
description="Finding the effective Kernel version",
- command="make --no-print-directory -C target/linux/ val.LINUX_VERSION val.LINUX_RELEASE val.LINUX_VERMAGIC | xargs printf '%s-%s-%s\\n'",
+ command=(
+ "make --no-print-directory -C target/linux/ "
+ "val.LINUX_VERSION val.LINUX_RELEASE val.LINUX_VERMAGIC | "
+ "xargs printf '%s-%s-%s\\n'"
+ ),
env={"TOPDIR": Interpolate("%(prop:builddir)s/build")},
)
)
@@ -1341,7 +1351,10 @@ def prepareFactory(target):
description="Packing files to sign",
descriptionDone="Files to sign packed",
command=Interpolate(
- "find bin/targets/%(kw:target)s/%(kw:subtarget)s%(prop:libc)s/ bin/targets/%(kw:target)s/%(kw:subtarget)s%(prop:libc)s/kmods/ -mindepth 1 -maxdepth 2 -type f -name sha256sums -print0 -or -name Packages -print0 | xargs -0 tar -czf sign.tar.gz",
+ "find bin/targets/%(kw:target)s/%(kw:subtarget)s%(prop:libc)s/ "
+ "bin/targets/%(kw:target)s/%(kw:subtarget)s%(prop:libc)s/kmods/ "
+ "-mindepth 1 -maxdepth 2 -type f -name sha256sums -print0 -or "
+ "-name Packages -print0 | xargs -0 tar -czf sign.tar.gz",
target=target,
subtarget=subtarget,
),
@@ -1674,7 +1687,11 @@ def prepareFactory(target):
name="sourcelist",
description="Finding source archives to upload",
descriptionDone="Source archives to upload found",
- command="find dl/ -maxdepth 1 -type f -not -size 0 -not -name '.*' -not -name '*.hash' -not -name '*.dl' -newer .config -printf '%f\\n' > sourcelist",
+ command=(
+ "find dl/ -maxdepth 1 -type f -not -size 0 "
+ "-not -name '.*' -not -name '*.hash' -not -name "
+ "'*.dl' -newer .config -printf '%f\\n' > sourcelist"
+ ),
haltOnFailure=True,
)
)
@@ -1775,7 +1792,7 @@ for brname in branchNames:
)
-####### STATUS TARGETS
+# STATUS TARGETS
# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
@@ -1826,7 +1843,7 @@ c["revlink"] = util.RevlinkMatch(
r"https://git.openwrt.org/?p=openwrt/\1.git;a=commit;h=%s",
)
-####### DB URL
+# DB URL
c["db"] = {
# This specifies what database buildbot uses to store its state. You can leave
diff --git a/requirements-dev.txt b/requirements-dev.txt
index e1cb65f..033af6b 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,3 +1,4 @@
cram==0.7
black==23.3.0
ruff==0.0.267
+flake8==6.1.0
More information about the lede-commits
mailing list