fastlane-plugin-github_status 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c63210bd71ce1329379c0a2c407cb7eedd50b5a
4
- data.tar.gz: 43b0022b168f882f9e3215f39df7f0f58200aa5c
3
+ metadata.gz: d590ee426df3c9db50f0c1145891c3af01fe5862
4
+ data.tar.gz: 13759d5e23f9abc36a533144889d6d9b21798025
5
5
  SHA512:
6
- metadata.gz: 10537b24a43898835f9f4e5efaab406a33429be0a9fcd8b1838322573b4f15d58022277714e42da3a1e38a4e385ee550ed50876ab9366297a376b190a808b6a4
7
- data.tar.gz: 5649d201f794cd449c6c1288f18ef8b1752f7aef241790785d0f9c99a95d030a26cef510ee2db749c69b23e5b075a4766c36ff838eeff2c6db5aa663e56c8395
6
+ metadata.gz: be1ad13915e6c6b296e5b13cd22a1455561d0fe043f46254f7bf7387c7df399f711b74b5a97f507ec09855f12d5fa375780d562e40f312fe6d2bbb23408ece82
7
+ data.tar.gz: 03e59a44d8e3ef7485ce76e9e3e715f9bdec4801a9682ab1614bb60ce7092c3fa3f5778ecd08b1b47b6f1ae48c068ea3b31e190c56a9e62cb9a74dd8b5caf9a9
data/README.md CHANGED
@@ -12,16 +12,44 @@ fastlane add_plugin github_status
12
12
 
13
13
  ## About github_status
14
14
 
15
- Provides the ability to check on GitHub server status as part of your build
15
+ Provides the ability to display and act upon GitHub server status as part of your build
16
16
 
17
- **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
17
+ #### Status display
18
+
19
+ ```ruby
20
+ # Display the status of the GitHub APIs as part of your build
21
+ github_status
22
+ ```
23
+
24
+ ![example output](assets/example_output.png)
25
+
26
+ #### Stop your build preemptively
27
+
28
+ If you use GitHub as part of your build and release process, it can be important to know that their APIs are having trouble before you start taking release actions.
29
+
30
+ ```ruby
31
+ # Stop the build if the status of the GitHub APIs is currently at or above a certain level of trouble
32
+ github_status(abort_level: 'major') # 'minor' or 'major'
33
+ ```
34
+
35
+ If you want to see how your build will behave when GitHub returns a particular status, you can temporarily force the plugin to return a particular status value by setting the `GITHUB_STATUS_TEST_STATUS` environment variable before your run, like:
36
+
37
+ ```bash
38
+ GITHUB_STATUS_TEST_STATUS=major fastlane your_lane
39
+ ```
40
+
41
+ #### Retrieve the status for your own use
42
+
43
+ ```ruby
44
+ # Capture the GitHub APIs status information, and use it however you'd like
45
+ message = github_status
46
+ puts "✅ #{message.body} ✅" if message.status == 'good'
47
+ ```
18
48
 
19
49
  ## Example
20
50
 
21
51
  Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
22
52
 
23
- **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
24
-
25
53
  ## Run tests for this plugin
26
54
 
27
55
  To run both the tests, and code style validation, run
@@ -7,6 +7,7 @@ require 'fastlane/plugin/github_status/version'
7
7
  require 'fastlane/plugin/github_status/ui'
8
8
  require 'fastlane/plugin/github_status/message'
9
9
  require 'fastlane/plugin/github_status/client'
10
+ require 'fastlane/plugin/github_status/options'
10
11
 
11
12
  module Fastlane
12
13
  module GithubStatus
@@ -2,7 +2,14 @@ module Fastlane
2
2
  module Actions
3
3
  class GithubStatusAction < Action
4
4
  def self.run(params)
5
- ui.print_message(client.last_message)
5
+ message = client.last_message
6
+ ui.print_message(message)
7
+
8
+ if message.status_at_least?(params[:abort_level])
9
+ ui.abort!("Aborting because of GitHub status: #{ui.status_statement(message)}")
10
+ end
11
+
12
+ message
6
13
  end
7
14
 
8
15
  def self.description
@@ -14,13 +21,7 @@ module Fastlane
14
21
  end
15
22
 
16
23
  def self.available_options
17
- [
18
- # FastlaneCore::ConfigItem.new(key: :your_option,
19
- # env_name: "GITHUB_STATUS_YOUR_OPTION",
20
- # description: "A description of your option",
21
- # optional: false,
22
- # type: String)
23
- ]
24
+ Plugin::GitHubStatus::Options.available_options
24
25
  end
25
26
 
26
27
  def self.is_supported?(platform)
@@ -31,20 +32,15 @@ module Fastlane
31
32
  # collaborators
32
33
  #
33
34
 
34
- # Used to override the UI for testing
35
- def self.ui=(ui)
36
- @ui = ui
35
+ class << self
36
+ attr_accessor :ui
37
+ attr_accessor :client
37
38
  end
38
39
 
39
40
  def self.ui
40
41
  @ui ||= Plugin::GitHubStatus::UI.new
41
42
  end
42
43
 
43
- # Used to override the Client for testing
44
- def self.client=(client)
45
- @client = client
46
- end
47
-
48
44
  def self.client
49
45
  @client ||= Plugin::GitHubStatus::Client.new
50
46
  end
@@ -4,6 +4,8 @@ module Fastlane
4
4
  # Immutable module object representing the last status message
5
5
  # provided by GitHub
6
6
  class Message
7
+ STATUS_RANKING = ['good', 'minor', 'major'].freeze
8
+
7
9
  # String representing one of three possible statuses:
8
10
  # * 'good' - Everything is OK
9
11
  # * 'minor' - GitHub is experiencing minor problems
@@ -28,10 +30,24 @@ module Fastlane
28
30
  # 'created_on' => '2016-06-01T16:40:35Z'
29
31
  # }
30
32
  def initialize(data_hash)
31
- @status = data_hash['status']
33
+ @status = ENV['GITHUB_STATUS_TEST_STATUS'] || data_hash['status']
32
34
  @body = data_hash['body']
33
35
  @created_on = Time.parse(data_hash['created_on'])
34
36
  end
37
+
38
+ def status_at_least?(other_status)
39
+ self.class.valid_status?(other_status) && (status_ranking(status) >= status_ranking(other_status))
40
+ end
41
+
42
+ def self.valid_status?(status)
43
+ STATUS_RANKING.include?(status)
44
+ end
45
+
46
+ private
47
+
48
+ def status_ranking(status)
49
+ STATUS_RANKING.find_index(status)
50
+ end
35
51
  end
36
52
  end
37
53
  end
@@ -0,0 +1,29 @@
1
+ module Fastlane
2
+ module Plugin
3
+ module GitHubStatus
4
+ class Options
5
+ # Excludes 'good' as a valid choice for wanting to abort the build
6
+ ABORT_STATUSES = Plugin::GitHubStatus::Message::STATUS_RANKING.drop(1)
7
+ ABORT_CHOICES = "'#{ABORT_STATUSES.join("', '")}'"
8
+
9
+ def self.available_options
10
+ [
11
+ FastlaneCore::ConfigItem.new(key: :abort_level,
12
+ env_name: "GITHUB_STATUS_ABORT_LEVEL",
13
+ description: "The GitHub status at or above which execution should abort. Valid values are: #{ABORT_CHOICES}",
14
+ optional: true,
15
+ type: String,
16
+ default_value: nil,
17
+ verify_block: proc do |value|
18
+ valid = value.nil? || ABORT_STATUSES.include?(value)
19
+
20
+ unless valid
21
+ FastlaneCore::UI.user_error!("abort_level must be one of: #{ABORT_CHOICES}")
22
+ end
23
+ end)
24
+ ]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -17,6 +17,10 @@ module Fastlane
17
17
  FastlaneUI.message '🐙 🐱'
18
18
  end
19
19
 
20
+ def abort!(text)
21
+ FastlaneUI.user_error!(text)
22
+ end
23
+
20
24
  def status_statement(message)
21
25
  status = message.status
22
26
  colorize_for_status(status, "#{status.upcase} - #{message.body}")
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GithubStatus
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-github_status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Furtak
@@ -106,6 +106,7 @@ files:
106
106
  - lib/fastlane/plugin/github_status/actions/github_status_action.rb
107
107
  - lib/fastlane/plugin/github_status/client.rb
108
108
  - lib/fastlane/plugin/github_status/message.rb
109
+ - lib/fastlane/plugin/github_status/options.rb
109
110
  - lib/fastlane/plugin/github_status/ui.rb
110
111
  - lib/fastlane/plugin/github_status/version.rb
111
112
  homepage: https://github.com/mfurtak/fastlane-plugin-github_status
@@ -131,6 +132,7 @@ rubyforge_project:
131
132
  rubygems_version: 2.4.5.1
132
133
  signing_key:
133
134
  specification_version: 4
134
- summary: Provides the ability to check on GitHub server status as part of your build
135
+ summary: Provides the ability to display and act upon GitHub server status as part
136
+ of your build
135
137
  test_files: []
136
138
  has_rdoc: