Ejemplo n.º 1
0
    def get(self, path, pr):
        # pylint: disable=too-many-locals
        org, repo = org_repo(path)
        path = pr_path(org, repo, pr)
        builds = pr_builds(path)
        # TODO(fejta): assume all builds are monotonically increasing.
        for bs in builds.itervalues():
            if any(len(b) > 8 for b, _, _ in bs):
                bs.sort(key=lambda (b, s, f): -(s or {}).get('timestamp', 0))
        if pr == 'batch':  # truncate batch results to last day
            cutoff = time.time() - 60 * 60 * 24
            builds = {}
            for job, job_builds in builds.iteritems():
                builds[job] = [(b, s, f) for b, s, f in job_builds
                               if not s or s.get('timestamp') > cutoff]

        max_builds, headings, rows = pull_request.builds_to_table(builds)
        digest = ghm.GHIssueDigest.get('%s/%s' % (org, repo), pr)
        self.render(
            'pr.html',
            dict(
                pr=pr,
                digest=digest,
                max_builds=max_builds,
                header=headings,
                org=org,
                repo=repo,
                rows=rows,
                path=path,
            ))
Ejemplo n.º 2
0
 def get(self, path, pr):
     if path:
         repo = 'kubernetes/%s' % path.strip('/')
     else:
         path = ''
         repo = 'kubernetes/kubernetes'
     builds = pr_builds(path, pr)
     if pr == 'batch':  # truncate batch results to last day
         cutoff = time.time() - 60 * 60 * 24
         builds = {
             j: [(b, s, f) for b, s, f in bs
                 if not s or s['timestamp'] > cutoff]
             for j, bs in builds.iteritems()
         }
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     digest = ghm.GHIssueDigest.get(repo, pr)
     self.render(
         'pr.html',
         dict(pr=pr,
              prefix=PR_PREFIX,
              digest=digest,
              max_builds=max_builds,
              header=headings,
              repo=repo,
              rows=rows,
              path=path))
Ejemplo n.º 3
0
 def get(self, path, pr):
     if path:
         repo = 'kubernetes/%s' % path.strip('/')
     else:
         path = ''
         repo = 'kubernetes/kubernetes'
     builds = pr_builds(path, pr)
     for bs in builds.itervalues():
         if any(len(b) > 8 for b, _, _ in bs):
             # Long builds indicate non sequential build numbers, sort them.
             # These builds shouldn't be created going forwards, so this
             # should be dead code once all the old PRs are finished.
             # -- rmmh 2017-01-13
             bs.sort(key=lambda (b, s, f): -(s or {}).get('timestamp', 0))
     if pr == 'batch':  # truncate batch results to last day
         cutoff = time.time() - 60 * 60 * 24
         builds = {
             j: [(b, s, f) for b, s, f in bs
                 if not s or s['timestamp'] > cutoff]
             for j, bs in builds.iteritems()
         }
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     digest = ghm.GHIssueDigest.get(repo, pr)
     self.render(
         'pr.html',
         dict(pr=pr,
              prefix=PR_PREFIX,
              digest=digest,
              max_builds=max_builds,
              header=headings,
              repo=repo,
              rows=rows,
              path=path))
Ejemplo n.º 4
0
    def test_builds_to_table(self):
        jobs = {'J1': [make(4, 'v2', 'A', 9), make(3, 'v2', 'B', 10)],
                'J2': [make(5, 'v1', 'C', 7), make(4, 'v1', 'D', 6)]}
        max_builds, headings, rows = pull_request.builds_to_table(jobs)

        self.assertEqual(max_builds, 4)
        self.assertEqual(headings, [('v2', 2, 9), ('v1', 2, 6)])
        self.assertEqual(rows, [('J1', [(4, 'A'), (3, 'B')]),
                                ('J2', [None, None, (5, 'C'), (4, 'D')])])
    def test_builds_to_table_podutils(self):
        jobs = {'J1': [makePodutil(4, 'v2', 'A', 9), makePodutil(3, 'v2', 'B', 10)],
                'J2': [makePodutil(5, 'v1', 'C', 7), makePodutil(4, 'v1', 'D', 6)]}
        max_builds, headings, rows = pull_request.builds_to_table(jobs)

        self.assertEqual(max_builds, 4)
        self.assertEqual(headings, [('v2', 2, 9), ('v1', 2, 6)])
        self.assertEqual(rows, [('J1', [(4, 'A'), (3, 'B')]),
                                ('J2', [None, None, (5, 'C'), (4, 'D')])])
Ejemplo n.º 6
0
 def get(self, pr):
     builds = pr_builds(pr)
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     self.render(
         'pr.html',
         dict(pr=pr,
              prefix=PR_PREFIX,
              max_builds=max_builds,
              header=headings,
              rows=rows))
Ejemplo n.º 7
0
 def get(self, pr):
     builds = pr_builds(pr)
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     digest = ghm.GHIssueDigest.get('kubernetes/kubernetes', pr)
     self.render(
         'pr.html',
         dict(pr=pr,
              prefix=PR_PREFIX,
              digest=digest,
              max_builds=max_builds,
              header=headings,
              rows=rows))
Ejemplo n.º 8
0
 def get(self, path, pr):
     if path:
         repo = 'kubernetes/%s' % path.strip('/')
     else:
         path = ''
         repo = 'kubernetes/kubernetes'
     builds = pr_builds(path, pr)
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     digest = ghm.GHIssueDigest.get(repo, pr)
     self.render(
         'pr.html',
         dict(pr=pr,
              prefix=PR_PREFIX,
              digest=digest,
              max_builds=max_builds,
              header=headings,
              repo=repo,
              rows=rows,
              path=path))
Ejemplo n.º 9
0
    def get(self, path, pr):
        # pylint: disable=too-many-locals
        org, repo = org_repo(path=path,
            default_org=self.app.config['default_org'],
            default_repo=self.app.config['default_repo'],
        )
        path = pr_path(org=org, repo=repo, pr=pr,
            pull_prefix=self.app.config['external_services'][org]['gcs_pull_prefix'],
            default_org=self.app.config['default_org'],
            default_repo=self.app.config['default_repo'],
        )
        builds = pr_builds(path)
        # TODO(fejta): assume all builds are monotonically increasing.
        for bs in builds.itervalues():
            if any(len(b) > 8 for b, _, _ in bs):
                bs.sort(key=lambda (b, s, f): -(s or {}).get('timestamp', 0))
        if pr == 'batch':  # truncate batch results to last day
            cutoff = time.time() - 60 * 60 * 24
            builds = {}
            for job, job_builds in builds.iteritems():
                builds[job] = [
                    (b, s, f) for b, s, f in job_builds
                    if not s or s.get('timestamp') > cutoff
                ]

        max_builds, headings, rows = pull_request.builds_to_table(builds)
        digest = ghm.GHIssueDigest.get('%s/%s' % (org, repo), pr)
        self.render(
            'pr.html',
            dict(
                pr=pr,
                digest=digest,
                max_builds=max_builds,
                header=headings,
                org=org,
                repo=repo,
                rows=rows,
                path=path,
            )
        )
Ejemplo n.º 10
0
 def get(self, path, pr):
     if path:
         repo = 'kubernetes/%s' % path.strip('/')
     else:
         path = ''
         repo = 'kubernetes/kubernetes'
     builds = pr_builds(path, pr)
     for bs in builds.itervalues():
         if any(len(b) > 8 for b, _, _ in bs):
             # Long builds indicate non sequential build numbers, sort them.
             # These builds shouldn't be created going forwards, so this
             # should be dead code once all the old PRs are finished.
             # -- rmmh 2017-01-13
             bs.sort(key=lambda (b, s, f): -(s or {}).get('timestamp', 0))
     if pr == 'batch':  # truncate batch results to last day
         cutoff = time.time() - 60 * 60 * 24
         builds = {j: [(b, s, f) for b, s, f in bs if not s or s['timestamp'] > cutoff]
                   for j, bs in builds.iteritems()}
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     digest = ghm.GHIssueDigest.get(repo, pr)
     self.render('pr.html', dict(pr=pr, prefix=PR_PREFIX, digest=digest,
         max_builds=max_builds, header=headings, repo=repo, rows=rows, path=path))
Ejemplo n.º 11
0
 def get(self, pr):
     builds = pr_builds(pr)
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     digest = ghm.GHIssueDigest.get('kubernetes/kubernetes', pr)
     self.render('pr.html', dict(pr=pr, prefix=PR_PREFIX, digest=digest,
         max_builds=max_builds, header=headings, rows=rows))
Ejemplo n.º 12
0
 def test_builds_to_table_no_header(self):
     jobs = {'J': [make(5, None, 'A', 3), make(4, '', 'B', 2)]}
     self.assertEqual(pull_request.builds_to_table(jobs),
                      (0, [], [('J', [(5, 'A'), (4, 'B')])]))
Ejemplo n.º 13
0
 def get(self, pr):
     builds = pr_builds(pr)
     max_builds, headings, rows = pull_request.builds_to_table(builds)
     self.render('pr.html', dict(pr=pr, prefix=PR_PREFIX,
         max_builds=max_builds, header=headings, rows=rows))
Ejemplo n.º 14
0
 def test_pull_ref_commit(self):
     jobs = {'J1': [make(4, 'v2', 'A', 9)]}
     jobs['J1'][0][1]['pull'] = 'master:1234,35:abcd'
     _, headings, _ = pull_request.builds_to_table(jobs)
     self.assertEqual(headings, [('abcd', 1, 9)])
Ejemplo n.º 15
0
 def test_builds_to_table_no_header(self):
     jobs = {'J': [make(5, None, 'A', 3), make(4, '', 'B', 2)]}
     self.assertEqual(pull_request.builds_to_table(jobs),
                      (0, [], [('J', [(5, 'A'), (4, 'B')])]))
 def test_pull_ref_commit(self):
     jobs = {'J1': [make(4, 'v2', 'A', 9)]}
     jobs['J1'][0][1]['pull'] = 'master:1234,35:abcd'
     _, headings, _ = pull_request.builds_to_table(jobs)
     self.assertEqual(headings, [('abcd', 1, 9)])