fief 0.0.1 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3543ddd3cd50e0eaee854ded81482f5055a33b802cab4e27698cfc93b7e9d7a4
4
- data.tar.gz: 20b02a86929d62c77e177c3b1d7f495adc07a1d3463d80bf4361c0f379a64638
3
+ metadata.gz: dd7cfda79ea5621c170b61d14f8199b428edc5ce90616852dcb48922094a493d
4
+ data.tar.gz: 7ee986cdc8e252af997416c4ae8a25f82f9fae413334c570d4612a93112d832f
5
5
  SHA512:
6
- metadata.gz: d770b689daff2ed3ef9efa70789cdf2503a2f0c8b0ed82620782ce05b6e270676dd47b8f7a551ad5378a500e33ca385754e40a64ef096261727b58ee792c2650
7
- data.tar.gz: f2a36f91fa8c01df22501c51ee2b49dffa88450da44f998c23965a5589b65852dc914f1c8a6e4d2dfdcc4ecc051999e82732bd3848bd342ba77af2910d0e8b01
6
+ metadata.gz: 3a265b21ebbe73254a3f1f252237a9524e18dada7ccdf6a77eaa6574d9533e266378bfb7d7287e9e6f85c0a3d6b130eb83101e0be1f86cf11d13423f9f397ea9
7
+ data.tar.gz: 1a5db3381cc3bc6d2bf4594c10400b0a32c73b9bd9e2cd039fef934348ac679875ee0f3588a355fa8675fd641447bea2469c986837f1cbb7590dbf6bf68326c0
@@ -2,10 +2,7 @@
2
2
  name: cron
3
3
  on:
4
4
  schedule:
5
- - cron: "23 23 * * *"
6
- push:
7
- branches:
8
- - master
5
+ - cron: "13 */4 * * *"
9
6
  concurrency:
10
7
  group: cron
11
8
  cancel-in-progress: true
@@ -19,14 +16,21 @@ jobs:
19
16
  ruby-version: 2.7
20
17
  - run: bundle install
21
18
  - run: |
22
- bin/fief --verbose --token ${{ secrets.TOKEN }} --to gh-pages \
19
+ bin/fief --token ${{ secrets.TOKEN }} --delay 1000 \
23
20
  --include jcabi/* \
24
- --include yegor256/cactoos \
25
- --include yegor256/takes \
26
- --include yegor256/xembly
21
+ --include yegor256/* \
22
+ --include sttc/* \
23
+ --include objectionary/* \
24
+ --include polystat/* \
25
+ --include zerocracy/* \
26
+ --include zold-io/* \
27
+ --exclude jcabi/.github \
28
+ --exclude yegor256/quiz \
29
+ --excluce yegor256/hangman \
30
+ --to gh-pages
27
31
  - run: mkdir -p gh-pages/$(date +'%Y/%m/%d')
28
32
  - run: cp gh-pages/index.xml gh-pages/$(date +'%Y/%m/%d')/index.xml
29
- - uses: JamesIves/github-pages-deploy-action@4.1.4
33
+ - uses: JamesIves/github-pages-deploy-action@v4.4.2
30
34
  with:
31
35
  branch: gh-pages
32
36
  folder: gh-pages
@@ -11,8 +11,8 @@ jobs:
11
11
  test:
12
12
  strategy:
13
13
  matrix:
14
- os: [ubuntu-20.04, macos-12]
15
- ruby: ['2.7', '3.0']
14
+ os: [ubuntu-20.04]
15
+ ruby: ['3.0']
16
16
  runs-on: ${{ matrix.os }}
17
17
  steps:
18
18
  - uses: actions/checkout@v3
data/.rubocop.yml CHANGED
@@ -8,7 +8,7 @@ AllCops:
8
8
  SuggestExtensions: false
9
9
 
10
10
  Metrics/CyclomaticComplexity:
11
- Max: 10
11
+ Max: 14
12
12
  Metrics/MethodLength:
13
13
  Enabled: false
14
14
  Layout/MultilineMethodCallIndentation:
@@ -21,3 +21,5 @@ Layout/EmptyLineAfterGuardClause:
21
21
  Enabled: false
22
22
  Style/ClassAndModuleChildren:
23
23
  Enabled: false
24
+ Metrics/BlockLength:
25
+ Max: 30
data/Gemfile CHANGED
@@ -24,8 +24,8 @@ gemspec
24
24
  gem 'cucumber', '8.0.0', require: false
25
25
  gem 'minitest', '5.15.0', require: false
26
26
  gem 'rake', '13.0.6', require: false
27
- gem 'rdoc', '6.4.0', require: false
28
- gem 'rubocop', '1.32.0', require: false
29
- gem 'rubocop-rspec', '2.11.1', require: false
27
+ gem 'rdoc', '6.5.0', require: false
28
+ gem 'rubocop', '1.52.0', require: false
29
+ gem 'rubocop-rspec', '2.22.0', require: false
30
30
  gem 'simplecov', '0.22.0', require: false
31
31
  gem 'xcop', '0.7.1', require: false
data/README.md CHANGED
@@ -9,7 +9,6 @@
9
9
  [![Gem Version](https://badge.fury.io/rb/fief.svg)](http://badge.fury.io/rb/fief)
10
10
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/fief/blob/master/LICENSE.txt)
11
11
  [![Maintainability](https://api.codeclimate.com/v1/badges/396ec0584e0a84adc723/maintainability)](https://codeclimate.com/github/yegor256/fief/maintainability)
12
- [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/fief.svg)](https://codecov.io/github/yegor256/fief?branch=master)
13
12
  ![Lines of code](https://img.shields.io/tokei/lines/github/yegor256/fief)
14
13
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/fief)](https://hitsofcode.com/view/github/yegor256/fief)
15
14
 
@@ -26,6 +25,8 @@ Then, run it locally and read its output:
26
25
  $ fief --repo yegor256/fief --verbose
27
26
  ```
28
27
 
28
+ For example, [here is mine](https://yegor256.github.io/fief/).
29
+
29
30
  ## How to contribute
30
31
 
31
32
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
data/assets/index.xsl CHANGED
@@ -98,7 +98,7 @@ SOFTWARE.
98
98
  <xsl:text>,1]]</xsl:text>
99
99
  </xsl:attribute>
100
100
  <colgroup>
101
- <col style="width: 2.5em;"/>
101
+ <col/>
102
102
  <xsl:for-each select="fief/titles/title">
103
103
  <xsl:sort select="."/>
104
104
  <col/>
@@ -142,6 +142,24 @@ SOFTWARE.
142
142
  <xsl:value-of select="fief/@time"/>
143
143
  <xsl:text>. </xsl:text>
144
144
  <br/>
145
+ <xsl:text>It took </xsl:text>
146
+ <xsl:variable name="sec" select="round(fief/@msec) div 1000"/>
147
+ <xsl:choose>
148
+ <xsl:when test="$sec &lt; 60">
149
+ <xsl:value-of select="$sec"/>
150
+ <xsl:text>s</xsl:text>
151
+ </xsl:when>
152
+ <xsl:when test="$sec &lt; 3600">
153
+ <xsl:value-of select="format-number($sec div 60, '#.##')"/>
154
+ <xsl:text>min</xsl:text>
155
+ </xsl:when>
156
+ <xsl:otherwise>
157
+ <xsl:value-of select="format-number($sec div 3600, '#.#')"/>
158
+ <xsl:text>h</xsl:text>
159
+ </xsl:otherwise>
160
+ </xsl:choose>
161
+ <xsl:text> to build the report.</xsl:text>
162
+ <br/>
145
163
  <xsl:text>The XML with the data </xsl:text>
146
164
  <a href="index.xml">
147
165
  <xsl:text>is here</xsl:text>
@@ -185,7 +203,13 @@ SOFTWARE.
185
203
  </tr>
186
204
  </xsl:template>
187
205
  <xsl:template match="m">
188
- <td class="num">
206
+ <td>
207
+ <xsl:attribute name="class">
208
+ <xsl:text>num</xsl:text>
209
+ <xsl:if test="@alert">
210
+ <xsl:text> firebrick</xsl:text>
211
+ </xsl:if>
212
+ </xsl:attribute>
189
213
  <xsl:attribute name="data-sort-value">
190
214
  <xsl:copy-of select="."/>
191
215
  </xsl:attribute>
data/bin/fief CHANGED
@@ -75,6 +75,7 @@ Encoding.default_external = Encoding::UTF_8
75
75
  Encoding.default_internal = Encoding::UTF_8
76
76
 
77
77
  def build_xml(opts, loog)
78
+ start = Time.now
78
79
  if opts.token?
79
80
  api = Octokit::Client.new(:access_token => opts[:token])
80
81
  else
@@ -104,11 +105,14 @@ def build_xml(opts, loog)
104
105
  else
105
106
  measures = m.take(loog)
106
107
  end
107
- data << {name: repo, metrics: measures}
108
+ if data.find { |d| d[:name] == repo }.nil?
109
+ data << {name: repo, metrics: []}
110
+ end
111
+ data.find { |d| d[:name] == repo }[:metrics] += measures
108
112
  end
109
113
  end
110
114
  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
111
- xml.fief(time: Time.now) do
115
+ xml.fief(time: Time.now, msec: Time.now - start) do
112
116
  xml.titles do
113
117
  data.map { |r| r[:metrics].map { |ms| ms[:title] } }.flatten.uniq.each do |t|
114
118
  xml.title do
@@ -122,6 +126,7 @@ def build_xml(opts, loog)
122
126
  xml.metrics do
123
127
  r[:metrics].each do |ms|
124
128
  xml.m(id: ms[:title]) do
129
+ xml.parent.set_attribute('alert', 'yes') if ms[:alert]
125
130
  xml.text ms[:value]
126
131
  end
127
132
  end
@@ -31,11 +31,38 @@ class Fief::Issues
31
31
 
32
32
  def take(loog)
33
33
  json = @api.list_issues(@repo, state: 'open')
34
- loog.debug("Found #{json.count} open issues in #{@repo}")
34
+ json.select! { |i| i[:pull_request].nil? }
35
+ total = json.count
36
+ loog.debug("Found #{total} open issues in #{@repo}")
37
+ old = 0
38
+ older = 0
39
+ json.each do |issue|
40
+ num = issue[:number]
41
+ data = @api.issue(@repo, num)
42
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 28)
43
+ loog.debug("Issue #{@repo}/##{num} is old")
44
+ old += 1
45
+ end
46
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 112)
47
+ loog.debug("Issue #{@repo}/##{num} is very old")
48
+ older += 1
49
+ end
50
+ end
35
51
  [
36
52
  {
37
53
  title: 'Open Issues',
38
- value: json.count
54
+ value: total,
55
+ alert: false
56
+ },
57
+ {
58
+ title: 'Old Issues',
59
+ value: old,
60
+ alert: older > total * 0.4
61
+ },
62
+ {
63
+ title: 'Older Issues',
64
+ value: older,
65
+ alert: older > total * 0.4
39
66
  }
40
67
  ]
41
68
  end
@@ -31,11 +31,37 @@ class Fief::Pulls
31
31
 
32
32
  def take(loog)
33
33
  json = @api.pull_requests(@repo, state: 'open')
34
- loog.debug("Found #{json.count} open pull requests in #{@repo}")
34
+ total = json.count
35
+ loog.debug("Found #{total} open pull requests in #{@repo}")
36
+ old = 0
37
+ older = 0
38
+ json.each do |pr|
39
+ num = pr[:number]
40
+ data = @api.pull_request(@repo, num)
41
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 28)
42
+ loog.debug("PR #{@repo}/##{num} is old")
43
+ old += 1
44
+ end
45
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 112)
46
+ loog.debug("PR #{@repo}/##{num} is very old")
47
+ older += 1
48
+ end
49
+ end
35
50
  [
36
51
  {
37
- title: 'Open Pull Requests',
38
- value: json.count
52
+ title: 'Open PRs',
53
+ value: total,
54
+ alert: false
55
+ },
56
+ {
57
+ title: 'Old PRs',
58
+ value: old,
59
+ alert: older > total * 0.4
60
+ },
61
+ {
62
+ title: 'Older PRs',
63
+ value: older,
64
+ alert: older > total * 0.2
39
65
  }
40
66
  ]
41
67
  end
@@ -0,0 +1,57 @@
1
+ # Copyright (c) 2023 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ # GitHub Action Runs in one GitHub repository.
22
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
23
+ # Copyright:: Copyright (c) 2023 Yegor Bugayenko
24
+ # License:: MIT
25
+ class Fief::Runs
26
+ def initialize(api, repo, opts)
27
+ @api = api
28
+ @repo = repo
29
+ @opts = opts
30
+ end
31
+
32
+ def take(loog)
33
+ master = @api.repository(@repo)[:default_branch]
34
+ json = @api.repository_workflow_runs(@repo, branch: master)
35
+ workflows = []
36
+ failures = 0
37
+ json[:workflow_runs].take(32).each do |run|
38
+ workflow = run[:workflow_id]
39
+ next if workflows.include?(workflow)
40
+ workflows << workflow
41
+ next if run[:status] != 'completed'
42
+ conclusion = run[:conclusion]
43
+ loog.debug("Workflow run '#{run[:name]}' in #{@repo} is '#{conclusion}'")
44
+ if conclusion == 'failure'
45
+ loog.debug("Workflow run '#{run[:name]}' is failed")
46
+ failures += 1
47
+ end
48
+ end
49
+ [
50
+ {
51
+ title: 'CI failures',
52
+ value: failures,
53
+ alert: failures > 0
54
+ }
55
+ ]
56
+ end
57
+ end
data/lib/fief/repos.rb CHANGED
@@ -40,6 +40,10 @@ class Fief::Repos
40
40
  @loog.debug("GitHub account @#{org} is a user's account")
41
41
  @api.repositories(org, { type: 'public' }).each do |json|
42
42
  id = json[:full_name]
43
+ if json[:archived]
44
+ @loog.debug("The #{id} repo is archived, ignoring it")
45
+ next
46
+ end
43
47
  repos << id
44
48
  @loog.debug("Including #{id} as it is owned by @#{org}")
45
49
  end
@@ -47,6 +51,10 @@ class Fief::Repos
47
51
  @loog.debug("GitHub account @#{org} is an organization account")
48
52
  @api.organization_repositories(org, { type: 'public' }).each do |json|
49
53
  id = json[:full_name]
54
+ if json[:archived]
55
+ @loog.debug("The #{id} repo is archived, ignoring it")
56
+ next
57
+ end
50
58
  repos << id
51
59
  @loog.debug("Including #{id} as a member of @#{org} organization")
52
60
  end
data/lib/fief/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2023 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Fief
26
- VERSION = '0.0.1'.freeze
26
+ VERSION = '0.0.3'.freeze
27
27
  end
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2023 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'minitest/autorun'
22
+ require 'octokit'
23
+ require 'loog'
24
+ require_relative '../../lib/fief/metrics/issues'
25
+
26
+ # Test for Issues.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2023 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestIssues < Minitest::Test
31
+ def test_real
32
+ api = Octokit::Client.new
33
+ m = Fief::Issues.new(api, 'yegor256/fief', {})
34
+ ms = m.take(Loog::VERBOSE)
35
+ assert !ms.empty?
36
+ p ms
37
+ rescue Octokit::TooManyRequests => e
38
+ puts e.message
39
+ skip
40
+ end
41
+ end
@@ -31,7 +31,7 @@ class TestPulls < Minitest::Test
31
31
  def test_real
32
32
  api = Octokit::Client.new
33
33
  m = Fief::Pulls.new(api, 'yegor256/fief', {})
34
- ms = m.take(Loog::NULL)
34
+ ms = m.take(Loog::VERBOSE)
35
35
  assert !ms.empty?
36
36
  p ms
37
37
  rescue Octokit::TooManyRequests => e
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2023 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'minitest/autorun'
22
+ require 'octokit'
23
+ require 'loog'
24
+ require_relative '../../lib/fief/metrics/runs'
25
+
26
+ # Test for Workflow Runs.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2023 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestRuns < Minitest::Test
31
+ def test_real
32
+ api = Octokit::Client.new
33
+ m = Fief::Runs.new(api, 'yegor256/debate', {})
34
+ ms = m.take(Loog::VERBOSE)
35
+ assert !ms.empty?
36
+ p ms
37
+ rescue Octokit::TooManyRequests => e
38
+ puts e.message
39
+ skip
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fief
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-03 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -157,12 +157,15 @@ files:
157
157
  - lib/fief/match.rb
158
158
  - lib/fief/metrics/issues.rb
159
159
  - lib/fief/metrics/pulls.rb
160
+ - lib/fief/metrics/runs.rb
160
161
  - lib/fief/repos.rb
161
162
  - lib/fief/version.rb
162
163
  - logo.png
163
164
  - logo.svg
164
165
  - renovate.json
166
+ - test/metrics/test_issues.rb
165
167
  - test/metrics/test_pulls.rb
168
+ - test/metrics/test_runs.rb
166
169
  - test/test__helper.rb
167
170
  - test/test_mask.rb
168
171
  - test/test_match.rb