Skip to content

Commit dfcbec7

Browse files
author
Linux RISC-V bot
committed
Adding CI files
1 parent eed108e commit dfcbec7

117 files changed

Lines changed: 11276 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# SPDX-FileCopyrightText: 2024 Rivos Inc.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
set -euox pipefail
7+
d=$(dirname "${BASH_SOURCE[0]}")
8+
. $d/series/utils.sh
9+
10+
logs=$(get_logs_dir)
11+
f=${logs}/build_ubuntu_defconfig.log
12+
13+
date -Iseconds | tee -a ${f}
14+
echo "Build an ubuntu kernel" | tee -a ${f}
15+
echo "Top 16 commits" | tee -a ${f}
16+
git log -16 --abbrev=12 --pretty="commit %h (\"%s\")" | tee -a ${f}
17+
18+
kernel_base_sha=$(git log -1 --pretty=%H $(git log -1 --reverse --pretty=%H .github)^)
19+
echo "build_name $(git describe --tags ${kernel_base_sha})" | tee -a ${f}
20+
build_name=$(git describe --tags ${kernel_base_sha})
21+
22+
# Build the kernel that will run LTP
23+
export CI_TRIPLE="riscv64-linux-gnu"
24+
cp $d/series/kconfigs/ubuntu_defconfig arch/riscv/configs/
25+
$d/series/kernel_builder.sh rv64 testsuites plain gcc | tee -a ${f}
26+
27+
kernel_dir="/build/$(gen_kernel_name rv64 testsuites plain gcc)"
28+
echo $build_name > $kernel_dir/kernel_version
29+
#tar cJvf --exclude $(basename $kernel_path) modules.tar.xz /build/$(gen_kernel_name rv64 testsuites plain gcc)/

.github/scripts/ci/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .base import Base, EndTest, Verdict, submit_pw_check
2+
from .shelltest import ShellTest

.github/scripts/ci/base.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
from abc import ABC, abstractmethod
2+
from enum import Enum
3+
import time
4+
import sys
5+
6+
from libs import utils
7+
8+
sys.path.insert(0, '../libs')
9+
from libs import log_debug
10+
11+
class Verdict(Enum):
12+
PENDING = 0
13+
PASS = 1
14+
FAIL = 2
15+
ERROR = 3
16+
SKIP = 4
17+
WARNING = 5
18+
19+
20+
class EndTest(Exception):
21+
"""
22+
End of Test
23+
"""
24+
25+
class Base(ABC):
26+
"""
27+
Base class for CI Tests.
28+
"""
29+
def __init__(self):
30+
self.start_time = 0
31+
self.end_time = 0
32+
self.verdict = Verdict.PENDING
33+
self.output = ""
34+
35+
def success(self):
36+
self.end_timer()
37+
self.verdict = Verdict.PASS
38+
39+
def error(self, msg):
40+
self.verdict = Verdict.ERROR
41+
self.output = msg
42+
self.end_timer()
43+
raise EndTest
44+
45+
def warning(self, msg):
46+
self.verdict = Verdict.WARNING
47+
self.output = msg
48+
self.end_timer()
49+
50+
def skip(self, msg):
51+
self.verdict = Verdict.SKIP
52+
self.output = msg
53+
self.end_timer()
54+
raise EndTest
55+
56+
def add_failure(self, msg):
57+
self.verdict = Verdict.FAIL
58+
if not self.output:
59+
self.output = msg
60+
else:
61+
self.output += "\n" + msg
62+
63+
def add_failure_end_test(self, msg):
64+
self.add_failure(msg)
65+
self.end_timer()
66+
raise EndTest
67+
68+
def start_timer(self):
69+
self.start_time = time.time()
70+
71+
def end_timer(self):
72+
self.end_time = time.time()
73+
74+
def elapsed(self):
75+
if self.start_time == 0:
76+
return 0
77+
if self.end_time == 0:
78+
self.end_timer()
79+
return self.end_time - self.start_time
80+
81+
def log_err(self, msg):
82+
utils.log_error(f"CI: {self.name}: {msg}")
83+
84+
def log_info(self, msg):
85+
utils.log_info(f"CI: {self.name}: {msg}")
86+
87+
def log_dbg(self, msg):
88+
utils.log_debug(f"CI: {self.name}: {msg}")
89+
90+
@abstractmethod
91+
def run(self, worktree=None):
92+
"""
93+
The child class should implement run() method
94+
If the test fail, it should raise the EndTest exception
95+
"""
96+
pass
97+
98+
@abstractmethod
99+
def post_run(self):
100+
"""
101+
The child class should implement post_run() method
102+
"""
103+
pass
104+
105+
106+
def submit_pw_check(pw, patch, name, verdict, desc, url=None, dry_run=False):
107+
108+
utils.log_debug(f"Submitting the result to PW: dry_run={dry_run}")
109+
110+
if not dry_run:
111+
state = 0
112+
113+
if verdict == Verdict.PASS:
114+
state = 1
115+
if verdict == Verdict.WARNING:
116+
state = 2
117+
if verdict == Verdict.FAIL:
118+
state = 3
119+
120+
pw.post_check(patch, name, state, desc, url)

.github/scripts/ci/shelltest.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from gettext import install
2+
import os
3+
import sys
4+
5+
sys.path.insert(0, '../libs')
6+
from libs import RepoTool, cmd_run
7+
8+
from ci import Base, Verdict, EndTest, submit_pw_check
9+
10+
class ShellTest(Base):
11+
"""Run shell test class
12+
This class runs a shell based test
13+
"""
14+
15+
def __init__(self, ci_data, patch, name, desc, sh):
16+
17+
# Common
18+
self.name = name
19+
self.desc = desc
20+
self.ci_data = ci_data
21+
22+
self.sh = sh
23+
self.patch = patch
24+
25+
super().__init__()
26+
27+
self.log_dbg("Initialization completed")
28+
29+
def run(self, worktree=None):
30+
31+
self.log_dbg("Run")
32+
self.start_timer()
33+
34+
current_script_path = os.path.dirname(os.path.abspath(__file__))
35+
36+
cwd = worktree if worktree else self.ci_data.src_dir
37+
cmd = ["bash", f"{current_script_path}/../pw_tests/{self.sh}"]
38+
(ret, stdout, stderr) = cmd_run(cmd, cwd=cwd)
39+
40+
if ret == 0:
41+
submit_pw_check(self.ci_data.pw, self.patch,
42+
self.name, Verdict.PASS,
43+
self.name,
44+
None, self.ci_data.config['dry_run'])
45+
self.success()
46+
elif ret == 250:
47+
url = self.ci_data.gh.create_gist(f"pw{self.ci_data.series['id']}-p{self.patch['id']}",
48+
f"{self.name}-WARNING",
49+
stdout + '\n' + stderr)
50+
submit_pw_check(self.ci_data.pw, self.patch,
51+
self.name, Verdict.WARNING,
52+
self.name,
53+
url, self.ci_data.config['dry_run'])
54+
self.warning(stdout + '\n' + stderr)
55+
else:
56+
url = self.ci_data.gh.create_gist(f"pw{self.ci_data.series['id']}-p{self.patch['id']}",
57+
f"{self.name}-FAIL",
58+
stdout + '\n' + stderr)
59+
submit_pw_check(self.ci_data.pw, self.patch,
60+
self.name, Verdict.FAIL,
61+
self.name,
62+
url, self.ci_data.config['dry_run'])
63+
self.error(stdout + '\n' + stderr)
64+
65+
def post_run(self):
66+
67+
self.log_dbg("Post Run...")

0 commit comments

Comments
 (0)