public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 08/19] oe-build-perf-test: support committing results data to Git
Date: Wed, 24 Aug 2016 10:12:58 +0300	[thread overview]
Message-ID: <1472022789-13028-9-git-send-email-markus.lehtonen@linux.intel.com> (raw)
In-Reply-To: <1472022789-13028-1-git-send-email-markus.lehtonen@linux.intel.com>

Implement a new command line option '--commit-results' which commits the
test results data into a Git repository. The given path must be an
existing initialized local Git repository.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
 meta/lib/oeqa/buildperf/base.py | 35 +++++++++++++++++++++++++++++++++++
 scripts/oe-build-perf-test      |  5 +++++
 2 files changed, 40 insertions(+)

diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index 0e77aae..8f7d88c 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -188,6 +188,41 @@ class BuildPerfTestResult(unittest.TextTestResult):
             fobj.write(','.join(values) + '\n')
 
 
+    def git_commit_results(self, repo_path, branch=None):
+        """Commit results into a Git repository"""
+        repo = GitRepo(repo_path, is_topdir=True)
+        if not branch:
+            branch = self.git_branch
+        log.info("Committing test results into %s %s", repo_path, branch)
+        tmp_index = os.path.join(repo_path, '.git', 'index.oe-build-perf')
+        try:
+            # Create new commit object from the new results
+            env_update = {'GIT_INDEX_FILE': tmp_index,
+                          'GIT_WORK_TREE': self.out_dir}
+            repo.run_cmd('add .', env_update)
+            tree = repo.run_cmd('write-tree', env_update)
+            parent = repo.rev_parse(branch)
+            msg = "Results of {}:{}\n".format(self.git_branch, self.git_commit)
+            git_cmd = ['commit-tree', tree, '-m', msg]
+            if parent:
+                git_cmd += ['-p', parent]
+            commit = repo.run_cmd(git_cmd, env_update)
+
+            # Update branch head
+            git_cmd = ['update-ref', 'refs/heads/' + branch, commit]
+            if parent:
+                git_cmd.append(parent)
+            repo.run_cmd(git_cmd)
+
+            # Update current HEAD, if we're on branch 'branch'
+            if repo.get_current_branch() == branch:
+                log.info("Updating %s HEAD to latest commit", repo_path)
+                repo.run_cmd('reset --hard')
+        finally:
+            if os.path.exists(tmp_index):
+                os.unlink(tmp_index)
+
+
 class BuildPerfTestCase(unittest.TestCase):
     """Base class for build performance tests"""
     SYSRES = 'sysres'
diff --git a/scripts/oe-build-perf-test b/scripts/oe-build-perf-test
index 21759c6..d6ea5ce 100755
--- a/scripts/oe-build-perf-test
+++ b/scripts/oe-build-perf-test
@@ -109,6 +109,9 @@ def parse_args(argv):
                         help="Output directory for test results")
     parser.add_argument('--run-tests', nargs='+', metavar='TEST',
                         help="List of tests to run")
+    parser.add_argument('--commit-results', metavar='GIT_DIR',
+                        type=os.path.abspath,
+                        help="Commit result data to a (local) git repository")
 
     return parser.parse_args(argv)
 
@@ -158,6 +161,8 @@ def main(argv=None):
     if result.wasSuccessful():
         if args.globalres_file:
             result.update_globalres_file(args.globalres_file)
+        if args.commit_results:
+            result.git_commit_results(args.commit_results)
         return 0
 
     return 1
-- 
2.6.6



  parent reply	other threads:[~2016-08-24  7:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24  7:12 [PATCH 00/19] oe-build-pef-test: support saving results in a Git repo Markus Lehtonen
2016-08-24  7:12 ` [PATCH 01/19] oe-build-perf-test: implement --run-tests option Markus Lehtonen
2016-08-24  7:12 ` [PATCH 02/19] oe-build-perf-test: use absolute paths in cmdline args Markus Lehtonen
2016-08-24  7:12 ` [PATCH 03/19] oeqa.utils.git: support git commands with updated env Markus Lehtonen
2016-08-24  7:12 ` [PATCH 04/19] oeqa.utils.git: introduce GitRepo.rev_parse() Markus Lehtonen
2016-08-24  7:12 ` [PATCH 05/19] oeqa.utils.git: implement GitRepo.get_current_branch() Markus Lehtonen
2016-08-24  7:12 ` [PATCH 06/19] oeqa.utils.git.GitRepo: new arg to require topdir Markus Lehtonen
2016-08-24  7:12 ` [PATCH 07/19] oeqa.buildperf: use term commit instead of revision Markus Lehtonen
2016-08-24  7:12 ` Markus Lehtonen [this message]
2016-08-24  7:12 ` [PATCH 09/19] oe-build-perf-test: implement --commit-results-branch Markus Lehtonen
2016-08-24  7:13 ` [PATCH 10/19] oeqa.utils.git: implement init() method Markus Lehtonen
2016-08-24  7:13 ` [PATCH 11/19] oe-build-perf-test: pre-check Git repo when using --commit-results Markus Lehtonen
2016-08-24  7:13 ` [PATCH 12/19] oe-build-perf-test: tag results committed to Git Markus Lehtonen
2016-08-24  7:13 ` [PATCH 13/19] oe-build-perf-test: new {tag_num} keyword for --commit-results-tag Markus Lehtonen
2016-08-24  7:13 ` [PATCH 14/19] oeqa.buildperf: add git commit count to result data Markus Lehtonen
2016-08-24  7:13 ` [PATCH 15/19] oe-build-perf-test: add {git_commit_count} keyword for --commit-results-tag Markus Lehtonen
2016-08-24  7:13 ` [PATCH 16/19] build-perf-test-wrapper.sh: parse args with getopts Markus Lehtonen
2016-08-24  7:13 ` [PATCH 17/19] build-perf-test-wrapper.sh: allow saving results in Git Markus Lehtonen
2016-08-24  7:13 ` [PATCH 18/19] build-perf-test-wrapper.sh: make archive dir configurable Markus Lehtonen
2016-08-24  7:13 ` [PATCH 19/19] build-perf-test-wrapper.sh: make workdir configurable Markus Lehtonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472022789-13028-9-git-send-email-markus.lehtonen@linux.intel.com \
    --to=markus.lehtonen@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox