-
Notifications
You must be signed in to change notification settings - Fork 2
ci: add CheckKernelLLVM #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'], | ||
|
|
@@ -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") | ||
|
|
@@ -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()) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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") | ||
|
|
||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
|
|
||
| set -e | ||
|
|
||
| export PATH=/opt/llvm/bin:$PATH | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
|
|
@@ -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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've fixed this separately in #5 |
||
| ;; | ||
| esac | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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
jobsvariable being either a string or an int.