fief 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba06e870d6a95356820b15bd3f692a4662057e7a466cf7a877065228bd74e536
4
- data.tar.gz: 1deec8fafbe79d23d4d2f7a580daec7089b056ad3c03a2d29c36150251721496
3
+ metadata.gz: dd7cfda79ea5621c170b61d14f8199b428edc5ce90616852dcb48922094a493d
4
+ data.tar.gz: 7ee986cdc8e252af997416c4ae8a25f82f9fae413334c570d4612a93112d832f
5
5
  SHA512:
6
- metadata.gz: 0b80671ae6d23c725dcaf3f94920682a45b2ec0d304736e6266d888fd976ceab3eb810c06d48dd828fe4d0d1c8c24c45943a33b17668e3baf790a9a39d149076
7
- data.tar.gz: 24d27ab6bb0cf97bf7b4ef9176381918f295641448f31dbaca719ddb3cb45eed6ab5dd977b100572a77734e8612a2c5ce4038d1feb7dd5388b7e6967174cb686
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,12 +16,18 @@ 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/* \
21
+ --include yegor256/* \
22
+ --include sttc/* \
23
+ --include objectionary/* \
24
+ --include polystat/* \
25
+ --include zerocracy/* \
26
+ --include zold-io/* \
24
27
  --exclude jcabi/.github \
25
- --include yegor256/cactoos \
26
- --include yegor256/takes \
27
- --include yegor256/xembly
28
+ --exclude yegor256/quiz \
29
+ --excluce yegor256/hangman \
30
+ --to gh-pages
28
31
  - run: mkdir -p gh-pages/$(date +'%Y/%m/%d')
29
32
  - run: cp gh-pages/index.xml gh-pages/$(date +'%Y/%m/%d')/index.xml
30
33
  - uses: JamesIves/github-pages-deploy-action@v4.4.2
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/assets/index.xsl CHANGED
@@ -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,15 +203,16 @@ 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>
192
- <xsl:if test="@alert">
193
- <xsl:attribute name="class">
194
- <xsl:text>firebrick</xsl:text>
195
- </xsl:attribute>
196
- </xsl:if>
197
216
  <xsl:copy-of select="."/>
198
217
  </td>
199
218
  </xsl:template>
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
@@ -111,7 +112,7 @@ def build_xml(opts, loog)
111
112
  end
112
113
  end
113
114
  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
114
- xml.fief(time: Time.now) do
115
+ xml.fief(time: Time.now, msec: Time.now - start) do
115
116
  xml.titles do
116
117
  data.map { |r| r[:metrics].map { |ms| ms[:title] } }.flatten.uniq.each do |t|
117
118
  xml.title do
@@ -31,6 +31,7 @@ class Fief::Issues
31
31
 
32
32
  def take(loog)
33
33
  json = @api.list_issues(@repo, state: 'open')
34
+ json.select! { |i| i[:pull_request].nil? }
34
35
  total = json.count
35
36
  loog.debug("Found #{total} open issues in #{@repo}")
36
37
  old = 0
@@ -38,11 +39,11 @@ class Fief::Issues
38
39
  json.each do |issue|
39
40
  num = issue[:number]
40
41
  data = @api.issue(@repo, num)
41
- if data[:created_at] < Time.now - (60 * 60 * 24 * 14)
42
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 28)
42
43
  loog.debug("Issue #{@repo}/##{num} is old")
43
44
  old += 1
44
45
  end
45
- if data[:created_at] < Time.now - (60 * 60 * 24 * 56)
46
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 112)
46
47
  loog.debug("Issue #{@repo}/##{num} is very old")
47
48
  older += 1
48
49
  end
@@ -38,11 +38,11 @@ class Fief::Pulls
38
38
  json.each do |pr|
39
39
  num = pr[:number]
40
40
  data = @api.pull_request(@repo, num)
41
- if data[:created_at] < Time.now - (60 * 60 * 24 * 14)
41
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 28)
42
42
  loog.debug("PR #{@repo}/##{num} is old")
43
43
  old += 1
44
44
  end
45
- if data[:created_at] < Time.now - (60 * 60 * 24 * 56)
45
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 112)
46
46
  loog.debug("PR #{@repo}/##{num} is very old")
47
47
  older += 1
48
48
  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.2'.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/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.2
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,6 +157,7 @@ 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
@@ -164,6 +165,7 @@ files:
164
165
  - renovate.json
165
166
  - test/metrics/test_issues.rb
166
167
  - test/metrics/test_pulls.rb
168
+ - test/metrics/test_runs.rb
167
169
  - test/test__helper.rb
168
170
  - test/test_mask.rb
169
171
  - test/test_match.rb