twister: set both commit and run date in json report
Version is not enough, we need the run date but also the commit date, to ease reporting and use in dashboards. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
148a6e2ee1
commit
8f5d0a77b0
2 changed files with 15 additions and 1 deletions
|
@ -13,6 +13,7 @@ import subprocess
|
|||
import shutil
|
||||
import re
|
||||
import argparse
|
||||
from datetime import datetime, timezone
|
||||
|
||||
logger = logging.getLogger('twister')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
@ -662,6 +663,8 @@ class TwisterEnv:
|
|||
def __init__(self, options=None) -> None:
|
||||
self.version = None
|
||||
self.toolchain = None
|
||||
self.commit_date = None
|
||||
self.run_date = None
|
||||
self.options = options
|
||||
if options and options.ninja:
|
||||
self.generator_cmd = "ninja"
|
||||
|
@ -690,6 +693,7 @@ class TwisterEnv:
|
|||
def discover(self):
|
||||
self.check_zephyr_version()
|
||||
self.get_toolchain()
|
||||
self.run_date = datetime.now(timezone.utc).isoformat(timespec='seconds')
|
||||
|
||||
def check_zephyr_version(self):
|
||||
try:
|
||||
|
@ -708,6 +712,14 @@ class TwisterEnv:
|
|||
except OSError:
|
||||
logger.info("Cannot read zephyr version.")
|
||||
|
||||
subproc = subprocess.run(["git", "show", "-s", "--format=%cI", "HEAD"],
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
cwd=ZEPHYR_BASE)
|
||||
if subproc.returncode == 0:
|
||||
self.commit_date = subproc.stdout.strip()
|
||||
else:
|
||||
self.commit_date = "Unknown"
|
||||
|
||||
@staticmethod
|
||||
def run_cmake_script(args=[]):
|
||||
|
|
|
@ -237,7 +237,9 @@ class Reporting:
|
|||
report = {}
|
||||
report["environment"] = {"os": os.name,
|
||||
"zephyr_version": version,
|
||||
"toolchain": self.env.toolchain
|
||||
"toolchain": self.env.toolchain,
|
||||
"commit_date": self.env.commit_date,
|
||||
"run_date": self.env.run_date
|
||||
}
|
||||
suites = []
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue