[PATCH] toaster: add tox.ini file to execute flake8 and test suite

Marlon Rodriguez Garcia <[email protected]> Wed, 18 Oct 2023 15:46:05 -0400
Newsgroups org.yoctoproject.lists.toaster
Message-ID <20231018194605.2710214-1-marlon.rodriguez-garcia@savoirfairelinux.com>
Added configuration file for tox https://tox.wiki/en/4.11.3/ that includes flake8 and the test suite.
This file can be execute using the command 'tox tox.ini' and can be used in autobuilder.

By adding flake8 to the validation of toaster the following aspects have to be take into consideration:
Objective
- To comply with PEP8 standards, we propose to utilize a linting tool(Flake8) that checks toaster's codebase for errors, styling issues and complexity

Ruleset
- See complete list of rules : https://www.flake8rules.com/

Assumptions
- We are aware that not all Flake8 rules can be applied to current codebase (those determined to be more troublesome can be excluded).
- The patches can be integrated gradually by sections and/or rules.
- The tox.ini will include the execution of the test suite.

Pros
- Standardized codebase for future integrations.
- Majority of the patches will be syntax modifications and not affecting application logic.

Cons
- Major refactor of the codebase.

Signed-off-by: Marlon Rodriguez Garcia <[email protected]>
---
 lib/toaster/tox.ini | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 lib/toaster/tox.ini

diff --git a/lib/toaster/tox.ini b/lib/toaster/tox.ini
new file mode 100644
index 00000000..bcdfdb4f
--- /dev/null
+++ b/lib/toaster/tox.ini
@@ -0,0 +1,25 @@
+[tox]
+envlist = py310
+skipsdist = True
+toxworkdir = {env:TOX_WORKDIR:.tox}
+passenv = *
+
+[testenv]
+setenv =
+    DJANGO_SETTINGS_MODULE=toastermain.settings_test
+    TOASTER_BUILDSERVER=1
+    EVENTREPLAY_DIR={toxinidir}/../../../build/
+    BUILDDIR={toxinidir}/../../../build/
+commands =
+    flake8
+    python3 {toxinidir}/manage.py test tests.db tests.commands tests.builds tests.browser tests.functional tests.views
+deps = 
+    -r ../../toaster-requirements.txt
+    -r {toxinidir}/tests/toaster-tests-requirements.txt
+    flake8
+
+[flake8]
+ignore = E501, F403
+
+[testenv:chrome]
+commands={[testenv]commands} --splinter-webdriver=chrome
\ No newline at end of file
-- 
2.34.1