Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions kernelci/kbuild.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

Check warning on line 1 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Too many lines in module (1387/1000)
#
# Copyright (C) 2023 Collabora Limited
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
Expand Down Expand Up @@ -44,12 +44,12 @@
from typing import Dict, Tuple, List

CIP_CONFIG_URL = \
"https://gitlab.com/cip-project/cip-kernel/cip-kernel-config/-/raw/master/{branch}/{config}" # noqa

Check warning on line 47 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Line too long (104/100)
CROS_CONFIG_URL = \
"https://chromium.googlesource.com/chromiumos/third_party/kernel/+archive/refs/heads/{branch}/chromeos/config.tar.gz" # noqa

Check warning on line 49 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Line too long (129/100)
FW_GIT = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" # noqa

# TODO: find a way to automatically fetch this information

Check warning on line 52 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: find a way to automatically fetch this information
LATEST_LTS_MAJOR = 6
LATEST_LTS_MINOR = 12

Expand Down Expand Up @@ -106,19 +106,19 @@
REDIR = ' > >(tee {}) 2> >(tee {} >&1)'


def _download_file_inner(url, file_path):

Check warning on line 109 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Either all return statements in a function should return an expression, or none of them should.
try:
r = requests.get(url, stream=True, timeout=60)
except requests.exceptions.RequestException as e:
print(f"[_download_file_inner] Error: {e}")
return False
except requests.exceptions.Timeout as e:

Check failure on line 115 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Bad except clauses order (RequestException is an ancestor class of Timeout)
print(f"[_download_file_inner] Timeout: {e}")
return False
except requests.exceptions.ConnectionError as e:

Check failure on line 118 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Bad except clauses order (RequestException is an ancestor class of ConnectionError)
print(f"[_download_file_inner] Connection error: {e}")
return False
except Exception as e:

Check warning on line 121 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Catching too general exception Exception
print(f"[_download_file_inner] Exception: {e}")
return False
if r.status_code == 200:
Expand All @@ -143,13 +143,13 @@
return False


class KBuild():

Check warning on line 146 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Too many instance attributes (29/7)
'''
Build class that represents kernel build
if node, jobname and params are provided, create new build object
if jsonobj is provided, load class from serialized json
'''
def __init__(self, node=None, jobname=None, params=None, jsonobj=None, apiconfig=None,

Check warning on line 152 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Too many arguments (7/5)
fragment_configs=None):
# Retrieve and store API token for future use
self._api_token = os.environ.get('KCI_API_TOKEN')
Expand Down Expand Up @@ -188,9 +188,9 @@
else:
self._dtbs_check = False
if params.get('kselftest') == 'disable':
self._kfselftest = False
self._kselftest = False
else:
self._kfselftest = True
self._kselftest = True
self._apijobname = jobname
self._steps = []
self._artifacts = []
Expand Down Expand Up @@ -246,7 +246,8 @@
)
self._full_artifacts = jsonobj['full_artifacts']
self._dtbs_check = jsonobj['dtbs_check']
self._kfselftest = jsonobj['kfselftest']
self._kselftest = jsonobj.get('kselftest',
jsonobj.get('kfselftest'))
self._coverage = jsonobj.get('coverage', False)
return
raise ValueError("No valid arguments provided")
Expand Down Expand Up @@ -349,7 +350,7 @@
self._artifacts.append("build_kimage_stderr.log")
self._artifacts.append("build_modules.log")
self._artifacts.append("build_modules_stderr.log")
if self._kfselftest:
if self._kselftest:
self._artifacts.append("build_kselftest.log")
self._artifacts.append("build_kselftest_stderr.log")
# disable DTBS for some archs
Expand Down Expand Up @@ -657,8 +658,8 @@
self.startjob("config_fragments")
for fragfile in fragment_files:
self.addcmd(f"./scripts/kconfig/merge_config.sh -m .config {fragfile}")
# TODO: olddefconfig should be optional/configurable

Check warning on line 661 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: olddefconfig should be optional/configurable
# TODO: log all warnings/errors of olddefconfig to separate file

Check warning on line 662 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

TODO: log all warnings/errors of olddefconfig to separate file
self.addcmd("make olddefconfig")
self.addcmd(f"cp .config {self._af_dir}/")
self.addcmd("cd ..")
Expand Down Expand Up @@ -719,15 +720,15 @@
self._fetch_firmware()
self._build_kernel()
self._build_modules()
if self._kfselftest:
if self._kselftest:
self._build_kselftest()
if self._arch not in DTBS_DISABLED:
self._build_dtbs()
self._package_kimage()
self._package_modules()
if self._coverage:
self._package_coverage()
if self._kfselftest:
if self._kselftest:
self._package_kselftest()
if self._arch not in DTBS_DISABLED:
self._package_dtbs()
Expand Down Expand Up @@ -802,7 +803,7 @@
targets = ["kernel", "modules"]
if self._arch not in DTBS_DISABLED:
targets.append("dtbs")
if self._kfselftest:
if self._kselftest:
targets.append("kselftest")
cmd_parts.append(" ".join(targets))
print(f"[_build_with_tuxmake] Building targets: {' '.join(targets)}")
Expand Down Expand Up @@ -1130,12 +1131,12 @@
os.unlink(upload_path)

print(f"[_upload_artifacts] Uploaded {artifact} to {stored_url}")
return artifact, stored_url, None

Check failure on line 1134 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Incompatible return value type (got "tuple[str, Any, None]", expected "tuple[str, str, str]") [return-value]
except Exception as e:
print(f"[_upload_artifacts] Error uploading {artifact}: {e}")
if compressed_file and os.path.exists(upload_path):
os.unlink(upload_path)
return artifact, None, str(e)

Check failure on line 1139 in kernelci/kbuild.py

View workflow job for this annotation

GitHub Actions / Lint

Incompatible return value type (got "tuple[str, None, str]", expected "tuple[str, str, str]") [return-value]

# Process uploads in parallel
max_workers = min(10, len(upload_tasks)) # Limit concurrent uploads
Expand Down Expand Up @@ -1307,7 +1308,7 @@
# Add child_nodes for each sub-step

# do we have kselftest archive in artifact keys? then node is ok
if self._kfselftest:
if self._kselftest:
kselftest_result = 'fail'
for artifact in af_uri:
if artifact in ('kselftest_tar_xz', 'kselftest_tar_gz'):
Expand Down Expand Up @@ -1355,7 +1356,7 @@

# if we have kselftest, we need to add child node
# but only if build was successful
if self._kfselftest and job_result == 'pass':
if self._kselftest and job_result == 'pass':
kselftest_node = self._node.copy()
# remove id to not have same as parent
kselftest_node.pop('id')
Expand Down
Loading