diff --git a/github/Repository.py b/github/Repository.py index 8ef82de9..7b4f4a22 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -135,6 +135,7 @@ import github.StatsPunchCard import github.Tag import github.Team import github.View +import github.Workflow from . import Consts @@ -3000,6 +3001,29 @@ class Repository(github.GithubObject.CompletableGithubObject): github.NamedUser.NamedUser, self._requester, self.url + "/watchers", None ) + def get_workflows(self): + """ + :calls: `GET /repos/:owner/:repo/actions/workflows `_ + :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Workflow.Workflow` + """ + return github.PaginatedList.PaginatedList( + github.Workflow.Workflow, + self._requester, + self.url + "/actions/workflows", + None, + ) + + def get_workflow(self, id_or_name): + """ + :calls: `GET /repos/:owner/:repo/actions/workflows/:workflow_id `_ + :rtype: :class:`github.Workflow.Workflow` + """ + assert isinstance(id_or_name, int) or isinstance(id_or_name, str), id_or_name + headers, data = self._requester.requestJsonAndCheck( + "GET", self.url + "/actions/workflows/" + id_or_name + ) + return github.Workflow.Workflow(self._requester, headers, data, completed=True) + def has_in_assignees(self, assignee): """ :calls: `GET /repos/:owner/:repo/assignees/:assignee `_ diff --git a/github/Workflow.py b/github/Workflow.py new file mode 100644 index 00000000..b3aa9807 --- /dev/null +++ b/github/Workflow.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- + +############################ Copyrights and license ############################ +# # +# Copyright 2020 Steve Kowalik # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +import github.GithubObject + + +class Workflow(github.GithubObject.CompletableGithubObject): + """ + This class represents Workflows. The reference can be found here https://developer.github.com/v3/actions/workflows/ + """ + + def __repr__(self): + return self.get__repr__({"name": self._name.value, "url": self._url.value}) + + @property + def id(self): + """ + :type: int + """ + self._completeIfNotSet(self._id) + return self._id.value + + @property + def name(self): + """ + :type: string + """ + self._completeIfNotSet(self._name) + return self._name.value + + @property + def path(self): + """ + :type: string + """ + self._completeIfNotSet(self._path) + return self._path.value + + @property + def state(self): + """ + :type: string + """ + self._completeIfNotSet(self._state) + return self._state.value + + @property + def created_at(self): + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def updated_at(self): + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self): + """ + :type: string + """ + self._completeIfNotSet(self._url) + return self._url.value + + @property + def html_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def badge_url(self): + """ + :type: string + """ + self._completeIfNotSet(self._badge_url) + return self._badge_url.value + + def _initAttributes(self): + self._id = github.GithubObject.NotSet + self._name = github.GithubObject.NotSet + self._path = github.GithubObject.NotSet + self._state = github.GithubObject.NotSet + self._created_at = github.GithubObject.NotSet + self._updated_at = github.GithubObject.NotSet + self._url = github.GithubObject.NotSet + self._html_url = github.GithubObject.NotSet + self._badge_url = github.GithubObject.NotSet + + def _useAttributes(self, attributes): + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "path" in attributes: # pragma no branch + self._path = self._makeStringAttribute(attributes["path"]) + if "state" in attributes: # pragma no branch + self._state = self._makeStringAttribute(attributes["state"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "badge_url" in attributes: # pragma no branch + self._badge_url = self._makeStringAttribute(attributes["badge_url"]) diff --git a/github/Workflow.pyi b/github/Workflow.pyi new file mode 100644 index 00000000..1f0b9e65 --- /dev/null +++ b/github/Workflow.pyi @@ -0,0 +1,27 @@ +from datetime import datetime +from typing import Any, Dict + +from github.GithubObject import CompletableGithubObject + +class Deployment(CompletableGithubObject): + def __repr__(self) -> str: ... + def _initAttributes(self) -> None: ... + def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... + @property + def id(self) -> int: ... + @property + def name(self) -> str: ... + @property + def path(self) -> str: ... + @property + def state(self) -> str: ... + @property + def created_at(self) -> datetime: ... + @property + def updated_at(self) -> datetime: ... + @property + def url(self) -> str: ... + @property + def html_url(self) -> str: ... + @property + def badge_url(self) -> str: ... diff --git a/tests/ReplayData/Repository.testGetWorkflows.txt b/tests/ReplayData/Repository.testGetWorkflows.txt new file mode 100644 index 00000000..8ad3cbc1 --- /dev/null +++ b/tests/ReplayData/Repository.testGetWorkflows.txt @@ -0,0 +1,22 @@ +https +GET +api.github.com +None +/repos/PyGithub/PyGithub +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Date', 'Thu, 30 Apr 2020 14:23:31 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Server', 'GitHub.com'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4984'), ('X-RateLimit-Reset', '1588260036'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"ca5e583e90533cae1b4d5dbe1e06ce8e"'), ('Last-Modified', 'Thu, 30 Apr 2020 11:35:51 GMT'), ('X-OAuth-Scopes', 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages'), ('X-Accepted-OAuth-Scopes', 'repo'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'EA20:2BF3:3A538:437A1:5EAADF62')] +{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars0.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2020-04-30T11:35:51Z","pushed_at":"2020-04-29T03:27:15Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":12694,"stargazers_count":3394,"watchers_count":3394,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1099,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":45,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":1099,"open_issues":45,"watchers":3394,"default_branch":"master","permissions":{"admin":false,"push":true,"pull":true},"temp_clone_token":"","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"delete_branch_on_merge":true,"organization":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars0.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"network_count":1099,"subscribers_count":98} + +https +GET +api.github.com +None +/repos/PyGithub/PyGithub/actions/workflows +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Date', 'Thu, 30 Apr 2020 14:23:31 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Server', 'GitHub.com'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4983'), ('X-RateLimit-Reset', '1588260036'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"fc1eaa3814dd3ef6fdb3da89e056c63b"'), ('X-OAuth-Scopes', 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, read:packages, repo, user, workflow, write:discussion, write:packages'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'EA22:67AD:694D5:7A1D2:5EAADF63')] +[{"id":1026390,"node_id":"MDg6V29ya2Zsb3cxMDI2Mzkw","name":"check","path":".github/workflows/check.yml","state":"active","created_at":"2020-04-15T10:48:32.000+10:00","updated_at":"2020-04-15T10:48:32.000+10:00","url":"https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1026390","html_url":"https://github.com/PyGithub/PyGithub/blob/master/.github/workflows/check.yml","badge_url":"https://github.com/PyGithub/PyGithub/workflows/check/badge.svg"},{"id":1122712,"node_id":"MDg6V29ya2Zsb3cxMTIyNzEy","name":"Publish to PyPI","path":".github/workflows/python-publish.yml","state":"active","created_at":"2020-04-26T18:51:02.000+10:00","updated_at":"2020-04-26T18:51:02.000+10:00","url":"https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1122712","html_url":"https://github.com/PyGithub/PyGithub/blob/master/.github/workflows/python-publish.yml","badge_url":"https://github.com/PyGithub/PyGithub/workflows/Publish%20to%20PyPI/badge.svg"}] + diff --git a/tests/ReplayData/Workflow.setUp.txt b/tests/ReplayData/Workflow.setUp.txt new file mode 100644 index 00000000..f4c4ea0d --- /dev/null +++ b/tests/ReplayData/Workflow.setUp.txt @@ -0,0 +1,22 @@ +https +GET +api.github.com +None +/repos/PyGithub/PyGithub +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Date', 'Thu, 30 Apr 2020 11:50:13 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Server', 'GitHub.com'), ('Status', '200 OK'), ('X-RateLimit-Limit', '60'), ('X-RateLimit-Remaining', '59'), ('X-RateLimit-Reset', '1588251013'), ('Cache-Control', 'public, max-age=60, s-maxage=60'), ('Vary', 'Accept, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"c913473c31e05fbce5ff335789f4ba5d"'), ('Last-Modified', 'Thu, 30 Apr 2020 11:35:51 GMT'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'AAA6:1E7E:2D89A:34402:5EAABB75')] +{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars0.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2020-04-30T11:35:51Z","pushed_at":"2020-04-29T03:27:15Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":12694,"stargazers_count":3394,"watchers_count":3394,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1099,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":45,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":1099,"open_issues":45,"watchers":3394,"default_branch":"master","temp_clone_token":null,"organization":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars0.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"network_count":1099,"subscribers_count":98} + +https +GET +api.github.com +None +/repos/PyGithub/PyGithub/actions/workflows/check.yml +{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'} +None +200 +[('Date', 'Thu, 30 Apr 2020 11:50:13 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Server', 'GitHub.com'), ('Status', '200 OK'), ('X-RateLimit-Limit', '60'), ('X-RateLimit-Remaining', '58'), ('X-RateLimit-Reset', '1588251013'), ('Cache-Control', 'public, max-age=60, s-maxage=60'), ('Vary', 'Accept, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"fed4afd3988c2fccd5909e64fb06dfc4"'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'AAA8:1E7E:2D8AA:34416:5EAABB75')] +{"id":1026390,"node_id":"MDg6V29ya2Zsb3cxMDI2Mzkw","name":"check","path":".github/workflows/check.yml","state":"active","created_at":"2020-04-15T00:48:32.000Z","updated_at":"2020-04-15T00:48:32.000Z","url":"https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1026390","html_url":"https://github.com/PyGithub/PyGithub/blob/master/.github/workflows/check.yml","badge_url":"https://github.com/PyGithub/PyGithub/workflows/check/badge.svg"} + diff --git a/tests/Repository.py b/tests/Repository.py index 68407ed0..7b837a61 100644 --- a/tests/Repository.py +++ b/tests/Repository.py @@ -962,6 +962,12 @@ class Repository(Framework.TestCase): ], ) + def testGetWorkflows(self): + workflows = self.g.get_repo("PyGithub/PyGithub").get_workflows() + self.assertListKeyEqual( + workflows, lambda w: w.name, ["check", "Publish to PyPI"] + ) + def testGetSourceImport(self): import_repo = self.g.get_user("brix4dayz").get_repo("source-import-test") source_import = import_repo.get_source_import() diff --git a/tests/Workflow.py b/tests/Workflow.py new file mode 100644 index 00000000..3598fb60 --- /dev/null +++ b/tests/Workflow.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +############################ Copyrights and license ############################ +# # +# Copyright 2020 Steve Kowalik # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +import datetime + +from . import Framework + + +class Workflow(Framework.TestCase): + def setUp(self): + super().setUp() + self.workflow = self.g.get_repo("PyGithub/PyGithub").get_workflow("check.yml") + + def testAttributes(self): + self.assertEqual( + repr(self.workflow), + 'Workflow(url="https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1026390", name="check")', + ) + self.assertEqual(self.workflow.id, 1026390) + self.assertEqual(self.workflow.name, "check") + self.assertEqual(self.workflow.path, ".github/workflows/check.yml") + self.assertEqual(self.workflow.state, "active") + timestamp = datetime.datetime(2020, 4, 15, 0, 48, 32) + self.assertEqual(self.workflow.created_at, timestamp) + self.assertEqual(self.workflow.updated_at, timestamp) + self.assertEqual( + self.workflow.url, + "https://api.github.com/repos/PyGithub/PyGithub/actions/workflows/1026390", + ) + self.assertEqual( + self.workflow.html_url, + "https://github.com/PyGithub/PyGithub/blob/master/.github/workflows/check.yml", + ) + self.assertEqual( + self.workflow.badge_url, + "https://github.com/PyGithub/PyGithub/workflows/check/badge.svg", + )