<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi, Igor</p>
<p><br>
</p>
<p>thanks for the patch! see my comments</p>
<p><br>
</p>
<p>Sergey<br>
</p>
<div class="moz-cite-prefix">On 8/3/23 10:30, Igor Munkin wrote:<br>
</div>
<blockquote type="cite"
cite="mid:df9a545109279a9eb40856933b17d7107d6eacaa.1691047132.git.imun@tarantool.org">
<pre class="moz-quote-pre" wrap="">This patch introduces a separate target to run flake8 against all Python
scripts within LuaJIT repository (i.e. debugger extensions). There are
some tweaks in .flake8rc regarding our style: one can find more info in
the config file.
The new target is a dependency for the new <LuaJIT-lint> target, that
joins both luacheck and flake8 linter runs. CI job with linters is
adjusted respectively.
Signed-off-by: Igor Munkin <a class="moz-txt-link-rfc2396E" href="mailto:imun@tarantool.org"><imun@tarantool.org></a>
---
.flake8rc | 12 ++++++++++++
.github/workflows/lint.yml | 4 ++--
test/CMakeLists.txt | 28 ++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 .flake8rc
diff --git a/.flake8rc b/.flake8rc
new file mode 100644
index 00000000..b6f7ad48
--- /dev/null
+++ b/.flake8rc
@@ -0,0 +1,12 @@
+[flake8]
+extend-ignore =
+ # TODO: I have no idea, how to fix this. flake8 suggests nothing
+ # (like clang-format or checkpatch.pl do). Help needed.
+ E131,
+ # TODO: I have no idea, how to fix this. flake8 suggests nothing
+ # (like clang-format or checkpatch.pl do). Help needed.
+ E501,
+ # XXX: Suppress F821, since we have autogenerated names for
+ # 'ptr' type complements in luajit_lldb.py.
+ F821
+max-line-length = 80
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 70c98104..6b420f68 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -41,7 +41,7 @@ jobs:
run: |
# TODO: Move this step to a separate action.
sudo apt -y update
- sudo apt -y install cmake ninja-build lua5.1 luarocks
+ sudo apt -y install cmake ninja-build lua5.1 luarocks flake8
sudo luarocks install luacheck
# Set CMAKE_BUILD_PARALLEL_LEVEL environment variable to
# limit the number of parallel jobs for build/test step.
@@ -49,5 +49,5 @@ jobs:
- name: configure
run: cmake -S . -B ${{ env.BUILDDIR }} -G Ninja
- name: test
- run: cmake --build . --target LuaJIT-luacheck
+ run: cmake --build . --target LuaJIT-lint
working-directory: ${{ env.BUILDDIR }}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 47296a22..17ac5cac 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -42,6 +42,34 @@ else()
)
endif()
+find_program(FLAKE8 flake8)
+if(FLAKE8)
+ get_filename_component(FLAKE8_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH)</pre>
</blockquote>
Nit: name FLAKE8_SOURCE_DIR is confused, because dir has nothing
common with flake8. May be "REAL_SOURCE_DIR"?<br>
<blockquote type="cite"
cite="mid:df9a545109279a9eb40856933b17d7107d6eacaa.1691047132.git.imun@tarantool.org">
<pre class="moz-quote-pre" wrap="">
+ set(FLAKE8_RC ${FLAKE8_SOURCE_DIR}/.flake8rc)
+ file(GLOB_RECURSE FLAKE8_DEPS ${FLAKE8_SOURCE_DIR}/*.py)
+ add_custom_target(${PROJECT_NAME}-flake8
+ DEPENDS ${FLAKE8_DEPS}
+ )
+ add_custom_command(TARGET ${PROJECT_NAME}-flake8
+ COMMENT "Running flake8 static analysis"
+ COMMAND
+ ${FLAKE8} ${FLAKE8_DEPS}
+ --config ${FLAKE8_RC}
+ --jobs ${CMAKE_BUILD_PARALLEL_LEVEL}
+ WORKING_DIRECTORY ${FLAKE8_SOURCE_DIR}
+ )
+else()
+ add_custom_target(${PROJECT_NAME}-flake8)
+ add_custom_command(TARGET ${PROJECT_NAME}-flake8
+ COMMENT "`flake8' is not found, so ${PROJECT_NAME}-flake8 target is dummy"</pre>
</blockquote>
<p>Please add a command to a dummy target:</p>
<pre style="margin: 0px 0px calc(1.5em); padding: var(--su12); border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-variant-alternates: inherit; font-weight: 400; font-stretch: inherit; line-height: var(--lh-md); font-family: var(--ff-mono); font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; font-size: var(--fs-body1); vertical-align: baseline; box-sizing: inherit; width: auto; max-height: 600px; overflow: auto; background-color: var(--highlight-bg); border-radius: var(--br-md); overflow-wrap: normal; color: var(--highlight-color); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: var(--ff-mono); font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; font-size: var(--_pr-code-fs); vertical-align: baseline; box-sizing: inherit; background-color: transparent; white-space: inherit; color: var(--black-800); border-radius: 0px;">COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red "</code><code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: var(--ff-mono); font-optical-sizing: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; font-size: var(--_pr-code-fs); vertical-align: baseline; box-sizing: inherit; background-color: transparent; white-space: inherit; color: var(--black-800); border-radius: 0px;">`flake8' is not found, so ${PROJECT_NAME}-flake8 target is dummy"
with added COMMAND target will print a message
</code></pre>
<p></p>
<blockquote type="cite"
cite="mid:df9a545109279a9eb40856933b17d7107d6eacaa.1691047132.git.imun@tarantool.org">
<pre class="moz-quote-pre" wrap="">
+ )
+endif()
+
+add_custom_target(${PROJECT_NAME}-lint DEPENDS
+ ${PROJECT_NAME}-luacheck
+ ${PROJECT_NAME}-flake8
+)
+
set(LUAJIT_TEST_COMMAND "${LUAJIT_TEST_BINARY} -e dofile[[${LUAJIT_TEST_INIT}]]")
separate_arguments(LUAJIT_TEST_COMMAND)
</pre>
</blockquote>
<p>You've introduced a new target LuaJIT-lint, that includes
LuaJIT-luacheck and LuaJIT-flake8.</p>
<p>I suppose we need replace dependence "LuaJIT-luacheck" to
"LuaJIT-lint" for a target "test".<br>
</p>
<blockquote type="cite"
cite="mid:df9a545109279a9eb40856933b17d7107d6eacaa.1691047132.git.imun@tarantool.org">
<pre class="moz-quote-pre" wrap="">
</pre>
</blockquote>
</body>
</html>