circle_ci_wrapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/circle_ci_wrapper.rb +45 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d2705c4fc13140c1c6265831d2ddf8c66a91092d4f40f4eff871e153b6fddeb8
|
4
|
+
data.tar.gz: f4e3c73f85856fd72f63b49a6bfbae82b1a10c5c9f3f38493cff7c4fea4ae055
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5e8faee594efae16273d450edd93f51b5d6bc326ff9779ac040e0f4c3975fbe393669d7fa493ada30dd99de50cff688bd6c211e59a5ff14724113db41929627
|
7
|
+
data.tar.gz: f37a69acf822026241fb9fedd6024ffb7f91f4eead1ab5483755fe37f8a3ba550fb0cb3957bd81d4405d18429246fcea4cdb5059f249e47b30d2a91bd3602a3f
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
# Wrapper around circle ci api
|
6
|
+
class CircleCiWrapper
|
7
|
+
CIRCLE_CI_API_URL = 'https://circleci.com/api/v1.1/project/github'
|
8
|
+
|
9
|
+
def self.report_urls_by_branch(branch_name, build_name = 'build')
|
10
|
+
url = "#{base_url}/tree/#{branch_name}?circle-token=#{ENV['CIRCLE_TOKEN']}&limit=6&filter=completed"
|
11
|
+
|
12
|
+
return nil if Net::HTTP.get_response(URI.parse(url)).code != '200'
|
13
|
+
|
14
|
+
latest_build_num = latest_build(url, build_name)
|
15
|
+
|
16
|
+
return nil unless latest_build_num
|
17
|
+
|
18
|
+
[
|
19
|
+
report_url("#{base_url}/#{ENV['CIRCLE_BUILD_NUM']}/artifacts?circle-token=#{ENV['CIRCLE_TOKEN']}"),
|
20
|
+
report_url("#{base_url}/#{latest_build_num}/artifacts?circle-token=#{ENV['CIRCLE_TOKEN']}", branch_name)
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.report_url(url, branch_name = nil)
|
25
|
+
return nil if Net::HTTP.get_response(URI.parse(url)).code != '200'
|
26
|
+
|
27
|
+
artifacts = JSON.parse(URI.parse(url).read).map { |a| a['url'] }
|
28
|
+
|
29
|
+
coverage_url = artifacts.find { |artifact| artifact&.end_with?('coverage/coverage.json') }
|
30
|
+
|
31
|
+
return nil unless coverage_url
|
32
|
+
|
33
|
+
"#{coverage_url}?circle-token=#{ENV['CIRCLE_TOKEN']}&branch=#{branch_name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.base_url
|
37
|
+
"#{CIRCLE_CI_API_URL}/#{ENV['CIRCLE_PROJECT_USERNAME']}/#{ENV['CIRCLE_PROJECT_REPONAME']}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.latest_build(url, build_name)
|
41
|
+
JSON.parse(URI.parse(url).read).select do |build|
|
42
|
+
build&.[]('build_parameters')&.[]('CIRCLE_JOB') == build_name
|
43
|
+
end&.first&.[]('build_num')
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: circle_ci_wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guilherme Pereira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.90'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.90'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.19'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.19'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.9'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.9'
|
111
|
+
description: CircleCI API wrapper
|
112
|
+
email:
|
113
|
+
- guilhermepereira@edgepetrol.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- lib/circle_ci_wrapper.rb
|
119
|
+
homepage: https://github.com/EdgePetrol/circle_ci
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.4.0
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubygems_version: 3.1.2
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: CircleCI API wrapper to help find build artifacts
|
142
|
+
test_files: []
|