Exemple #1
0
    def start_publishing(self, host, github):
        identifier = self.name + "-" + self.revision[0:8] + "-" + self.context.replace("/", "-")
        description = "{0} [{1}]".format(testinfra.TESTING, testinfra.HOSTNAME)
        status = {
            "github": {
                "resource": github.qualify("statuses/" + self.revision),
                "status": {
                    "state": "pending",
                    "context": self.context,
                    "description": description,
                }
            },
            "revision": self.revision,
            "link": "log.html",
            "extras": [ "https://raw.githubusercontent.com/cockpit-project/cockpit/" +
                self.revision + "/test/files/log.html" ]
        }

        (prefix, unused, image) = self.context.partition("/")
        if self.name == "master" and prefix == "verify":
            status['irc'] = { }    # Only send to IRC when master
            status['badge'] = {
                'name': image,
                'description': image,
                'status': 'running'
            }

        # For other scripts to use
        os.environ["TEST_DESCRIPTION"] = description
        self.sink = testinfra.Sink(host, identifier, status)
Exemple #2
0
 def start_publishing(self, host, github):
     identifier = self.name + "-" + time.strftime("%Y-%m-%d")
     status = {
         "github": {
             "token":
             github.token,
             "requests": [
                 # Create issue
                 {
                     "method": "POST",
                     "resource": github.qualify("issues"),
                     "data": {
                         "title":
                         testinfra.ISSUE_TITLE_IMAGE_REFRESH.format(
                             self.image),
                         "labels": ["bot"],
                         "body":
                         ("Image creation for %s in process on %s.\nLog: :link"
                          % (self.image, testinfra.HOSTNAME))
                     },
                     "result": "issue"
                 }
             ]
         },
         "onaborted": {
             "github": {
                 "token":
                 github.token,
                 "requests": [
                     # Post comment about failure
                     {
                         "method": "POST",
                         "resource": ":issue.comments_url",
                         "data": {
                             "body": "Image creation aborted",
                         }
                     }
                 ]
             },
         }
     }
     self.sink = testinfra.Sink(host, identifier, status)
    def start_publishing(self, host, github):
        identifier = self.name + "-" + self.revision[
            0:8] + "-" + self.context.replace("/", "-")
        description = "{0} [{1}]".format(testinfra.TESTING, testinfra.HOSTNAME)

        self.github_status_data = {
            "state": "pending",
            "context": self.context,
            "description": description,
            "target_url": ":link"
        }

        status = {
            "github": {
                "token":
                github.token,
                "requests": [
                    # Set status to pending
                    {
                        "method": "POST",
                        "resource":
                        github.qualify("statuses/" + self.revision),
                        "data": self.github_status_data
                    }
                ]
            },
            "revision":
            self.revision,
            "link":
            "log.html",
            "extras": [
                "https://raw.githubusercontent.com/cockpit-project/cockpit/master/test/common/log.html"
            ],
            "onaborted": {
                "github": {
                    "token":
                    github.token,
                    "requests": [
                        # Set status to error
                        {
                            "method": "POST",
                            "resource":
                            github.qualify("statuses/" + self.revision),
                            "data": {
                                "state": "error",
                                "context": self.context,
                                "description": "Aborted without status",
                                "target_url": ":link"
                            }
                        }
                    ]
                },
            }
        }

        (prefix, unused, image) = self.context.partition("/")
        if self.name == "master" and prefix == "verify":
            status['irc'] = {}  # Only send to IRC when master
            status['badge'] = {
                'name': image,
                'description': image,
                'status': 'running'
            }
            status['onaborted']['badge'] = {
                'name': image,
                'description': image,
                'status': 'error'
            }

        # For other scripts to use
        os.environ["TEST_DESCRIPTION"] = description
        self.sink = testinfra.Sink(host, identifier, status)
Exemple #4
0
    def start_publishing(self, host, github):
        if self.pull:
            identifier = self.name + "-" + self.pull['head']['sha']
        else:
            identifier = self.name + "-" + time.strftime("%Y-%m-%d")

        requests = []

        body_text = ("Image creation for %s in process on %s.\nLog: :link" %
                     (self.image, testinfra.HOSTNAME))

        if self.issue:
            requests += [
                # Get issue
                {
                    "method":
                    "GET",
                    "resource":
                    github.qualify("issues/" + str(self.issue['number'])),
                    "result":
                    "issue"
                },
                # Add comment
                {
                    "method": "POST",
                    "resource": ":issue.comments_url",
                    "data": {
                        "body": body_text
                    }
                }
            ]
        else:
            requests += [
                # Create issue
                {
                    "method": "POST",
                    "resource": github.qualify("issues"),
                    "data": {
                        "title":
                        testinfra.ISSUE_TITLE_IMAGE_REFRESH.format(self.image),
                        "labels": ["bot"],
                        "body":
                        body_text
                    },
                    "result": "issue"
                }
            ]

        status = {
            "github": {
                "token": github.token,
                "requests": requests
            },
            "onaborted": {
                "github": {
                    "token":
                    github.token,
                    "requests": [
                        # Post comment about failure
                        {
                            "method": "POST",
                            "resource": ":issue.comments_url",
                            "data": {
                                "body": "Image creation aborted",
                            }
                        }
                    ]
                },
            }
        }
        self.sink = testinfra.Sink(host, identifier, status)