huginn_firefox_versions_agent 0.1.10

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4e030bcfbaba35760526cba0fb000354c3976cf895076035649793d7d9d16e3b
4
+ data.tar.gz: d50f9f337c0c0c393645031106444923e9ad72455f4262973a084d13344be1e6
5
+ SHA512:
6
+ metadata.gz: 5500ec18741f7632ed5b181dde649968652ffa2ab7936fc570eb6e28033cf61263d6a458dce3082aad46f49fa81b3c2571ea3710822fb558100f52b73b373fe8
7
+ data.tar.gz: 1beda1056beb2fb6427da949ee3aab08b40cddc93b7ee62b725b49d66d469f607209dcf3bed6869239f2165ba57bafc2c2e68219c78dc9a683cbff1f2bc97254
data/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2022 Nicolas Germain
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,140 @@
1
+ module Agents
2
+ class FirefoxVersionsAgent < Agent
3
+ include FormConfigurable
4
+ can_dry_run!
5
+ no_bulk_receive!
6
+ default_schedule 'every_1h'
7
+
8
+ description do
9
+ <<-MD
10
+ The Firefox versions Agent fetches releases information for Firefox (desktop and mobile) from `https://product-details.mozilla.org/`.
11
+ I added this agent because with website agent, when indicator is empty for "all ok status", no event was created.
12
+
13
+ `debug` is used to verbose mode.
14
+
15
+ `expected_receive_period_in_days` is used to determine if the Agent is working. Set it to the maximum number of days
16
+ that you anticipate passing without this Agent receiving an incoming Event.
17
+ MD
18
+ end
19
+
20
+ event_description <<-MD
21
+ Events look like this:
22
+
23
+ {
24
+ "FIREFOX_AURORA": "",
25
+ "FIREFOX_DEVEDITION": "104.0b2",
26
+ "FIREFOX_ESR": "91.12.0esr",
27
+ "FIREFOX_ESR_NEXT": "102.1.0esr",
28
+ "FIREFOX_NIGHTLY": "105.0a1",
29
+ "FIREFOX_PINEBUILD": "",
30
+ "LAST_MERGE_DATE": "2022-07-25",
31
+ "LAST_RELEASE_DATE": "2022-07-26",
32
+ "LAST_SOFTFREEZE_DATE": "2022-07-21",
33
+ "LATEST_FIREFOX_DEVEL_VERSION": "104.0b2",
34
+ "LATEST_FIREFOX_OLDER_VERSION": "3.6.28",
35
+ "LATEST_FIREFOX_RELEASED_DEVEL_VERSION": "104.0b2",
36
+ "LATEST_FIREFOX_VERSION": "103.0",
37
+ "NEXT_MERGE_DATE": "2022-08-22",
38
+ "NEXT_RELEASE_DATE": "2022-08-23",
39
+ "NEXT_SOFTFREEZE_DATE": "2022-08-18"
40
+ }
41
+ MD
42
+
43
+ def default_options
44
+ {
45
+ 'debug' => 'false',
46
+ 'expected_receive_period_in_days' => '2',
47
+ 'type' => 'latest',
48
+ 'changes_only' => 'true'
49
+ }
50
+ end
51
+
52
+ form_configurable :expected_receive_period_in_days, type: :string
53
+ form_configurable :changes_only, type: :boolean
54
+ form_configurable :debug, type: :boolean
55
+ form_configurable :type, type: :array, values: ['latest', 'latest_esr', 'latest_nightly']
56
+
57
+ def validate_options
58
+ errors.add(:base, "type has invalid value: should be 'latest' 'latest_esr' 'latest_nightly'") if interpolated['type'].present? && !%w(latest latest_esr latest_nightly).include?(interpolated['type'])
59
+
60
+ if options.has_key?('changes_only') && boolify(options['changes_only']).nil?
61
+ errors.add(:base, "if provided, changes_only must be true or false")
62
+ end
63
+
64
+ if options.has_key?('debug') && boolify(options['debug']).nil?
65
+ errors.add(:base, "if provided, debug must be true or false")
66
+ end
67
+
68
+ unless options['expected_receive_period_in_days'].present? && options['expected_receive_period_in_days'].to_i > 0
69
+ errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working")
70
+ end
71
+ end
72
+
73
+ def working?
74
+ event_created_within?(options['expected_receive_period_in_days']) && !recent_error_logs?
75
+ end
76
+
77
+ def check
78
+ check_versions
79
+ end
80
+
81
+ private
82
+
83
+ def check_same(foo,bar,payload)
84
+ if foo != bar
85
+ if interpolated['debug'] == 'true'
86
+ log "not equal, so event created!"
87
+ end
88
+ create_event payload: payload
89
+ else
90
+ if interpolated['debug'] == 'true'
91
+ log "equal"
92
+ end
93
+ end
94
+ end
95
+
96
+ def check_versions()
97
+
98
+ uri = URI.parse("https://product-details.mozilla.org/1.0/firefox_versions.json")
99
+ response = Net::HTTP.get_response(uri)
100
+
101
+ log "fetch status request status : #{response.code}"
102
+ payload = JSON.parse(response.body)
103
+
104
+ if interpolated['debug'] == 'true'
105
+ log payload
106
+ end
107
+
108
+ if interpolated['changes_only'] == 'true'
109
+ if payload.to_s != memory['last_status']
110
+ if !memory['last_status'].nil?
111
+ last_status = memory['last_status'].gsub("=>", ": ").gsub(": nil", ": null")
112
+ last_status = JSON.parse(last_status)
113
+ case interpolated['type']
114
+ when "latest"
115
+ check_same(payload['LATEST_FIREFOX_VERSION'],last_status['LATEST_FIREFOX_VERSION'],payload)
116
+ when "latest_esr"
117
+ check_same(payload['FIREFOX_ESR'],last_status['FIREFOX_ESR'],payload)
118
+ when "latest_nightly"
119
+ check_same(payload['FIREFOX_NIGHTLY'],last_status['FIREFOX_NIGHTLY'],payload)
120
+ else
121
+ log "Error: type has an invalid value (#{type})"
122
+ end
123
+ else
124
+ create_event payload: payload
125
+ end
126
+ memory['last_status'] = payload.to_s
127
+ else
128
+ if interpolated['debug'] == 'true'
129
+ log "equal"
130
+ end
131
+ end
132
+ else
133
+ create_event payload: payload
134
+ if payload.to_s != memory['last_status']
135
+ memory['last_status'] = payload.to_s
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,4 @@
1
+ require 'huginn_agent'
2
+
3
+ #HuginnAgent.load 'huginn_firefox_versions_agent/concerns/my_agent_concern'
4
+ HuginnAgent.register 'huginn_firefox_versions_agent/firefox_versions_agent'
@@ -0,0 +1,13 @@
1
+ require 'rails_helper'
2
+ require 'huginn_agent/spec_helper'
3
+
4
+ describe Agents::FirefoxVersionsAgent do
5
+ before(:each) do
6
+ @valid_options = Agents::FirefoxVersionsAgent.new.default_options
7
+ @checker = Agents::FirefoxVersionsAgent.new(:name => "FirefoxVersionsAgent", :options => @valid_options)
8
+ @checker.user = users(:bob)
9
+ @checker.save!
10
+ end
11
+
12
+ pending "add specs here"
13
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: huginn_firefox_versions_agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.10
5
+ platform: ruby
6
+ authors:
7
+ - Nicolas Germain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-02-11 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.0
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.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 12.3.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 12.3.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: huginn_agent
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Write a longer description or delete this line.
56
+ email:
57
+ - ngermain@hihouhou.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.txt
63
+ - lib/huginn_firefox_versions_agent.rb
64
+ - lib/huginn_firefox_versions_agent/firefox_versions_agent.rb
65
+ - spec/firefox_versions_agent_spec.rb
66
+ homepage: https://github.com/hihouhou/huginn_firefox_versions_agent
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubygems_version: 3.3.3
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Write a short summary, because Rubygems requires one.
89
+ test_files:
90
+ - spec/firefox_versions_agent_spec.rb