From b5c27826158f699960fcf887e901545c359ad68c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 30 Aug 2017 16:42:19 -0400 Subject: [PATCH] src/script/build-integration-branch Signed-off-by: Sage Weil --- doc/dev/testing.rst | 40 +++++++++++++++++++++ src/script/build-integration-branch | 54 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 doc/dev/testing.rst create mode 100755 src/script/build-integration-branch diff --git a/doc/dev/testing.rst b/doc/dev/testing.rst new file mode 100644 index 0000000000000..1d99848a708fb --- /dev/null +++ b/doc/dev/testing.rst @@ -0,0 +1,40 @@ +Testing notes +============= + + +build-integration-branch +------------------------ + +Setup +^^^^^ + +#. Create a github token at ``_ + 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 ``_. + +#. 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 index 0000000000000..9ac3f0c5ff39a --- /dev/null +++ b/src/script/build-integration-branch @@ -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) -- 2.39.5