danger-gitlab_graph 0.0.7 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # adapted from https://github.com/danger/danger/blob/0d23ca3e1095101aa60e9a7b629b7cf02f0b187a/spec/support/gitlab_helper.rb
4
+ module Danger
5
+ module Support
6
+ module GitLabHelper
7
+ def expected_headers
8
+ {
9
+ "Accept" => "application/json",
10
+ "PRIVATE-TOKEN" => stub_env["DANGER_GITLAB_API_TOKEN"]
11
+ }
12
+ end
13
+
14
+ def stub_env
15
+ {
16
+ "GITLAB_CI" => "1",
17
+ "CI_COMMIT_SHA" => "3333333333333333333333333333333333333333",
18
+ "CI_PROJECT_PATH" => "k0nserv/danger-test",
19
+ "CI_PROJECT_URL" => "https://gitlab.com/k0nserv/danger-test",
20
+ "CI_MERGE_REQUEST_PROJECT_PATH" => "k0nserv/danger-test",
21
+ "CI_MERGE_REQUEST_PROJECT_URL" => "https://gitlab.com/k0nserv/danger-test",
22
+ "DANGER_GITLAB_API_TOKEN" => "a86e56d46ac78b"
23
+ }
24
+ end
25
+
26
+ def stub_ci(env = stub_env)
27
+ Danger::GitLabCI.new(env)
28
+ end
29
+
30
+ def stub_request_source(env = stub_env)
31
+ Danger::RequestSources::GitLab.new(stub_ci(env), env)
32
+ end
33
+
34
+ def stub_jobs(pipeline_id)
35
+ pipeline_jobs = File.read("#{File.dirname(__FILE__)}/fixtures/jobs-#{pipeline_id}.json")
36
+
37
+ stub_request(:get, "https://gitlab.com/api/v4/projects/123/pipelines/#{pipeline_id}/jobs").
38
+ to_return(status: 200, body: pipeline_jobs, headers: {})
39
+ end
40
+
41
+ def stub_trace(job_id)
42
+ trace_job = File.read("#{File.dirname(__FILE__)}/fixtures/trace-#{job_id}.txt")
43
+
44
+ stub_request(:get, "https://gitlab.com/api/v4/projects/123/jobs/#{job_id}/trace").
45
+ to_return(status: 200, body: trace_job, headers: {})
46
+ end
47
+
48
+ def stub_version(version)
49
+ url = "https://gitlab.com/api/v4/version"
50
+ WebMock.stub_request(:get, url).with(headers: expected_headers).to_return(
51
+ body: "{\"version\":\"#{version}\",\"revision\":\"1d9280e\"}"
52
+ )
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-gitlab_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Beckmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-03 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -164,6 +164,34 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: danger-gitlab
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: webmock
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.1'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.1'
167
195
  description: Danger plugin for creating graph from ci metrics.
168
196
  email:
169
197
  - king-jan1999@hotmail.de
@@ -189,11 +217,18 @@ files:
189
217
  - lib/gitlab_graph/plugin.rb
190
218
  - spec/gitlab_graph_spec.rb
191
219
  - spec/spec_helper.rb
192
- - spec/support/fixtures/github_pr.json
220
+ - spec/support/fixtures/graph-simple-expected.svg
221
+ - spec/support/fixtures/jobs-1119.json
222
+ - spec/support/fixtures/jobs-123456.json
223
+ - spec/support/fixtures/pipelines.json
224
+ - spec/support/fixtures/trace-2722.txt
225
+ - spec/support/fixtures/trace-2723.txt
226
+ - spec/support/gitlab_helper.rb
193
227
  homepage: https://github.com/kingjan1999/danger-gitlab_graph
194
228
  licenses:
195
229
  - MIT
196
- metadata: {}
230
+ metadata:
231
+ rubygems_mfa_required: 'true'
197
232
  post_install_message:
198
233
  rdoc_options: []
199
234
  require_paths:
@@ -202,7 +237,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
237
  requirements:
203
238
  - - ">="
204
239
  - !ruby/object:Gem::Version
205
- version: '0'
240
+ version: 2.7.0
206
241
  required_rubygems_version: !ruby/object:Gem::Requirement
207
242
  requirements:
208
243
  - - ">="
@@ -214,7 +249,4 @@ signing_key:
214
249
  specification_version: 4
215
250
  summary: Danger plugin which allows you to extract and visualize metrics over previous
216
251
  ci runs.
217
- test_files:
218
- - spec/gitlab_graph_spec.rb
219
- - spec/spec_helper.rb
220
- - spec/support/fixtures/github_pr.json
252
+ test_files: []
@@ -1,277 +0,0 @@
1
- {
2
- "url": "https://api.github.com/repos/danger/danger-plugin-template/pulls/18",
3
- "id": 185317229,
4
- "node_id": "MDExOlB1bGxSZXF1ZXN0MTg1MzE3MjI5",
5
- "html_url": "https://github.com/danger/danger-plugin-template/pull/18",
6
- "diff_url": "https://github.com/danger/danger-plugin-template/pull/18.diff",
7
- "patch_url": "https://github.com/danger/danger-plugin-template/pull/18.patch",
8
- "issue_url": "https://api.github.com/repos/danger/danger-plugin-template/issues/18",
9
- "number": 18,
10
- "state": "closed",
11
- "locked": false,
12
- "title": "add exmaple of how to mock PRs",
13
- "user": {
14
- "login": "wilrnh",
15
- "id": 555966,
16
- "node_id": "MDQ6VXNlcjU1NTk2Ng==",
17
- "avatar_url": "https://avatars.githubusercontent.com/u/555966?v=4",
18
- "gravatar_id": "",
19
- "url": "https://api.github.com/users/wilrnh",
20
- "html_url": "https://github.com/wilrnh",
21
- "followers_url": "https://api.github.com/users/wilrnh/followers",
22
- "following_url": "https://api.github.com/users/wilrnh/following{/other_user}",
23
- "gists_url": "https://api.github.com/users/wilrnh/gists{/gist_id}",
24
- "starred_url": "https://api.github.com/users/wilrnh/starred{/owner}{/repo}",
25
- "subscriptions_url": "https://api.github.com/users/wilrnh/subscriptions",
26
- "organizations_url": "https://api.github.com/users/wilrnh/orgs",
27
- "repos_url": "https://api.github.com/users/wilrnh/repos",
28
- "events_url": "https://api.github.com/users/wilrnh/events{/privacy}",
29
- "received_events_url": "https://api.github.com/users/wilrnh/received_events",
30
- "type": "User",
31
- "site_admin": false
32
- },
33
- "body": "Fixes danger/danger#661\r\n\r\nadd example how to mock PRs",
34
- "created_at": "2018-05-02T01:52:26Z",
35
- "updated_at": "2018-05-02T10:37:04Z",
36
- "closed_at": "2018-05-02T10:37:04Z",
37
- "merged_at": "2018-05-02T10:37:04Z",
38
- "merge_commit_sha": "39eacac22d52a2b70fc49bd8aba19eb7d2864717",
39
- "assignee": null,
40
- "assignees": [
41
-
42
- ],
43
- "requested_reviewers": [
44
-
45
- ],
46
- "requested_teams": [
47
-
48
- ],
49
- "labels": [
50
-
51
- ],
52
- "milestone": null,
53
- "draft": false,
54
- "commits_url": "https://api.github.com/repos/danger/danger-plugin-template/pulls/18/commits",
55
- "review_comments_url": "https://api.github.com/repos/danger/danger-plugin-template/pulls/18/comments",
56
- "review_comment_url": "https://api.github.com/repos/danger/danger-plugin-template/pulls/comments{/number}",
57
- "comments_url": "https://api.github.com/repos/danger/danger-plugin-template/issues/18/comments",
58
- "statuses_url": "https://api.github.com/repos/danger/danger-plugin-template/statuses/abe89bee0cdc5f45b1dee62c60e74c70f3fcb5d5",
59
- "head": {
60
- "label": "wilrnh:661-mocking-prs",
61
- "ref": "661-mocking-prs",
62
- "sha": "abe89bee0cdc5f45b1dee62c60e74c70f3fcb5d5",
63
- "user": {
64
- "login": "wilrnh",
65
- "id": 555966,
66
- "node_id": "MDQ6VXNlcjU1NTk2Ng==",
67
- "avatar_url": "https://avatars.githubusercontent.com/u/555966?v=4",
68
- "gravatar_id": "",
69
- "url": "https://api.github.com/users/wilrnh",
70
- "html_url": "https://github.com/wilrnh",
71
- "followers_url": "https://api.github.com/users/wilrnh/followers",
72
- "following_url": "https://api.github.com/users/wilrnh/following{/other_user}",
73
- "gists_url": "https://api.github.com/users/wilrnh/gists{/gist_id}",
74
- "starred_url": "https://api.github.com/users/wilrnh/starred{/owner}{/repo}",
75
- "subscriptions_url": "https://api.github.com/users/wilrnh/subscriptions",
76
- "organizations_url": "https://api.github.com/users/wilrnh/orgs",
77
- "repos_url": "https://api.github.com/users/wilrnh/repos",
78
- "events_url": "https://api.github.com/users/wilrnh/events{/privacy}",
79
- "received_events_url": "https://api.github.com/users/wilrnh/received_events",
80
- "type": "User",
81
- "site_admin": false
82
- },
83
- "repo": null
84
- },
85
- "base": {
86
- "label": "danger:master",
87
- "ref": "master",
88
- "sha": "30bd69c1c09d927abde0695fcb39dd70d4cc0f81",
89
- "user": {
90
- "login": "danger",
91
- "id": 17147106,
92
- "node_id": "MDEyOk9yZ2FuaXphdGlvbjE3MTQ3MTA2",
93
- "avatar_url": "https://avatars.githubusercontent.com/u/17147106?v=4",
94
- "gravatar_id": "",
95
- "url": "https://api.github.com/users/danger",
96
- "html_url": "https://github.com/danger",
97
- "followers_url": "https://api.github.com/users/danger/followers",
98
- "following_url": "https://api.github.com/users/danger/following{/other_user}",
99
- "gists_url": "https://api.github.com/users/danger/gists{/gist_id}",
100
- "starred_url": "https://api.github.com/users/danger/starred{/owner}{/repo}",
101
- "subscriptions_url": "https://api.github.com/users/danger/subscriptions",
102
- "organizations_url": "https://api.github.com/users/danger/orgs",
103
- "repos_url": "https://api.github.com/users/danger/repos",
104
- "events_url": "https://api.github.com/users/danger/events{/privacy}",
105
- "received_events_url": "https://api.github.com/users/danger/received_events",
106
- "type": "Organization",
107
- "site_admin": false
108
- },
109
- "repo": {
110
- "id": 60424063,
111
- "node_id": "MDEwOlJlcG9zaXRvcnk2MDQyNDA2Mw==",
112
- "name": "danger-plugin-template",
113
- "full_name": "danger/danger-plugin-template",
114
- "private": false,
115
- "owner": {
116
- "login": "danger",
117
- "id": 17147106,
118
- "node_id": "MDEyOk9yZ2FuaXphdGlvbjE3MTQ3MTA2",
119
- "avatar_url": "https://avatars.githubusercontent.com/u/17147106?v=4",
120
- "gravatar_id": "",
121
- "url": "https://api.github.com/users/danger",
122
- "html_url": "https://github.com/danger",
123
- "followers_url": "https://api.github.com/users/danger/followers",
124
- "following_url": "https://api.github.com/users/danger/following{/other_user}",
125
- "gists_url": "https://api.github.com/users/danger/gists{/gist_id}",
126
- "starred_url": "https://api.github.com/users/danger/starred{/owner}{/repo}",
127
- "subscriptions_url": "https://api.github.com/users/danger/subscriptions",
128
- "organizations_url": "https://api.github.com/users/danger/orgs",
129
- "repos_url": "https://api.github.com/users/danger/repos",
130
- "events_url": "https://api.github.com/users/danger/events{/privacy}",
131
- "received_events_url": "https://api.github.com/users/danger/received_events",
132
- "type": "Organization",
133
- "site_admin": false
134
- },
135
- "html_url": "https://github.com/danger/danger-plugin-template",
136
- "description": "An opinionated template for creating a Danger plugin",
137
- "fork": false,
138
- "url": "https://api.github.com/repos/danger/danger-plugin-template",
139
- "forks_url": "https://api.github.com/repos/danger/danger-plugin-template/forks",
140
- "keys_url": "https://api.github.com/repos/danger/danger-plugin-template/keys{/key_id}",
141
- "collaborators_url": "https://api.github.com/repos/danger/danger-plugin-template/collaborators{/collaborator}",
142
- "teams_url": "https://api.github.com/repos/danger/danger-plugin-template/teams",
143
- "hooks_url": "https://api.github.com/repos/danger/danger-plugin-template/hooks",
144
- "issue_events_url": "https://api.github.com/repos/danger/danger-plugin-template/issues/events{/number}",
145
- "events_url": "https://api.github.com/repos/danger/danger-plugin-template/events",
146
- "assignees_url": "https://api.github.com/repos/danger/danger-plugin-template/assignees{/user}",
147
- "branches_url": "https://api.github.com/repos/danger/danger-plugin-template/branches{/branch}",
148
- "tags_url": "https://api.github.com/repos/danger/danger-plugin-template/tags",
149
- "blobs_url": "https://api.github.com/repos/danger/danger-plugin-template/git/blobs{/sha}",
150
- "git_tags_url": "https://api.github.com/repos/danger/danger-plugin-template/git/tags{/sha}",
151
- "git_refs_url": "https://api.github.com/repos/danger/danger-plugin-template/git/refs{/sha}",
152
- "trees_url": "https://api.github.com/repos/danger/danger-plugin-template/git/trees{/sha}",
153
- "statuses_url": "https://api.github.com/repos/danger/danger-plugin-template/statuses/{sha}",
154
- "languages_url": "https://api.github.com/repos/danger/danger-plugin-template/languages",
155
- "stargazers_url": "https://api.github.com/repos/danger/danger-plugin-template/stargazers",
156
- "contributors_url": "https://api.github.com/repos/danger/danger-plugin-template/contributors",
157
- "subscribers_url": "https://api.github.com/repos/danger/danger-plugin-template/subscribers",
158
- "subscription_url": "https://api.github.com/repos/danger/danger-plugin-template/subscription",
159
- "commits_url": "https://api.github.com/repos/danger/danger-plugin-template/commits{/sha}",
160
- "git_commits_url": "https://api.github.com/repos/danger/danger-plugin-template/git/commits{/sha}",
161
- "comments_url": "https://api.github.com/repos/danger/danger-plugin-template/comments{/number}",
162
- "issue_comment_url": "https://api.github.com/repos/danger/danger-plugin-template/issues/comments{/number}",
163
- "contents_url": "https://api.github.com/repos/danger/danger-plugin-template/contents/{+path}",
164
- "compare_url": "https://api.github.com/repos/danger/danger-plugin-template/compare/{base}...{head}",
165
- "merges_url": "https://api.github.com/repos/danger/danger-plugin-template/merges",
166
- "archive_url": "https://api.github.com/repos/danger/danger-plugin-template/{archive_format}{/ref}",
167
- "downloads_url": "https://api.github.com/repos/danger/danger-plugin-template/downloads",
168
- "issues_url": "https://api.github.com/repos/danger/danger-plugin-template/issues{/number}",
169
- "pulls_url": "https://api.github.com/repos/danger/danger-plugin-template/pulls{/number}",
170
- "milestones_url": "https://api.github.com/repos/danger/danger-plugin-template/milestones{/number}",
171
- "notifications_url": "https://api.github.com/repos/danger/danger-plugin-template/notifications{?since,all,participating}",
172
- "labels_url": "https://api.github.com/repos/danger/danger-plugin-template/labels{/name}",
173
- "releases_url": "https://api.github.com/repos/danger/danger-plugin-template/releases{/id}",
174
- "deployments_url": "https://api.github.com/repos/danger/danger-plugin-template/deployments",
175
- "created_at": "2016-06-04T18:17:02Z",
176
- "updated_at": "2021-10-27T08:26:48Z",
177
- "pushed_at": "2022-09-04T13:16:52Z",
178
- "git_url": "git://github.com/danger/danger-plugin-template.git",
179
- "ssh_url": "git@github.com:danger/danger-plugin-template.git",
180
- "clone_url": "https://github.com/danger/danger-plugin-template.git",
181
- "svn_url": "https://github.com/danger/danger-plugin-template",
182
- "homepage": null,
183
- "size": 42,
184
- "stargazers_count": 19,
185
- "watchers_count": 19,
186
- "language": "Ruby",
187
- "has_issues": true,
188
- "has_projects": true,
189
- "has_downloads": true,
190
- "has_wiki": true,
191
- "has_pages": false,
192
- "forks_count": 12,
193
- "mirror_url": null,
194
- "archived": false,
195
- "disabled": false,
196
- "open_issues_count": 2,
197
- "license": {
198
- "key": "other",
199
- "name": "Other",
200
- "spdx_id": "NOASSERTION",
201
- "url": null,
202
- "node_id": "MDc6TGljZW5zZTA="
203
- },
204
- "allow_forking": true,
205
- "is_template": false,
206
- "web_commit_signoff_required": false,
207
- "topics": [
208
-
209
- ],
210
- "visibility": "public",
211
- "forks": 12,
212
- "open_issues": 2,
213
- "watchers": 19,
214
- "default_branch": "master"
215
- }
216
- },
217
- "_links": {
218
- "self": {
219
- "href": "https://api.github.com/repos/danger/danger-plugin-template/pulls/18"
220
- },
221
- "html": {
222
- "href": "https://github.com/danger/danger-plugin-template/pull/18"
223
- },
224
- "issue": {
225
- "href": "https://api.github.com/repos/danger/danger-plugin-template/issues/18"
226
- },
227
- "comments": {
228
- "href": "https://api.github.com/repos/danger/danger-plugin-template/issues/18/comments"
229
- },
230
- "review_comments": {
231
- "href": "https://api.github.com/repos/danger/danger-plugin-template/pulls/18/comments"
232
- },
233
- "review_comment": {
234
- "href": "https://api.github.com/repos/danger/danger-plugin-template/pulls/comments{/number}"
235
- },
236
- "commits": {
237
- "href": "https://api.github.com/repos/danger/danger-plugin-template/pulls/18/commits"
238
- },
239
- "statuses": {
240
- "href": "https://api.github.com/repos/danger/danger-plugin-template/statuses/abe89bee0cdc5f45b1dee62c60e74c70f3fcb5d5"
241
- }
242
- },
243
- "author_association": "CONTRIBUTOR",
244
- "auto_merge": null,
245
- "active_lock_reason": null,
246
- "merged": true,
247
- "mergeable": null,
248
- "rebaseable": null,
249
- "mergeable_state": "unknown",
250
- "merged_by": {
251
- "login": "orta",
252
- "id": 49038,
253
- "node_id": "MDQ6VXNlcjQ5MDM4",
254
- "avatar_url": "https://avatars.githubusercontent.com/u/49038?v=4",
255
- "gravatar_id": "",
256
- "url": "https://api.github.com/users/orta",
257
- "html_url": "https://github.com/orta",
258
- "followers_url": "https://api.github.com/users/orta/followers",
259
- "following_url": "https://api.github.com/users/orta/following{/other_user}",
260
- "gists_url": "https://api.github.com/users/orta/gists{/gist_id}",
261
- "starred_url": "https://api.github.com/users/orta/starred{/owner}{/repo}",
262
- "subscriptions_url": "https://api.github.com/users/orta/subscriptions",
263
- "organizations_url": "https://api.github.com/users/orta/orgs",
264
- "repos_url": "https://api.github.com/users/orta/repos",
265
- "events_url": "https://api.github.com/users/orta/events{/privacy}",
266
- "received_events_url": "https://api.github.com/users/orta/received_events",
267
- "type": "User",
268
- "site_admin": false
269
- },
270
- "comments": 2,
271
- "review_comments": 0,
272
- "maintainer_can_modify": false,
273
- "commits": 2,
274
- "additions": 5,
275
- "deletions": 0,
276
- "changed_files": 1
277
- }