{"id":3405,"date":"2018-07-30T10:00:52","date_gmt":"2018-07-30T01:00:52","guid":{"rendered":"https:\/\/blog.timecrowd.net\/?p=3405"},"modified":"2018-07-25T18:08:48","modified_gmt":"2018-07-25T09:08:48","slug":"use-github-statuses","status":"publish","type":"post","link":"https:\/\/blog.timecrowd.net\/use-github-statuses\/","title":{"rendered":"Github\u306eStatuses API\u3092\u4f7f\u3044\u3053\u306a\u3059"},"content":{"rendered":"<p>\u5148\u65e5Github\u304cMicrosoft\u306b\u8cb7\u53ce\u3055\u308c\u305f\u3068\u3044\u3046\u30cb\u30e5\u30fc\u30b9\u304c\u98db\u3073\u8fbc\u3093\u3067\u304d\u307e\u3057\u305f\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306f\u4eca\u5f8c\u306e\u52d5\u5411\u304c\u6c17\u306b\u306a\u308b\u4eca\u65e5\u3053\u306e\u9803\u3067\u3059\u3002<\/p>\n<p>\u3064\u3044\u6700\u8fd1\u30af\u30fc\u30e9\u30fc\u3092\u53d6\u308a\u4ed8\u3051\u5feb\u9069\u306b\u4f5c\u696d\u3057\u3066\u3044\u306a\u304c\u3089\u96fb\u6c17\u4ee3\u304c\u6c17\u306b\u306a\u308b\u65c5\u3092\u7d42\u3048\u305f\u30a8\u30f3\u30b8\u30cb\u30a2\u4e09\u5b85\u3067\u3059\u3002<\/p>\n<p>\u4eca\u65e5\u306f\u65e5\u3005\u306e\u958b\u767a\u3067\u5229\u7528\u3057\u3066\u3044\u308bGithub\u306e\u6d3b\u7528\u65b9\u6cd5\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"toc_white no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Statuses_API\"><span class=\"toc_number toc_depth_1\">1<\/span> Statuses API\u3068\u306f<\/a><\/li><li><a href=\"#Statuses_API-2\"><span class=\"toc_number toc_depth_1\">2<\/span> Statuses API\u3092\u4f7f\u3063\u305f\u30b9\u30c6\u30fc\u30bf\u30b9\u306e\u5236\u5fa1<\/a><\/li><li><a href=\"#i\"><span class=\"toc_number toc_depth_1\">3<\/span> \u307e\u3068\u3081<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Statuses_API\">Statuses API\u3068\u306f<\/span><\/h2>\n<p>Github\u306eREST API v3\u306b\u306fStatuses\u3068\u3044\u3046API\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/developer.github.com\/v3\/repos\/statuses\/\" target=\"_blank\" rel=\"noopener\">Statuses | GitHub Developer Guide<\/a><\/p>\n<p>\u672c\u65e5\u306f\u3053\u306eAPI\u306e\u3061\u3087\u3063\u3068\u3057\u305f\u6d3b\u7528\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u3053\u306eStatuses API\u3092\u5229\u7528\u3059\u308b\u3068\u3069\u3093\u306a\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u304b\u3092\u7c21\u5358\u306b\u3054\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>Circle CI\u3084Sider\u306a\u3069\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u65b9\u306f\u65e2\u306b\u3054\u5b58\u77e5\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4ee5\u4e0b\u306e\u8d64\u67a0\u306e\u90e8\u5206\u3092\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308bAPI\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3406\" src=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Github-Statuses.png\" alt=\"\" width=\"1430\" height=\"580\" srcset=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Github-Statuses.png 1430w, https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Github-Statuses-768x311.png 768w\" sizes=\"(max-width: 1430px) 100vw, 1430px\" \/><\/p>\n<p>TimeCrowd\u3067\u306f\u65e5\u3005\u306e\u958b\u767a\u3067PR\u3054\u3068\u306b<a href=\"https:\/\/github.com\/colszowka\/simplecov\" target=\"_blank\" rel=\"noopener\">simplecov<\/a>\u3084<a href=\"https:\/\/github.com\/whitesmith\/rubycritic\" target=\"_blank\" rel=\"noopener\">rubycritc<\/a>\u3092\u5229\u7528\u3057\u3066\u9759\u7684\u306a\u30b3\u30fc\u30c9\u306e\u54c1\u8cea\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u3059\u304c\u3001\u4eca\u307e\u3067\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306bbot\u304c\u30b3\u30e1\u30f3\u30c8\u3092\u3059\u308b\u3088\u3046\u306a\u5f62\u306b\u3057\u3066\u3044\u305f\u305f\u3081\u3001push\u56de\u6570\u304c\u591a\u304f\u306a\u308b\u306b\u9023\u308c\u3066\u30b3\u30e1\u30f3\u30c8\u6b04\u304c\u6c5a\u308c\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u6b20\u70b9\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3407\" src=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/TimeCrowd-Statuses.png\" alt=\"\" width=\"1570\" height=\"542\" srcset=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/TimeCrowd-Statuses.png 1570w, https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/TimeCrowd-Statuses-768x265.png 768w\" sizes=\"(max-width: 1570px) 100vw, 1570px\" \/><\/p>\n<p>\u305d\u3053\u3067\u4f55\u304b\u826f\u3044\u65b9\u6cd5\u306f\u306a\u3044\u304b\u3068\u8abf\u3079\u3066\u3044\u305f\u3068\u3053\u308dGithub\u306eStatuses API\u306b\u8fbf\u308a\u7740\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2><span id=\"Statuses_API-2\">Statuses API\u3092\u4f7f\u3063\u305f\u30b9\u30c6\u30fc\u30bf\u30b9\u306e\u5236\u5fa1<\/span><\/h2>\n<p>\u305d\u308c\u3067\u306fCircle CI\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u4f8b\u306b\u3068\u3063\u3066Statuses API\u3067\u3069\u306e\u3088\u3046\u306b\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u64cd\u4f5c\u3059\u308b\u304b\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f<a href=\"https:\/\/developer.github.com\/v3\/repos\/statuses\/#create-a-status\" target=\"_blank\" rel=\"noopener\">Create a status<\/a>\u306e\u90e8\u5206\u3092\u5229\u7528\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u5bfe\u5fdc\u3059\u308b\u90e8\u5206\u306b\u3064\u3044\u3066\u306f\u4e0b\u8a18\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3408\" src=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Explain-to-create-a-status.png\" alt=\"\" width=\"1440\" height=\"122\" srcset=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Explain-to-create-a-status.png 1440w, https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Explain-to-create-a-status-768x65.png 768w\" sizes=\"(max-width: 1440px) 100vw, 1440px\" \/><\/p>\n<p>status\u306e\u307f\u5fc5\u9808\u3067\u5185\u5bb9\u304c\u6c7a\u307e\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u308c\u4ee5\u5916\u306f\u57fa\u672c\u7684\u306b\u81ea\u7531\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u4e0a\u8a18\u3092\u8e0f\u307e\u3048\u305f\u4e0a\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066coverage\u306e\u7d50\u679c\u3092\u30b9\u30c6\u30fc\u30bf\u30b9\u306b\u8868\u793a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre><code>#!\/usr\/bin\/env bash\r\n\r\nset -eu\r\n\r\nif [ \"$CI_PULL_REQUEST\" == false ] || [ -z \"$CI_PULL_REQUEST\" ]; then\r\n  echo 'not pull request.'\r\n  exit 0\r\nfi\r\n\r\nif [[ $CI_PULL_REQUEST =~ ([0-9]*)$ ]]; then\r\n  PR_NUMBER=${BASH_REMATCH[1]}\r\nelse\r\n  echo 'cannot get pull request number. maybe bug.'\r\n  exit 1\r\nfi\r\n\r\nARTIFACATS_BASE_URL=\"https:\/\/$CIRCLE_BUILD_NUM-xxxxxxx-gh.circle-artifacts.com\/0\"\r\nCOV_URL=\"$ARTIFACATS_BASE_URL\/tmp\/coverage\/index.html\"\r\nCOV_PERCENTAGE=`cat \/tmp\/coverage\/.last_run.json | jq '.result.covered_percent'`\r\nCOV_DESC=\"$COV_PERCENTAGE\\% covered\"\r\nPOST_BODY=\"{\\\"state\\\": \\\"success\\\", \\\"target_url\\\": \\\"$COV_URL\\\", \\\"description\\\": \\\"$COV_PERCENTAGE\\\", \\\"context\\\": \\\"coverage\\\"}\"\r\ncurl -XPOST \\\r\n  -H \"Authorization: token $GITHUB_TOKEN\" \\\r\n  -H \"Content-Type: application\/json\" \\\r\n  -d \"$POST_BODY\" \\\r\n  https:\/\/api.github.com\/repos\/$CIRCLE_PROJECT_USERNAME\/$CIRCLE_PROJECT_REPONAME\/statuses\/$CIRCLE_SHA1<\/code><\/pre>\n<p>simplecov\u3084rubycritic\u306e\u5b9f\u884c\u7d50\u679c\u306f\u8aad\u3081\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306a\u5f62\u3067\u4fdd\u5b58\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u306e\u4e2d\u8eab\u3092\u898b\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u308f\u304b\u308b\u3088\u3046\u306b\u3001\u5927\u3057\u305f\u3053\u3068\u306f\u3084\u3063\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<p>\u5358\u7d14\u306bsimplecov\u3084rubycritic\u306e\u7d50\u679c\u3092\u3001\u305d\u308c\u305e\u308c\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u8a2d\u5b9a\u3057\u3066Github\u3078\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6295\u3052\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u3053\u3061\u3089\u306e\u4f8b\u3067\u306f\u5358\u7d14\u306b\u5024\u3092\u9001\u3063\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u304c\u3001\u4f8b\u3048\u3070coverage\u304c80%\u3092\u5207\u3063\u305f\u3089failure\u306b\u3059\u308b\u306a\u3069\u3001\u9759\u7684\u89e3\u6790\u3067\u54c1\u8cea\u306e\u4f4e\u4e0b\u304c\u898b\u53d7\u3051\u3089\u308c\u305f\u3089build\u3092\u5931\u6557\u3068\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u6700\u7d42\u7684\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5f62\u3067\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u30b3\u30e1\u30f3\u30c8\u6b04\u304c\u6c5a\u3055\u308c\u308b\u3088\u3046\u306a\u3053\u3068\u3082\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3412\" src=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Improved-Github-Status.png\" alt=\"\" width=\"1440\" height=\"762\" srcset=\"https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Improved-Github-Status.png 1440w, https:\/\/blog.timecrowd.net\/wp-content\/uploads\/2018\/07\/Improved-Github-Status-768x406.png 768w\" sizes=\"(max-width: 1440px) 100vw, 1440px\" \/><\/p>\n<h2><span id=\"i\">\u307e\u3068\u3081<\/span><\/h2>\n<p>\u958b\u767a\u8005\u306e\u5473\u65b9Github\u3067\u3059\u304c\u3001\u4eca\u5f8c\u3069\u306e\u3088\u3046\u306a\u65b9\u5411\u306b\u9032\u3093\u3067\u3044\u304f\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u500b\u4eba\u7684\u306b\u306fProjects\u306e\u4f7f\u3044\u52dd\u624b\u3092\u5411\u4e0a\u3057\u3066\u304f\u308c\u308b\u3068\u8272\u3005\u3068\u52a9\u304b\u308b\u306e\u3067\u3059\u304c&#8230;<\/p>\n<p>\u7686\u3055\u3093\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3069\u306e\u3088\u3046\u306b\u3057\u3066Github API\u3092\u6d3b\u7528\u3057\u3066\u3044\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u4eca\u56de\u306e\u4e8b\u4f8b\u3067\u306f\u305d\u308c\u307b\u3069\u5927\u304d\u306a\u52b9\u679c\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u3053\u3046\u3044\u3063\u305f\u6d3b\u7528\u4e8b\u4f8b\u306f\u3069\u3093\u3069\u3093\u516c\u958b\u3057\u3066\u958b\u767a\u8005\u307f\u3093\u306a\u304c\u30cf\u30c3\u30d4\u30fc\u306b\u306a\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u304d\u305f\u3044\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5148\u65e5Github\u304cMicrosoft\u306b\u8cb7\u53ce\u3055\u308c\u305f\u3068\u3044\u3046\u30cb\u30e5\u30fc\u30b9\u304c\u98db\u3073\u8fbc\u3093\u3067\u304d\u307e\u3057\u305f\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306f\u4eca\u5f8c\u306e\u52d5\u5411\u304c\u6c17\u306b\u306a\u308b\u4eca\u65e5\u3053\u306e\u9803\u3067\u3059\u3002 &#8230;","protected":false},"author":5,"featured_media":3406,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cybocfi_hide_featured_image":""},"categories":[5],"tags":[12],"_links":{"self":[{"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/posts\/3405"}],"collection":[{"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/comments?post=3405"}],"version-history":[{"count":6,"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/posts\/3405\/revisions"}],"predecessor-version":[{"id":3415,"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/posts\/3405\/revisions\/3415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/media\/3406"}],"wp:attachment":[{"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/media?parent=3405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/categories?post=3405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.timecrowd.net\/wp-json\/wp\/v2\/tags?post=3405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}