Various GitHub Onebox improvements (#13163)

* FIX: Improve GitHub folder regexp in Onebox

It used to match any GitHub URL that was not matched by the other GitHub
Oneboxes and it did not do a good job at handling those. With this
change, the generic Onebox will handle the remaining URLs.

* FEATURE: Add Onebox for GitHub Actions

* FEATURE: Add Onebox for PR check runs

* FIX: Remove image from GitHub folder Oneboxes

It is a generic, auto-generated image which does not provide any value.

* DEV: Add tests

* FIX: Strip HTML comments from PR body
This commit is contained in:
Dan Ungureanu 2021-05-27 12:38:42 +03:00 committed by GitHub
parent 2f12c0f5bd
commit 723d7de18c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 886 additions and 20 deletions

View File

@ -88,6 +88,7 @@ export default {
const oneboxTypes = {
amazon: "discourse-amazon",
githubactions: "fab-github",
githubblob: "fab-github",
githubcommit: "fab-github",
githubpullrequest: "fab-github",

View File

@ -507,6 +507,49 @@ pre.onebox code {
}
}
.onebox.githubactions {
h4 {
margin-top: 5px;
margin-bottom: 5px;
}
.github-row {
display: flex;
}
.github-icon-container {
display: flex;
align-items: flex-start;
margin-right: 5px;
}
.github-icon {
fill: var(--primary-medium);
width: var(--font-up-3);
height: var(--font-up-3);
}
.github-icon-success {
fill: var(--success);
}
.github-icon-failure {
fill: var(--danger);
}
.github-icon-pending {
fill: #dbab0a;
}
.github-info {
color: var(--primary-high);
}
.github-run-number {
color: var(--primary-medium);
}
}
//Onebox - Github - Pull request
.onebox-body .github-commit-status {
background: #f5f5f5;

View File

@ -0,0 +1,87 @@
# frozen_string_literal: true
require_relative '../mixins/github_body'
module Onebox
module Engine
class GithubActionsOnebox
include Engine
include LayoutSupport
include JSON
matches_regexp(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/(actions\/runs\/[[:digit:]]+|pull\/[[:digit:]]*\/checks\?check_run_id=[[:digit:]]+)/)
always_https
def url
if type == :actions_run
"https://api.github.com/repos/#{match[:org]}/#{match[:repo]}/actions/runs/#{match[:run_id]}"
elsif type == :pr_run
"https://api.github.com/repos/#{match[:org]}/#{match[:repo]}/check-runs/#{match[:check_run_id]}"
end
end
def self.priority
90 # overlaps with GithubPullRequestOnebox
end
private
def match_url
return if defined?(@match) && defined?(@type)
if match = @url.match(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/actions\/runs\/(?<run_id>[[:digit:]]+)/)
@match = match
@type = :actions_run
end
if match = @url.match(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/pull\/(?<pr_id>[[:digit:]]*)\/checks\?check_run_id=(?<check_run_id>[[:digit:]]+)/)
@match = match
@type = :pr_run
end
end
def match
return @match if defined?(@match)
match_url
@match
end
def type
return @type if defined?(@type)
match_url
@type
end
def data
status = "unknown"
if raw["status"] == "completed"
if raw["conclusion"] == "success"
status = "success"
elsif raw["conclusion"] == "failure"
status = "failure"
elsif raw["conclusion"] == "cancelled"
end
elsif raw["status"] == "in_progress"
status = "pending"
end
title = if type == :actions_run
raw["head_commit"]["message"].lines.first
elsif type == :pr_run
pr_url = "https://api.github.com/repos/#{match[:org]}/#{match[:repo]}/pulls/#{match[:pr_id]}"
::MultiJson.load(URI.open(pr_url, read_timeout: timeout))["title"]
end
{
link: @url,
title: title,
name: raw["name"],
run_number: raw["run_number"],
status => true,
}
end
end
end
end

View File

@ -7,14 +7,9 @@ module Onebox
include StandardEmbed
include LayoutSupport
matches_regexp(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?(github)\.com[\:\d]*(\/[^\/]+){2}/)
matches_regexp(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?(github)\.com[\:\d]*(\/[^\/]+){2}\/tree/)
always_https
def self.priority
# This engine should have lower priority than the other Github engines
150
end
private
def data
@ -46,7 +41,6 @@ module Onebox
{
link: url,
image: og.image,
title: Onebox::Helpers.truncate(title, 250),
path: display_path,
description: display_description,

View File

@ -9,17 +9,18 @@ module Onebox
end
module InstanceMethods
GITHUB_COMMENT_REGEX = /(<!--.*?-->\r\n)/
GITHUB_COMMENT_REGEX = /<!--.*?-->/
MAX_BODY_LENGTH = 80
def compute_body(body)
body = body.dup
excerpt = nil
body = (body || '').gsub(GITHUB_COMMENT_REGEX, '')
body = body.length > 0 ? body : nil
if body && body.length > MAX_BODY_LENGTH
excerpt = body[MAX_BODY_LENGTH..body.length].rstrip
body = body[0..MAX_BODY_LENGTH - 1]
def compute_body(body)
if body
body = body.gsub(GITHUB_COMMENT_REGEX, '').strip
if body.length == 0
body = nil
elsif body.length > MAX_BODY_LENGTH
excerpt = body[MAX_BODY_LENGTH..body.length].rstrip
body = body[0..MAX_BODY_LENGTH - 1]
end
end
[body, excerpt]

View File

@ -0,0 +1,31 @@
<div class="github-row">
<div class="github-icon-container" title="Commit">
{{#success}}
<svg width="24" height="24" class="github-icon github-icon-success" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12zm16.28-2.72a.75.75 0 00-1.06-1.06l-5.97 5.97-2.47-2.47a.75.75 0 00-1.06 1.06l3 3a.75.75 0 001.06 0l6.5-6.5z"></path></svg>
{{/success}}
{{#pending}}
<svg width="24" height="24" class="github-icon github-icon-pending" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 18a6 6 0 100-12 6 6 0 000 12z"></path></svg>
{{/pending}}
{{#failure}}
<svg width="24" height="24" class="github-icon github-icon-failure" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12zm8.036-4.024a.75.75 0 00-1.06 1.06L10.939 12l-2.963 2.963a.75.75 0 101.06 1.06L12 13.06l2.963 2.964a.75.75 0 001.061-1.06L13.061 12l2.963-2.964a.75.75 0 10-1.06-1.06L12 10.939 9.036 7.976z"></path></svg>
{{/failure}}
{{#unknown}}
<svg width="24" height="24" class="github-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 18a6 6 0 100-12 6 6 0 000 12z"></path></svg>
{{/unknown}}
</div>
<div class="github-info-container">
<h4>
<a href="{{link}}" target="_blank" rel="noopener">{{title}}</a>
</h4>
{{#run_number}}
<div class="github-info">
{{name}} <span class="github-run-number">#{{run_number}}</span>
</div>
{{/run_number}}
</div>
</div>

View File

@ -1,5 +1,3 @@
{{#image}}<img src="{{image}}" class="thumbnail"/>{{/image}}
<h3><a href="{{link}}" target="_blank" rel="noopener">{{title}}</a></h3>
{{#path}}

View File

@ -0,0 +1,176 @@
{
"id": 873214216,
"name": "Linting",
"node_id": "WFR_lAHOADEiqs4Ac4CqzjQMMQg",
"head_branch": "simplify-deleted-post-copy",
"head_sha": "929e4ee5e93e53f45c7be78fcf81b734120af9c0",
"run_number": 2687,
"event": "pull_request",
"status": "completed",
"conclusion": "success",
"workflow_id": 5947272,
"check_suite_id": 2820222471,
"check_suite_node_id": "MDEwOkNoZWNrU3VpdGUyODIwMjIyNDcx",
"url": "https://api.github.com/repos/discourse/discourse/actions/runs/873214216",
"html_url": "https://github.com/discourse/discourse/actions/runs/873214216",
"pull_requests": [
],
"created_at": "2021-05-25T01:10:28Z",
"updated_at": "2021-05-25T01:15:56Z",
"jobs_url": "https://api.github.com/repos/discourse/discourse/actions/runs/873214216/jobs",
"logs_url": "https://api.github.com/repos/discourse/discourse/actions/runs/873214216/logs",
"check_suite_url": "https://api.github.com/repos/discourse/discourse/check-suites/2820222471",
"artifacts_url": "https://api.github.com/repos/discourse/discourse/actions/runs/873214216/artifacts",
"cancel_url": "https://api.github.com/repos/discourse/discourse/actions/runs/873214216/cancel",
"rerun_url": "https://api.github.com/repos/discourse/discourse/actions/runs/873214216/rerun",
"workflow_url": "https://api.github.com/repos/discourse/discourse/actions/workflows/5947272",
"head_commit": {
"id": "929e4ee5e93e53f45c7be78fcf81b734120af9c0",
"tree_id": "3d8f1301a94fd5bad68684e2fe1212ad890dcd79",
"message": "Remove deleted_by_author key\n\nThis has to be done to avoid errors because the old translation\nhad a one and many key, whereas the new one has no count.",
"timestamp": "2021-05-25T01:09:40Z",
"author": {
"name": "Martin Brennan",
"email": "martin@discourse.org"
},
"committer": {
"name": "Martin Brennan",
"email": "martin@discourse.org"
}
},
"repository": {
"id": 7569578,
"node_id": "MDEwOlJlcG9zaXRvcnk3NTY5NTc4",
"name": "discourse",
"full_name": "discourse/discourse",
"private": false,
"owner": {
"login": "discourse",
"id": 3220138,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3220138?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/discourse",
"html_url": "https://github.com/discourse",
"followers_url": "https://api.github.com/users/discourse/followers",
"following_url": "https://api.github.com/users/discourse/following{/other_user}",
"gists_url": "https://api.github.com/users/discourse/gists{/gist_id}",
"starred_url": "https://api.github.com/users/discourse/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/discourse/subscriptions",
"organizations_url": "https://api.github.com/users/discourse/orgs",
"repos_url": "https://api.github.com/users/discourse/repos",
"events_url": "https://api.github.com/users/discourse/events{/privacy}",
"received_events_url": "https://api.github.com/users/discourse/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/discourse/discourse",
"description": "A platform for community discussion. Free, open, simple.",
"fork": false,
"url": "https://api.github.com/repos/discourse/discourse",
"forks_url": "https://api.github.com/repos/discourse/discourse/forks",
"keys_url": "https://api.github.com/repos/discourse/discourse/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/discourse/discourse/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/discourse/discourse/teams",
"hooks_url": "https://api.github.com/repos/discourse/discourse/hooks",
"issue_events_url": "https://api.github.com/repos/discourse/discourse/issues/events{/number}",
"events_url": "https://api.github.com/repos/discourse/discourse/events",
"assignees_url": "https://api.github.com/repos/discourse/discourse/assignees{/user}",
"branches_url": "https://api.github.com/repos/discourse/discourse/branches{/branch}",
"tags_url": "https://api.github.com/repos/discourse/discourse/tags",
"blobs_url": "https://api.github.com/repos/discourse/discourse/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/discourse/discourse/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/discourse/discourse/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/discourse/discourse/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/discourse/discourse/statuses/{sha}",
"languages_url": "https://api.github.com/repos/discourse/discourse/languages",
"stargazers_url": "https://api.github.com/repos/discourse/discourse/stargazers",
"contributors_url": "https://api.github.com/repos/discourse/discourse/contributors",
"subscribers_url": "https://api.github.com/repos/discourse/discourse/subscribers",
"subscription_url": "https://api.github.com/repos/discourse/discourse/subscription",
"commits_url": "https://api.github.com/repos/discourse/discourse/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/discourse/discourse/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/discourse/discourse/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/discourse/discourse/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/discourse/discourse/contents/{+path}",
"compare_url": "https://api.github.com/repos/discourse/discourse/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/discourse/discourse/merges",
"archive_url": "https://api.github.com/repos/discourse/discourse/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/discourse/discourse/downloads",
"issues_url": "https://api.github.com/repos/discourse/discourse/issues{/number}",
"pulls_url": "https://api.github.com/repos/discourse/discourse/pulls{/number}",
"milestones_url": "https://api.github.com/repos/discourse/discourse/milestones{/number}",
"notifications_url": "https://api.github.com/repos/discourse/discourse/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/discourse/discourse/labels{/name}",
"releases_url": "https://api.github.com/repos/discourse/discourse/releases{/id}",
"deployments_url": "https://api.github.com/repos/discourse/discourse/deployments"
},
"head_repository": {
"id": 7569578,
"node_id": "MDEwOlJlcG9zaXRvcnk3NTY5NTc4",
"name": "discourse",
"full_name": "discourse/discourse",
"private": false,
"owner": {
"login": "discourse",
"id": 3220138,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3220138?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/discourse",
"html_url": "https://github.com/discourse",
"followers_url": "https://api.github.com/users/discourse/followers",
"following_url": "https://api.github.com/users/discourse/following{/other_user}",
"gists_url": "https://api.github.com/users/discourse/gists{/gist_id}",
"starred_url": "https://api.github.com/users/discourse/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/discourse/subscriptions",
"organizations_url": "https://api.github.com/users/discourse/orgs",
"repos_url": "https://api.github.com/users/discourse/repos",
"events_url": "https://api.github.com/users/discourse/events{/privacy}",
"received_events_url": "https://api.github.com/users/discourse/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/discourse/discourse",
"description": "A platform for community discussion. Free, open, simple.",
"fork": false,
"url": "https://api.github.com/repos/discourse/discourse",
"forks_url": "https://api.github.com/repos/discourse/discourse/forks",
"keys_url": "https://api.github.com/repos/discourse/discourse/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/discourse/discourse/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/discourse/discourse/teams",
"hooks_url": "https://api.github.com/repos/discourse/discourse/hooks",
"issue_events_url": "https://api.github.com/repos/discourse/discourse/issues/events{/number}",
"events_url": "https://api.github.com/repos/discourse/discourse/events",
"assignees_url": "https://api.github.com/repos/discourse/discourse/assignees{/user}",
"branches_url": "https://api.github.com/repos/discourse/discourse/branches{/branch}",
"tags_url": "https://api.github.com/repos/discourse/discourse/tags",
"blobs_url": "https://api.github.com/repos/discourse/discourse/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/discourse/discourse/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/discourse/discourse/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/discourse/discourse/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/discourse/discourse/statuses/{sha}",
"languages_url": "https://api.github.com/repos/discourse/discourse/languages",
"stargazers_url": "https://api.github.com/repos/discourse/discourse/stargazers",
"contributors_url": "https://api.github.com/repos/discourse/discourse/contributors",
"subscribers_url": "https://api.github.com/repos/discourse/discourse/subscribers",
"subscription_url": "https://api.github.com/repos/discourse/discourse/subscription",
"commits_url": "https://api.github.com/repos/discourse/discourse/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/discourse/discourse/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/discourse/discourse/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/discourse/discourse/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/discourse/discourse/contents/{+path}",
"compare_url": "https://api.github.com/repos/discourse/discourse/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/discourse/discourse/merges",
"archive_url": "https://api.github.com/repos/discourse/discourse/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/discourse/discourse/downloads",
"issues_url": "https://api.github.com/repos/discourse/discourse/issues{/number}",
"pulls_url": "https://api.github.com/repos/discourse/discourse/pulls{/number}",
"milestones_url": "https://api.github.com/repos/discourse/discourse/milestones{/number}",
"notifications_url": "https://api.github.com/repos/discourse/discourse/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/discourse/discourse/labels{/name}",
"releases_url": "https://api.github.com/repos/discourse/discourse/releases{/id}",
"deployments_url": "https://api.github.com/repos/discourse/discourse/deployments"
}
}

View File

@ -0,0 +1,369 @@
{
"url": "https://api.github.com/repos/discourse/discourse/pulls/13128",
"id": 651671568,
"node_id": "MDExOlB1bGxSZXF1ZXN0NjUxNjcxNTY4",
"html_url": "https://github.com/discourse/discourse/pull/13128",
"diff_url": "https://github.com/discourse/discourse/pull/13128.diff",
"patch_url": "https://github.com/discourse/discourse/pull/13128.patch",
"issue_url": "https://api.github.com/repos/discourse/discourse/issues/13128",
"number": 13128,
"state": "closed",
"locked": false,
"title": "simplify post and topic deletion language",
"user": {
"login": "coding-horror",
"id": 1522517,
"node_id": "MDQ6VXNlcjE1MjI1MTc=",
"avatar_url": "https://avatars.githubusercontent.com/u/1522517?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/coding-horror",
"html_url": "https://github.com/coding-horror",
"followers_url": "https://api.github.com/users/coding-horror/followers",
"following_url": "https://api.github.com/users/coding-horror/following{/other_user}",
"gists_url": "https://api.github.com/users/coding-horror/gists{/gist_id}",
"starred_url": "https://api.github.com/users/coding-horror/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/coding-horror/subscriptions",
"organizations_url": "https://api.github.com/users/coding-horror/orgs",
"repos_url": "https://api.github.com/users/coding-horror/repos",
"events_url": "https://api.github.com/users/coding-horror/events{/privacy}",
"received_events_url": "https://api.github.com/users/coding-horror/received_events",
"type": "User",
"site_admin": false
},
"body": "based on feedback from Matt Haughey, we don't need to use so many words when describing a deleted topic or post.\r\n\r\n<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->\r\n",
"created_at": "2021-05-24T22:16:01Z",
"updated_at": "2021-05-25T02:04:11Z",
"closed_at": "2021-05-25T02:04:10Z",
"merged_at": "2021-05-25T02:04:10Z",
"merge_commit_sha": "50926f614342336793f1b78672b387d545d48de3",
"assignee": null,
"assignees": [
],
"requested_reviewers": [
],
"requested_teams": [
],
"labels": [
],
"milestone": null,
"draft": false,
"commits_url": "https://api.github.com/repos/discourse/discourse/pulls/13128/commits",
"review_comments_url": "https://api.github.com/repos/discourse/discourse/pulls/13128/comments",
"review_comment_url": "https://api.github.com/repos/discourse/discourse/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/discourse/discourse/issues/13128/comments",
"statuses_url": "https://api.github.com/repos/discourse/discourse/statuses/929e4ee5e93e53f45c7be78fcf81b734120af9c0",
"head": {
"label": "discourse:simplify-deleted-post-copy",
"ref": "simplify-deleted-post-copy",
"sha": "929e4ee5e93e53f45c7be78fcf81b734120af9c0",
"user": {
"login": "discourse",
"id": 3220138,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3220138?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/discourse",
"html_url": "https://github.com/discourse",
"followers_url": "https://api.github.com/users/discourse/followers",
"following_url": "https://api.github.com/users/discourse/following{/other_user}",
"gists_url": "https://api.github.com/users/discourse/gists{/gist_id}",
"starred_url": "https://api.github.com/users/discourse/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/discourse/subscriptions",
"organizations_url": "https://api.github.com/users/discourse/orgs",
"repos_url": "https://api.github.com/users/discourse/repos",
"events_url": "https://api.github.com/users/discourse/events{/privacy}",
"received_events_url": "https://api.github.com/users/discourse/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 7569578,
"node_id": "MDEwOlJlcG9zaXRvcnk3NTY5NTc4",
"name": "discourse",
"full_name": "discourse/discourse",
"private": false,
"owner": {
"login": "discourse",
"id": 3220138,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3220138?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/discourse",
"html_url": "https://github.com/discourse",
"followers_url": "https://api.github.com/users/discourse/followers",
"following_url": "https://api.github.com/users/discourse/following{/other_user}",
"gists_url": "https://api.github.com/users/discourse/gists{/gist_id}",
"starred_url": "https://api.github.com/users/discourse/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/discourse/subscriptions",
"organizations_url": "https://api.github.com/users/discourse/orgs",
"repos_url": "https://api.github.com/users/discourse/repos",
"events_url": "https://api.github.com/users/discourse/events{/privacy}",
"received_events_url": "https://api.github.com/users/discourse/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/discourse/discourse",
"description": "A platform for community discussion. Free, open, simple.",
"fork": false,
"url": "https://api.github.com/repos/discourse/discourse",
"forks_url": "https://api.github.com/repos/discourse/discourse/forks",
"keys_url": "https://api.github.com/repos/discourse/discourse/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/discourse/discourse/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/discourse/discourse/teams",
"hooks_url": "https://api.github.com/repos/discourse/discourse/hooks",
"issue_events_url": "https://api.github.com/repos/discourse/discourse/issues/events{/number}",
"events_url": "https://api.github.com/repos/discourse/discourse/events",
"assignees_url": "https://api.github.com/repos/discourse/discourse/assignees{/user}",
"branches_url": "https://api.github.com/repos/discourse/discourse/branches{/branch}",
"tags_url": "https://api.github.com/repos/discourse/discourse/tags",
"blobs_url": "https://api.github.com/repos/discourse/discourse/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/discourse/discourse/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/discourse/discourse/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/discourse/discourse/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/discourse/discourse/statuses/{sha}",
"languages_url": "https://api.github.com/repos/discourse/discourse/languages",
"stargazers_url": "https://api.github.com/repos/discourse/discourse/stargazers",
"contributors_url": "https://api.github.com/repos/discourse/discourse/contributors",
"subscribers_url": "https://api.github.com/repos/discourse/discourse/subscribers",
"subscription_url": "https://api.github.com/repos/discourse/discourse/subscription",
"commits_url": "https://api.github.com/repos/discourse/discourse/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/discourse/discourse/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/discourse/discourse/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/discourse/discourse/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/discourse/discourse/contents/{+path}",
"compare_url": "https://api.github.com/repos/discourse/discourse/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/discourse/discourse/merges",
"archive_url": "https://api.github.com/repos/discourse/discourse/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/discourse/discourse/downloads",
"issues_url": "https://api.github.com/repos/discourse/discourse/issues{/number}",
"pulls_url": "https://api.github.com/repos/discourse/discourse/pulls{/number}",
"milestones_url": "https://api.github.com/repos/discourse/discourse/milestones{/number}",
"notifications_url": "https://api.github.com/repos/discourse/discourse/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/discourse/discourse/labels{/name}",
"releases_url": "https://api.github.com/repos/discourse/discourse/releases{/id}",
"deployments_url": "https://api.github.com/repos/discourse/discourse/deployments",
"created_at": "2013-01-12T00:25:55Z",
"updated_at": "2021-05-26T11:54:17Z",
"pushed_at": "2021-05-26T14:34:39Z",
"git_url": "git://github.com/discourse/discourse.git",
"ssh_url": "git@github.com:discourse/discourse.git",
"clone_url": "https://github.com/discourse/discourse.git",
"svn_url": "https://github.com/discourse/discourse",
"homepage": "https://www.discourse.org",
"size": 369664,
"stargazers_count": 33354,
"watchers_count": 33354,
"language": "Ruby",
"has_issues": false,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 7246,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 31,
"license": {
"key": "other",
"name": "Other",
"spdx_id": "NOASSERTION",
"url": null,
"node_id": "MDc6TGljZW5zZTA="
},
"forks": 7246,
"open_issues": 31,
"watchers": 33354,
"default_branch": "master"
}
},
"base": {
"label": "discourse:master",
"ref": "master",
"sha": "b8a08d21e0e9c73f3fdd1ef99c6b8dfe00f5c4f7",
"user": {
"login": "discourse",
"id": 3220138,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3220138?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/discourse",
"html_url": "https://github.com/discourse",
"followers_url": "https://api.github.com/users/discourse/followers",
"following_url": "https://api.github.com/users/discourse/following{/other_user}",
"gists_url": "https://api.github.com/users/discourse/gists{/gist_id}",
"starred_url": "https://api.github.com/users/discourse/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/discourse/subscriptions",
"organizations_url": "https://api.github.com/users/discourse/orgs",
"repos_url": "https://api.github.com/users/discourse/repos",
"events_url": "https://api.github.com/users/discourse/events{/privacy}",
"received_events_url": "https://api.github.com/users/discourse/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 7569578,
"node_id": "MDEwOlJlcG9zaXRvcnk3NTY5NTc4",
"name": "discourse",
"full_name": "discourse/discourse",
"private": false,
"owner": {
"login": "discourse",
"id": 3220138,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=",
"avatar_url": "https://avatars.githubusercontent.com/u/3220138?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/discourse",
"html_url": "https://github.com/discourse",
"followers_url": "https://api.github.com/users/discourse/followers",
"following_url": "https://api.github.com/users/discourse/following{/other_user}",
"gists_url": "https://api.github.com/users/discourse/gists{/gist_id}",
"starred_url": "https://api.github.com/users/discourse/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/discourse/subscriptions",
"organizations_url": "https://api.github.com/users/discourse/orgs",
"repos_url": "https://api.github.com/users/discourse/repos",
"events_url": "https://api.github.com/users/discourse/events{/privacy}",
"received_events_url": "https://api.github.com/users/discourse/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/discourse/discourse",
"description": "A platform for community discussion. Free, open, simple.",
"fork": false,
"url": "https://api.github.com/repos/discourse/discourse",
"forks_url": "https://api.github.com/repos/discourse/discourse/forks",
"keys_url": "https://api.github.com/repos/discourse/discourse/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/discourse/discourse/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/discourse/discourse/teams",
"hooks_url": "https://api.github.com/repos/discourse/discourse/hooks",
"issue_events_url": "https://api.github.com/repos/discourse/discourse/issues/events{/number}",
"events_url": "https://api.github.com/repos/discourse/discourse/events",
"assignees_url": "https://api.github.com/repos/discourse/discourse/assignees{/user}",
"branches_url": "https://api.github.com/repos/discourse/discourse/branches{/branch}",
"tags_url": "https://api.github.com/repos/discourse/discourse/tags",
"blobs_url": "https://api.github.com/repos/discourse/discourse/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/discourse/discourse/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/discourse/discourse/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/discourse/discourse/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/discourse/discourse/statuses/{sha}",
"languages_url": "https://api.github.com/repos/discourse/discourse/languages",
"stargazers_url": "https://api.github.com/repos/discourse/discourse/stargazers",
"contributors_url": "https://api.github.com/repos/discourse/discourse/contributors",
"subscribers_url": "https://api.github.com/repos/discourse/discourse/subscribers",
"subscription_url": "https://api.github.com/repos/discourse/discourse/subscription",
"commits_url": "https://api.github.com/repos/discourse/discourse/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/discourse/discourse/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/discourse/discourse/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/discourse/discourse/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/discourse/discourse/contents/{+path}",
"compare_url": "https://api.github.com/repos/discourse/discourse/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/discourse/discourse/merges",
"archive_url": "https://api.github.com/repos/discourse/discourse/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/discourse/discourse/downloads",
"issues_url": "https://api.github.com/repos/discourse/discourse/issues{/number}",
"pulls_url": "https://api.github.com/repos/discourse/discourse/pulls{/number}",
"milestones_url": "https://api.github.com/repos/discourse/discourse/milestones{/number}",
"notifications_url": "https://api.github.com/repos/discourse/discourse/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/discourse/discourse/labels{/name}",
"releases_url": "https://api.github.com/repos/discourse/discourse/releases{/id}",
"deployments_url": "https://api.github.com/repos/discourse/discourse/deployments",
"created_at": "2013-01-12T00:25:55Z",
"updated_at": "2021-05-26T11:54:17Z",
"pushed_at": "2021-05-26T14:34:39Z",
"git_url": "git://github.com/discourse/discourse.git",
"ssh_url": "git@github.com:discourse/discourse.git",
"clone_url": "https://github.com/discourse/discourse.git",
"svn_url": "https://github.com/discourse/discourse",
"homepage": "https://www.discourse.org",
"size": 369664,
"stargazers_count": 33354,
"watchers_count": 33354,
"language": "Ruby",
"has_issues": false,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 7246,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 31,
"license": {
"key": "other",
"name": "Other",
"spdx_id": "NOASSERTION",
"url": null,
"node_id": "MDc6TGljZW5zZTA="
},
"forks": 7246,
"open_issues": 31,
"watchers": 33354,
"default_branch": "master"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/discourse/discourse/pulls/13128"
},
"html": {
"href": "https://github.com/discourse/discourse/pull/13128"
},
"issue": {
"href": "https://api.github.com/repos/discourse/discourse/issues/13128"
},
"comments": {
"href": "https://api.github.com/repos/discourse/discourse/issues/13128/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/discourse/discourse/pulls/13128/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/discourse/discourse/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/discourse/discourse/pulls/13128/commits"
},
"statuses": {
"href": "https://api.github.com/repos/discourse/discourse/statuses/929e4ee5e93e53f45c7be78fcf81b734120af9c0"
}
},
"author_association": "MEMBER",
"auto_merge": null,
"active_lock_reason": null,
"merged": true,
"mergeable": null,
"rebaseable": null,
"mergeable_state": "unknown",
"merged_by": {
"login": "martin-brennan",
"id": 920448,
"node_id": "MDQ6VXNlcjkyMDQ0OA==",
"avatar_url": "https://avatars.githubusercontent.com/u/920448?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/martin-brennan",
"html_url": "https://github.com/martin-brennan",
"followers_url": "https://api.github.com/users/martin-brennan/followers",
"following_url": "https://api.github.com/users/martin-brennan/following{/other_user}",
"gists_url": "https://api.github.com/users/martin-brennan/gists{/gist_id}",
"starred_url": "https://api.github.com/users/martin-brennan/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/martin-brennan/subscriptions",
"organizations_url": "https://api.github.com/users/martin-brennan/orgs",
"repos_url": "https://api.github.com/users/martin-brennan/repos",
"events_url": "https://api.github.com/users/martin-brennan/events{/privacy}",
"received_events_url": "https://api.github.com/users/martin-brennan/received_events",
"type": "User",
"site_admin": false
},
"comments": 0,
"review_comments": 0,
"maintainer_can_modify": false,
"commits": 3,
"additions": 10,
"deletions": 19,
"changed_files": 5
}

View File

@ -0,0 +1,109 @@
{
"id": 2660861130,
"node_id": "MDg6Q2hlY2tSdW4yNjYwODYxMTMw",
"head_sha": "929e4ee5e93e53f45c7be78fcf81b734120af9c0",
"external_id": "ca395085-040a-526b-2ce8-bdc85f692774",
"url": "https://api.github.com/repos/discourse/discourse/check-runs/2660861130",
"html_url": "https://github.com/discourse/discourse/runs/2660861130",
"details_url": "https://github.com/discourse/discourse/runs/2660861130",
"status": "completed",
"conclusion": "success",
"started_at": "2021-05-25T01:10:38Z",
"completed_at": "2021-05-25T01:15:51Z",
"output": {
"title": null,
"summary": null,
"text": null,
"annotations_count": 0,
"annotations_url": "https://api.github.com/repos/discourse/discourse/check-runs/2660861130/annotations"
},
"name": "run",
"check_suite": {
"id": 2820222471
},
"app": {
"id": 15368,
"slug": "github-actions",
"node_id": "MDM6QXBwMTUzNjg=",
"owner": {
"login": "github",
"id": 9919,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
"avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github",
"html_url": "https://github.com/github",
"followers_url": "https://api.github.com/users/github/followers",
"following_url": "https://api.github.com/users/github/following{/other_user}",
"gists_url": "https://api.github.com/users/github/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github/subscriptions",
"organizations_url": "https://api.github.com/users/github/orgs",
"repos_url": "https://api.github.com/users/github/repos",
"events_url": "https://api.github.com/users/github/events{/privacy}",
"received_events_url": "https://api.github.com/users/github/received_events",
"type": "Organization",
"site_admin": false
},
"name": "GitHub Actions",
"description": "Automate your workflow from idea to production",
"external_url": "https://help.github.com/en/actions",
"html_url": "https://github.com/apps/github-actions",
"created_at": "2018-07-30T09:30:17Z",
"updated_at": "2019-12-10T19:04:12Z",
"permissions": {
"actions": "write",
"checks": "write",
"contents": "write",
"deployments": "write",
"discussions": "write",
"issues": "write",
"metadata": "read",
"organization_packages": "write",
"packages": "write",
"pages": "write",
"pull_requests": "write",
"repository_hooks": "write",
"repository_projects": "write",
"security_events": "write",
"statuses": "write",
"vulnerability_alerts": "read"
},
"events": [
"check_run",
"check_suite",
"create",
"delete",
"deployment",
"deployment_status",
"discussion",
"discussion_comment",
"fork",
"gollum",
"issues",
"issue_comment",
"label",
"milestone",
"page_build",
"project",
"project_card",
"project_column",
"public",
"pull_request",
"pull_request_review",
"pull_request_review_comment",
"push",
"registry_package",
"release",
"repository",
"repository_dispatch",
"status",
"watch",
"workflow_dispatch",
"workflow_run"
]
},
"pull_requests": [
]
}

View File

@ -26,7 +26,7 @@
"received_events_url": "https://api.github.com/users/jamesaanderson/received_events",
"type": "User"
},
"body": "http://meta.discourse.org/t/audio-html5-tag/8168",
"body": "http://meta.discourse.org/t/audio-html5-tag/8168\n<!-- test comment -->",
"created_at": "2013-07-26T02:05:53Z",
"updated_at": "2013-07-26T15:31:57Z",
"closed_at": "2013-07-26T15:30:57Z",

View File

@ -0,0 +1,56 @@
# frozen_string_literal: true
require "rails_helper"
describe Onebox::Engine::GithubActionsOnebox do
describe "PR check run" do
before do
@link = "https://github.com/discourse/discourse/pull/13128/checks?check_run_id=2660861130"
stub_request(:get, "https://api.github.com/repos/discourse/discourse/pulls/13128")
.to_return(status: 200, body: onebox_response("githubactions_pr"))
stub_request(:get, "https://api.github.com/repos/discourse/discourse/check-runs/2660861130")
.to_return(status: 200, body: onebox_response("githubactions_pr_run"))
end
include_context "engines"
it_behaves_like "an engine"
describe "#to_html" do
it "includes status" do
expect(html).to include("success")
end
it "includes title" do
expect(html).to include("simplify post and topic deletion language")
end
end
end
describe "GitHub Actions run" do
before do
@link = "https://github.com/discourse/discourse/actions/runs/873214216"
stub_request(:get, "https://api.github.com/repos/discourse/discourse/actions/runs/873214216")
.to_return(status: 200, body: onebox_response("githubactions_actions_run"))
end
include_context "engines"
it_behaves_like "an engine"
describe "#to_html" do
it "includes status" do
expect(html).to include("success")
end
it "includes title" do
expect(html).to include("Remove deleted_by_author key")
end
it "includes action name" do
expect(html).to include("Linting")
end
end
end
end

View File

@ -46,8 +46,9 @@ describe Onebox::Engine::GithubPullRequestOnebox do
expect(html).to include("1")
end
it "includes the body" do
it "includes the body without comments" do
expect(html).to include("http://meta.discourse.org/t/audio-html5-tag/8168")
expect(html).not_to include("test comment")
end
end
end