Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,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
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

18 changes: 12 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,13 @@ 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)

self.log_dbg("Initialization completed")

Expand All @@ -52,7 +58,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 +70,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 +92,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
2 changes: 2 additions & 0 deletions ci/generickernelbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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 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
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
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
10 changes: 4 additions & 6 deletions libs/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,15 @@ def __init__(self, config_file=None, github_repo=None, src_dir=None,
# Init github
log_info(f"Initialize Github: {github_repo}")
if 'GITHUB_TOKEN' not in os.environ:
log_error("Set GITHUB_TOKEN environment variable")
raise ContextError
log_info("GITHUB_TOKEN environment variable not set")

# Use a separate token for Check Runs API (requires GitHub App token,
# not a PAT). Falls back to GITHUB_TOKEN if not set.
checks_token = os.environ.get('GITHUB_CHECKS_TOKEN',
os.environ['GITHUB_TOKEN'])
token = os.environ.get('GITHUB_TOKEN', None)
checks_token = os.environ.get('GITHUB_CHECKS_TOKEN', token)

try:
self.gh = GithubTool(github_repo, os.environ['GITHUB_TOKEN'],
checks_token=checks_token)
self.gh = GithubTool(github_repo, token, checks_token=checks_token)
except:
log_error("Failed to initialize GithubTool class")
raise ContextError
Expand Down