Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def parse_args():
help='Ratch root directory.')
ap.add_argument('-d', '--dry-run', action='store_true', default=False,
help='Run it without uploading the result. default=False')
ap.add_argument('-j', '--jobs', action='store', type=str, default="4",
help='Number of make jobs (number or "auto"). default=4')

# Positional parameter
ap.add_argument('space', choices=['user', 'kernel'],
Expand Down Expand Up @@ -396,6 +398,9 @@ def create_test_list_kernel(ci_data):
# BuildKernel32
test_list.append(ci.BuildKernel32(ci_data, kernel_config=kernel_config))

# CheckKernelLLVM
test_list.append(ci.CheckKernelLLVM(ci_data, kernel_config=kernel_config))

# TestRunnerSetup
tester_config = os.path.join(ci_data.config['bluez_dir'],
"doc", "tester.config")
Expand Down Expand Up @@ -501,14 +506,17 @@ def main():
log_error(f"Invalid parameter(space) {args.space}")
sys.exit(1)

if args.jobs == "auto":
args.jobs = str(os.cpu_count())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No super found of the jobs variable being either a string or an int.


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the default should also be set here? That's where it's advertised.

ci_data = Context(config_file=os.path.abspath(args.config),
github_repo=args.repo,
src_dir=main_src,
patch_root=args.patch_root,
branch=args.branch, dry_run=args.dry_run,
bluez_dir=args.bluez_dir, ell_dir=args.ell_dir,
kernel_dir=args.kernel_dir, pr_num=args.pr_num,
space=args.space)
space=args.space, jobs=args.jobs)

# Setup Source for the test that needs to access the base like incremental
# build.
Expand Down
1 change: 1 addition & 0 deletions ci/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
from .checksparse import CheckSparse
from .checkallwarning import CheckAllWarning
from .checksmatch import CheckSmatch
from .checkkernelllvm import CheckKernelLLVM

3 changes: 2 additions & 1 deletion ci/buildbluez.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def __init__(self, ci_data, src_dir=None, config_params=None,
self.dry_run = dry_run

super().__init__(config_params=config_params, work_dir=self.src_dir,
make_params=self.make_params)
make_params=self.make_params,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
3 changes: 2 additions & 1 deletion ci/buildell.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def __init__(self, ci_data, src_dir=None):
self.desc = "Build and Install ELL"
self.ci_data = ci_data

super().__init__(work_dir=ci_data.config['ell_dir'], install=True)
super().__init__(work_dir=ci_data.config['ell_dir'], install=True,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
3 changes: 2 additions & 1 deletion ci/buildkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def __init__(self, ci_data, kernel_config=None, simple_build=True,
self.stderr = None

super().__init__(kernel_config=kernel_config, simple_build=simple_build,
make_params=make_params, work_dir=self.src_dir)
make_params=make_params, work_dir=self.src_dir,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
3 changes: 2 additions & 1 deletion ci/buildkernel32.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def __init__(self, ci_data, kernel_config=None, simple_build=True,
self.log_dbg(f"New config for 32bit is created: {new_config}")

super().__init__(kernel_config=new_config, simple_build=simple_build,
make_params=make_params, work_dir=self.src_dir)
make_params=make_params, work_dir=self.src_dir,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
19 changes: 13 additions & 6 deletions ci/checkallwarning.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class CheckAllWarning(GenericKernelBuild):
This class runs the kernel build with all warning enabled.
"""

def __init__(self, ci_data, kernel_config=None, src_dir=None, dry_run=None):
def __init__(self, ci_data, kernel_config=None, src_dir=None, dry_run=None,
make_params=None):

self.name = "CheckAllWarning"
self.desc = "Run linux kernel with all warning enabled"
Expand All @@ -30,8 +31,14 @@ def __init__(self, ci_data, kernel_config=None, src_dir=None, dry_run=None):
self.log_dbg(f"Override the dry_run flag: {dry_run}")
self.dry_run = dry_run

if make_params:
make_params = ['W=1'] + make_params
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know if it's too early to ask for that, but would it be possible to only have "generic" make params be added to the make params? I'm thinking of the (eventual) meson support which wouldn't know what to do with W=1.

else:
make_params = ['W=1']

super().__init__(kernel_config=kernel_config, simple_build=True,
make_params=['W=1'], work_dir=self.src_dir)
make_params=make_params, work_dir=self.src_dir,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand All @@ -52,7 +59,7 @@ def run(self):
if self.verdict == Verdict.FAIL:
submit_pw_check(self.ci_data.pw, self.ci_data.patch_1,
self.name, Verdict.FAIL,
"CheckAllWarning: FAIL: " + self.output,
f"{self.name}: FAIL: " + self.output,
None, self.dry_run)
# Test verdict and output is already set by the super().run().
# Just raising EndTest exception is enough here
Expand All @@ -64,7 +71,7 @@ def run(self):
# Build success
submit_pw_check(self.ci_data.pw, self.ci_data.patch_1,
self.name, Verdict.PASS,
"CheckAllWarning PASS",
f"{self.name} PASS",
None, self.dry_run)
# Actually no need to call success() here. But add it here just for
# reference
Expand All @@ -86,15 +93,15 @@ def run(self):
# Found error and return warning
submit_pw_check(self.ci_data.pw, self.ci_data.patch_1,
self.name, Verdict.WARNING,
"CheckSparse WARNING " + output_str,
f"{self.name} WARNING " + output_str,
None, self.dry_run)
self.warning(output_str)
return

# Build success
submit_pw_check(self.ci_data.pw, self.ci_data.patch_1,
self.name, Verdict.PASS,
"CheckSparse PASS",
f"{self.name} PASS",
None, self.dry_run)
# Actually no need to call success() here. But add it here just for
# reference
Expand Down
33 changes: 33 additions & 0 deletions ci/checkkernelllvm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import sys
import re

from ci import Verdict, EndTest, submit_pw_check
from ci import CheckAllWarning

class CheckKernelLLVM(CheckAllWarning):
"""Build kernel with LLVM + context analysis
"""

def __init__(self, ci_data, kernel_config=None, src_dir=None, dry_run=None):
# Enable context analysis unconditionally
kernel_config = self.make_kernel_config(kernel_config)

super().__init__(ci_data, kernel_config=kernel_config, src_dir=src_dir,
dry_run=dry_run, make_params=["LLVM=1"])

self.name = "CheckKernelLLVM"
self.desc = "Build kernel with LLVM + context analysis"

def make_kernel_config(self, old_kernel_config):
kernel_config = "/build_kernel_llvm.config"
if not old_kernel_config:
old_kernel_config = '/bluetooth_build.config'

with open(old_kernel_config, "r") as f:
config_text = f.read()
config_text += "\n\nCONFIG_WARN_CONTEXT_ANALYSIS=y"
with open(kernel_config, "w") as f:
f.write(config_text)

return kernel_config
3 changes: 2 additions & 1 deletion ci/checksparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def __init__(self, ci_data, kernel_config=None, src_dir=None, dry_run=None):
self.dry_run = dry_run

super().__init__(kernel_config=kernel_config, simple_build=True,
make_params=['C=1'], work_dir=self.src_dir)
make_params=['C=1'], work_dir=self.src_dir,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
3 changes: 2 additions & 1 deletion ci/checkvalgrind.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def __init__(self, ci_data):
config_params = ["--disable-lsan", "--disable-asan"]
make_params = ["check"]
super().__init__(config_params=config_params, make_params=make_params,
work_dir=ci_data.src_dir)
work_dir=ci_data.src_dir,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
6 changes: 4 additions & 2 deletions ci/genericbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GenericBuild(Base):
def __init__(self, config_cmd=None, config_params=None,
make_cmd=None, make_params=None,
use_fakeroot=False, install=False, install_params=None,
work_dir=None):
work_dir=None, jobs=None):

super().__init__()

Expand All @@ -40,6 +40,8 @@ def __init__(self, config_cmd=None, config_params=None,

self.stderr = None

self.jobs = jobs if jobs else "4"

self.log_dbg("Initialization completed")

def run(self):
Expand All @@ -58,7 +60,7 @@ def run(self):

# Make
# AR: Maybe read from /proc for job count
cmd = [self.make_cmd, "-j4"]
cmd = [self.make_cmd, "-j" + str(self.jobs)]
if self.use_fakeroot:
cmd = ["fakeroot"] + cmd
if self.make_params:
Expand Down
8 changes: 6 additions & 2 deletions ci/generickernelbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GenericKernelBuild(Base):
"""

def __init__(self, kernel_config=None, simple_build=True,
make_params=None, work_dir=None):
make_params=None, work_dir=None, jobs=None):

super().__init__()

Expand All @@ -37,6 +37,8 @@ def __init__(self, kernel_config=None, simple_build=True,
# Save the error output
self.stderr = None

self.jobs = str(jobs) if jobs else "4"

self.log_dbg("Initialization completed")

def run(self):
Expand All @@ -50,6 +52,8 @@ def run(self):
# Update .config
self.log_info("GenericKernelBuild: Run make olddefconfig")
cmd = ["make", "olddefconfig"]
if self.make_params:
cmd += self.make_params
(ret, stdout, stderr) = cmd_run(cmd, cwd=self.work_dir)
if ret:
self.log_err("GenericKernelBuild: Failed to config the kernel")
Expand All @@ -58,7 +62,7 @@ def run(self):
# make
self.log_info("Run make")

base_cmd = ["make", "-j4"]
base_cmd = ["make", "-j" + self.jobs]
if self.make_params:
base_cmd += self.make_params
self.log_dbg(f"GenericKernelBuild: Base Command: {base_cmd}")
Expand Down
5 changes: 4 additions & 1 deletion ci/incrementalbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(self, ci_data, space, kernel_config=None):
if self.space == "kernel" and not self.kernel_config:
self.kernel_config = '/bluetooth_build.config'

jobs = ci_data.config.get('jobs')
self.jobs = str(jobs) if jobs else "4"

super().__init__()

self.log_dbg("Initialization completed")
Expand Down Expand Up @@ -57,7 +60,7 @@ def _initial_setup(self):
def _incremental_make(self):
"""Run make without reconfiguring - truly incremental."""

cmd = ["make", "-j4"]
cmd = ["make", "-j" + self.jobs]
if self.space == "kernel":
# Kernel simple build: only Bluetooth sources
cmd.append('net/bluetooth/')
Expand Down
3 changes: 2 additions & 1 deletion ci/makedistcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def __init__(self, ci_data):
config_params = ["--disable-lsan", "--disable-asan", "--disable-ubsan"]
make_params = ["distcheck"]
super().__init__(config_params=config_params, make_params=make_params,
use_fakeroot=True, work_dir=ci_data.src_dir)
use_fakeroot=True, work_dir=ci_data.src_dir,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
3 changes: 2 additions & 1 deletion ci/makeextell.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def __init__(self, ci_data):
self.ci_data = ci_data

config_params = ["--enable-external-ell", "--disable-lsan", "--disable-asan", "--disable-ubsan"]
super().__init__(config_params=config_params, work_dir=ci_data.src_dir)
super().__init__(config_params=config_params, work_dir=ci_data.src_dir,
jobs=ci_data.config.get('jobs'))

self.log_dbg("Initialization completed")

Expand Down
5 changes: 4 additions & 1 deletion ci/scanbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def __init__(self, ci_data):
self.desc = "Run Scan Build"
self.ci_data = ci_data

jobs = ci_data.config.get('jobs')
self.jobs = str(jobs) if jobs else "4"

super().__init__()

self.log_dbg("Initialization completed")
Expand All @@ -40,7 +43,7 @@ def scan_build(self, error_filename):
self.add_failure_end_test(stderr)

# Scan Build Make
cmd = ["scan-build", "make", "-j4"]
cmd = ["scan-build", "make", "-j" + self.jobs]
(ret, stdout, stderr) = cmd_run(cmd, cwd=self.ci_data.src_dir)
if ret:
self.log_err("Scan Build failed")
Expand Down
57 changes: 56 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

export PATH=/opt/llvm/bin:$PATH
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't be needed if we used llvm from the distribution, see BluezTestBot/docker-bluez-build#2 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the CONTEXT_ANALYSIS is a bit of a moving target vs Clang versions, I think it's better to pick manually the compiler we want


echo "Environment Variables:"
echo " Workflow: $GITHUB_WORKFLOW"
echo " Action: $GITHUB_ACTION"
Expand Down Expand Up @@ -171,9 +173,62 @@ case $TASK in
exit 1
fi
;;
localci)
echo "Task: local CI"
mkdir -p /work
mkdir -p /work/base
GITHUB_WORKSPACE=/work
BASE_DIR=base

SPACE="$2"
GITHUB_REPOSITORY="$3"
PR="$4"

git config --global user.name "local"
git config --global user.email "local@users.noreply.github.com"

echo "Target ($SPACE): $GITHUB_REPOSITORY PR: $PR"

ls -l "$GITHUB_WORKSPACE/$BASE_DIR"
if ! test -d "$GITHUB_WORKSPACE/$BASE_DIR/src"; then
echo "Cloning https://github.com/$GITHUB_REPOSITORY"
git clone --depth 1 "https://github.com/$GITHUB_REPOSITORY" \
$GITHUB_WORKSPACE/$BASE_DIR/src
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll probably want to run shellcheck on that portion of the script, see also #5 which does that for the rest of the script.

fi
set_git_safe_dir $GITHUB_WORKSPACE/$BASE_DIR/src

if ! test -d "$GITHUB_WORKSPACE/$BASE_DIR/ell"; then
clone_ell $GITHUB_WORKSPACE/$BASE_DIR/ell
fi
set_git_safe_dir $GITHUB_WORKSPACE/$BASE_DIR/ell

mkdir $GITHUB_WORKSPACE/$BASE_DIR/patch

if [ $SPACE == "kernel" ]; then
if ! test -d "$GITHUB_WORKSPACE/$BASE_DIR/bluez"; then
clone_bluez $GITHUB_WORKSPACE/$BASE_DIR/bluez
fi
set_git_safe_dir $GITHUB_WORKSPACE/$BASE_DIR/bluez
/ci.py -c /config.json -z $GITHUB_WORKSPACE/$BASE_DIR/bluez \
-e $GITHUB_WORKSPACE/$BASE_DIR/ell \
-k $GITHUB_WORKSPACE/$BASE_DIR/src \
-p $GITHUB_WORKSPACE/$BASE_DIR/patch \
kernel $GITHUB_REPOSITORY $PR \
--dry-run -j auto
elif [ $SPACE == "user" ]; then
/ci.py -c /config.json -z $GITHUB_WORKSPACE/$BASE_DIR/src \
-e $GITHUB_WORKSPACE/$BASE_DIR/ell \
-p $GITHUB_WORKSPACE/$BASE_DIR/patch \
user $GITHUB_REPOSITORY $PR \
--dry-run -j auto
else
echo "Unknown SPACE: $SPACE"
exit 1
fi
;;
*)
echo "Unknown TASK: $TASK"
eixt 1
exit 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed this separately in #5

;;
esac

Expand Down
Loading