Example #1
0
class Worker:
    """
    Worker class running all performance measurements currently in queue
    """

    def __init__(self):
        self.checkflow = CheckFlow(initRepo=True)  # Handles Repo, DB and Auth calls


    def checkQueue(self):
        """
        Checks Queue for remaining tests recursively
        :return: True if queue is
        """
        nextUp: QueueObject
        queue = QueueObject.objects(running=False)
        if len(queue) != 0:
            nextUp = queue.order_by('_id').first()  # Should work through queue by FIFO
            del queue
        else:
            return True

        nextUp.running = True
        nextUp.save()  # Update status to running

        # Custom Jobs
        if hasattr(nextUp, 'customYaml') and nextUp.customYaml is not None:
            try:
                # Running Test
                c = Commit(self.checkflow.repo.repo, nextUp.commitSHA)
                self.checkflow.repo._testCommit(c, nextUp, plotting=False)

                # reset to previous state
                self.checkflow.repo.repo.head.reset(self.checkflow.repo.initialHead, index=True, working_tree=True)
                nextUp.status = "completed"
                nextUp.save()
                nextUp.delete()  # Bit unnecessary to change status earlier, but hey

            except Exception as exc:
                nextUp.status = str(exc)
                nextUp.save()

        else:
            try:
                self.checkflow.auth.updateInstallID(nextUp.installID)
                if self.checkflow.runCheck(nextUp):  # Run perf measurements
                    if nextUp.compareUrl is not None:
                        self.checkflow.comparePerformance(nextUp)  # Run comparison
                nextUp.status = "completed"
                nextUp.save()
                nextUp.delete()  # Bit unnecessary to change status earlier, but hey
            except Exception as exc:
                nextUp.status = str(exc)
                nextUp.save()

        # Recursion to check for remaining queue
        if self.checkQueue():
            print('Queue is done')
def addToQueue(c: CheckFlow, sha: str):
    # TODO: Add mode without GitHub interaction and manual DB auth entry
    runUrl = c._createCheckRun(sha, f'MANUAL TEST RUN {time.asctime()}')

    q = QueueObject()
    q.runUrl = runUrl
    q.commitSHA = sha
    q.installID = 2027548
    q.running = False
    q.save()
Example #3
0
def receiveHook(request):
    """ Deal with incoming web hook """

    # On push associated with pull request will receive:
    #   1. Push Event
    #   2. Check_Suite Event
    #   3. Pull Request Event

    pretty_request(request)

    try:
        event_type = request.headers["X-Github-Event"]
        print(f"HOOK CALLED: {event_type}")
    except Exception as e:
        print(e)
        return HttpResponse("Not a X-Github-Event type request.")

    #TODO: HANDLE RE-REQUEST EVENTS for single runs and entire suits

    if "pull_request" in event_type:
        request_json = json.loads(request.body)
        action = request_json["action"]

        # TODO: Re-enable these triggers
        if action == "opened" \
                or action == "synchronize"\
                or action == "reopened":
            print('\n\n\nDEBUG: NOT RUNNING FOR ALL PULL REQUESTS\n\n\n')

        if action == "labeled":
            labels = request_json['pull_request']['labels']
            for l in labels:
                if l['name'] == 'test-performance':
                    print('\n\n\nLABEL-TRIGGER\n\n\n')
                    try:
                        check = CheckFlow()
                        check.receiveHook(request)
                    except Exception as e:
                        print(f"CheckFlow failed with {e}")

                    continue

    return HttpResponse(status=201)
    runUrl = c._createCheckRun(sha, f'MANUAL TEST RUN {time.asctime()}')

    q = QueueObject()
    q.runUrl = runUrl
    q.commitSHA = sha
    q.installID = 2027548
    q.running = False
    q.save()


if __name__ == '__main__':

    # me.connect('performancedb', host='localhost:30017', username=os.environ['USERNAME'],
    #           password=os.environ['PASSWORD'])

    c = CheckFlow(initRepo=True)
    c.auth.updateInstallID(2027548)
    c.baseUrl = "https://api.github.com/repos/AutoPas/AutoPas"

    # Change to Repo
    os.chdir(c.repo.repo.git_dir.strip('.git'))

    # Get all merge commits
    startData = '2020-06-01'
    commitLog = run([
        'git', 'log', '--merges', '--first-parent', 'master', '--since',
        startData
    ],
                    stdout=PIPE,
                    encoding='utf-8')
Example #5
0
 def __init__(self):
     self.checkflow = CheckFlow(initRepo=True)  # Handles Repo, DB and Auth calls
Example #6
0
from mongoDocuments import QueueObject
from checks import CheckFlow

if __name__ == '__main__':

    # me.connect('performancedb', host='localhost:30017', username=os.environ['USERNAME'],
    #           password=os.environ['PASSWORD'])

    q = QueueObject()
    c = CheckFlow(initRepo=False)
    c.auth.updateInstallID(2027548)
    c.baseUrl = "https://api.github.com/repos/AutoPas/AutoPas"

    testSHA = '5c489e1630fb5091b23a40452133223cbf333aea'

    # TODO: Add mode without GitHub interaction and manual DB auth entry

    runUrl = c._createCheckRun(testSHA, 'MANUAL TEST RUN')

    q.runUrl = runUrl
    q.commitSHA = testSHA
    q.installID = 2027548
    q.running = False
    q.save()

    #runUrl = c._createCheckRun(sha, f'MANUAL TEST RUN {time.asctime()}')

    q = QueueObject()
    #q.runUrl = runUrl
    q.commitSHA = sha
    #q.installID = 2027548
    q.running = False
    q.save()


if __name__ == '__main__':

    # me.connect('performancedb', host='localhost:30017', username=os.environ['USERNAME'],
    #           password=os.environ['PASSWORD'])

    c = CheckFlow(initRepo=True)
    #c.auth.updateInstallID(2027548)
    #c.baseUrl = "https://api.github.com/repos/AutoPas/AutoPas"

    # Change to Repo
    os.chdir(c.repo.repo.git_dir.strip('.git'))

    # Get all merge commits
    startData = '2019-01-01'
    endDate = '2020-09-01'
    path = 'src/autopas/molecularDynamics/LJFunctor*'
    commitLog = run(['git', 'log',
                     '--merges',
                     '--first-parent', 'master',
                     '--since', startData,
                     '--until', endDate,
from mongoDocuments import QueueObject
from checks import CheckFlow
import time

if __name__ == '__main__':

    testSHA = "1baed181eaf3e698b8e7061a8ac8d0607844d39f"
    compareSHA = 'a3193c3dfc47afd976b1e1061bddb579b04c7ab9'

    c = CheckFlow(initRepo=False)
    c.baseUrl = "https://api.github.com/repos/AutoPas/AutoPas"
    c.auth.updateInstallID(2027548)
    compareUrl = c._createCheckRun(testSHA, f"MANUAL COMPARE {time.asctime()}")

    q = QueueObject()
    q.compareUrl = compareUrl
    q.commitSHA = testSHA
    q.installID = 2027548
    q.compareOptions = {'0_BaseSHA': compareSHA}
    c.comparePerformance(q)