]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/script/build-integration-branch 17382/head
authorSage Weil <sage@redhat.com>
Wed, 30 Aug 2017 20:42:19 +0000 (16:42 -0400)
committerSage Weil <sage@redhat.com>
Thu, 31 Aug 2017 02:53:10 +0000 (22:53 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
doc/dev/testing.rst [new file with mode: 0644]
src/script/build-integration-branch [new file with mode: 0755]

diff --git a/doc/dev/testing.rst b/doc/dev/testing.rst
new file mode 100644 (file)
index 0000000..1d99848
--- /dev/null
@@ -0,0 +1,40 @@
+Testing notes
+=============
+
+
+build-integration-branch
+------------------------
+
+Setup
+^^^^^
+
+#. Create a github token at `<https://github.com/settings/tokens>`_
+   and put it in ``~/.github_token``.  Note that only the
+   ``public_repo`` under the ``repo`` section needs to be checked.
+
+#. Create a ceph repo label `wip-yourname-testing` if you don't
+   already have one at `<https://github.com/ceph/ceph/labels>`_.
+
+#. Create the ``ci`` remote::
+
+     git remote add ci git@github.com:ceph/ceph-ci
+
+Using
+^^^^^
+
+#. Tag some subset of `needs-qa` commits with your label (usually `wip-yourname-testing`).
+
+#. Create the integration branch::
+
+     git checkout master
+     git pull
+     ../src/script/build-integration-branch wip-yourname-testing
+
+#. Smoke test::
+
+     make && ctest -j12
+
+#. Push to ceph-ci::
+
+     git push ci $(git rev-parse --abbrev-ref HEAD)
+
diff --git a/src/script/build-integration-branch b/src/script/build-integration-branch
new file mode 100755 (executable)
index 0000000..9ac3f0c
--- /dev/null
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+import json
+import os
+import requests
+from subprocess import call
+import sys
+import time
+
+label = sys.argv[1]
+repo = "ceph/ceph"
+
+with open(os.environ['HOME'] + '/.github_token', 'r') as myfile:
+    token = myfile.readline().strip()
+
+# get prs
+baseurl = 'https://api.github.com/repos/{repo}/issues?labels={label}&access_token={token}'
+url = baseurl.format(
+    label=label,
+    repo=repo,
+    token=token)
+r = requests.get(url)
+assert(r.ok)
+j = json.loads(r.text or r.content)
+print("--- found %d issues tagged with %s" % (len(j), label))
+
+prs = []
+for issue in j:
+    if 'pull_request' not in issue:
+        continue
+    r = requests.get(issue['pull_request']['url'] + '?access_token=' + token)
+    prs.append(json.loads(r.text or r.content))
+print("--- queried %s prs" % len(prs))
+
+# name branch
+TIME_FORMAT = '%Y-%m-%d-%H%M'
+branch = label + "-" + time.strftime(TIME_FORMAT, time.localtime())
+print "branch %s" % branch
+
+# assemble
+print('--- creating branch %s' % branch)
+call(['git', 'branch', '-D', branch])
+call(['git', 'checkout', '-b', branch])
+for pr in prs:
+    print('--- pr %d --- pulling %s branch %s' % (
+        pr['number'],
+        pr['head']['repo']['clone_url'],
+        pr['head']['ref']))
+    call(['git', 'pull', '--no-edit',
+          pr['head']['repo']['clone_url'],
+          pr['head']['ref']
+    ])
+print('--- done')
+print('--- perhaps you want to: make && ctest -j12 && git push ci %s' % branch)