fastlane-plugin-github_job_status 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 96e339555bf8616cb2ba48614ff44ab4e1808acf
4
+ data.tar.gz: ad2845d5f235c4a08847acec94b55f224258d348
5
+ SHA512:
6
+ metadata.gz: 70da624cbf4782ea89567d5563a3ef7b39a9b2996c256e6391e7f8cc47e57594cd1ee7629ffc4dba715ef0fb42bcbaf6b25f5eb20f655bf0318b79432db76e6e
7
+ data.tar.gz: aa9175cb59af82a0fe912fdb87a922a815ec6fb832bf125300a78bb39c80d1a6b510f5dce1f7f91f9e94d7b6cf8d4c8063239f45d0e566b1a703655508bdbd27
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Justin Singer <justin.singer@appian.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # github_job_status plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-github_job_status)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-github_job_status`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin github_job_status
11
+ ```
12
+
13
+ ## About github_job_status
14
+
15
+ Post the status of your test jobs to your pull requests. This uses GihHub's [status API](https://developer.github.com/v3/repos/statuses/). Statuses posted to pull requests look this:
16
+ ![screen shot 2016-12-16 at 2 25 20 pm](https://cloud.githubusercontent.com/assets/8180094/21275606/98432cc4-c39b-11e6-984f-25228455efd7.png)
17
+
18
+ This plugin can be used in the following way:
19
+
20
+ ```RUBY
21
+ github_job_status(
22
+ token: 'github_OAuth_token',
23
+ owner: 'justinsinger',
24
+ repo: 'fastlane_plugins',
25
+ sha: 'commit_sha',
26
+ job_name: 'good_job',
27
+ build_url: 'skullcrushers.gov',
28
+ state: 'pending'
29
+ )
30
+ ```
31
+
32
+ * `state` must be pending, success, error, or failure
33
+ * `token` can be obtained in GitHub for an owner (To do this, go to settings/Personal access tokens. Generate a new token and be sure to enable `repo:status`.)
34
+ * `job_name` and `build_url` are optional, but all other parameters are required
35
+
36
+ ## Example
37
+
38
+ 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`.
39
+
40
+ ## Run tests for this plugin
41
+
42
+ To run both the tests, and code style validation, run
43
+
44
+ ```
45
+ rake
46
+ ```
47
+
48
+ To automatically fix many of the styling issues, use
49
+ ```
50
+ rubocop -a
51
+ ```
52
+
53
+ ## Issues and Feedback
54
+
55
+ For any other issues and feedback about this plugin, please submit it to this repository.
56
+
57
+ ## Troubleshooting
58
+
59
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
60
+
61
+ ## Using `fastlane` Plugins
62
+
63
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
64
+
65
+ ## About `fastlane`
66
+
67
+ `fastlane` is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/github_job_status/version'
2
+
3
+ module Fastlane
4
+ module GithubJobStatus
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::GithubJobStatus.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,124 @@
1
+ module Fastlane
2
+ module Actions
3
+ class GithubJobStatusAction < Action
4
+ require 'rest-client'
5
+
6
+ def self.run(params)
7
+ api = "https://api.github.com/repos"
8
+ url = "#{api}/#{params[:owner]}/#{params[:repo]}/statuses/#{params[:sha]}"
9
+
10
+ headers = {
11
+ 'Authorization' => "token #{params[:token]}",
12
+ 'User-Agent' => 'fastlane',
13
+ 'content_type' => :json,
14
+ 'accept' => :json
15
+ }
16
+
17
+ payload = {
18
+ state: params[:state],
19
+ description: description_for_state(params[:state])
20
+ }
21
+ context = params[:job_name]
22
+ payload['context'] = context unless context.nil?
23
+ target_url = params[:build_url]
24
+ payload['target_url'] = target_url unless target_url.nil?
25
+
26
+ begin
27
+ post(url, payload.to_json, headers)
28
+ true
29
+ rescue RestClient::ExceptionWithResponse => e
30
+ UI.error "Status failed to post to GitHub. Recieved the following response from the server: #{e.response}"
31
+ false
32
+ end
33
+ end
34
+
35
+ def self.post(url, payload, headers)
36
+ RestClient.post(url, payload, headers)
37
+ end
38
+
39
+ def self.description_for_state(state)
40
+ case state
41
+ when 'pending'
42
+ 'Job pending'
43
+ when 'success'
44
+ 'Job succeeded'
45
+ when 'error'
46
+ 'Job failed'
47
+ when 'failure'
48
+ 'Job unstable'
49
+ end
50
+ end
51
+
52
+ def self.description
53
+ "Post the status of your test jobs to your pull requests"
54
+ end
55
+
56
+ def self.authors
57
+ ["Justin Singer"]
58
+ end
59
+
60
+ def self.return_value
61
+ "True if status posted sucessfully, False otherwise"
62
+ end
63
+
64
+ def self.details
65
+ "Uses github's status API (https://developer.github.com/v3/repos/statuses/) to display the status of continuous integration jobs directly on pull requests."
66
+ end
67
+
68
+ def self.available_options
69
+ [
70
+ FastlaneCore::ConfigItem.new(
71
+ key: :token,
72
+ env_name: 'GITHUB_JOB_STATUS_TOKEN',
73
+ description: 'OAuth token for :owner GitHub account',
74
+ verify_block: proc { |value| UI.user_error! "Token must be specified" if value.empty? }
75
+ ),
76
+ FastlaneCore::ConfigItem.new(
77
+ key: :owner,
78
+ env_name: 'GITHUB_JOB_STATUS_OWNER',
79
+ description: 'The github owner or username',
80
+ verify_block: proc { |value| UI.user_error! "Owner must be specified" if value.empty? }
81
+ ),
82
+ FastlaneCore::ConfigItem.new(
83
+ key: :repo,
84
+ env_name: 'GITHUB_JOB_STATUS_REPO',
85
+ description: 'The github repo',
86
+ verify_block: proc { |value| UI.user_error! "Repo must be specified" if value.empty? }
87
+ ),
88
+ FastlaneCore::ConfigItem.new(
89
+ key: :sha,
90
+ env_name: 'GITHUB_JOB_STATUS_SHA',
91
+ description: 'The github sha of the commit',
92
+ verify_block: proc { |value| UI.user_error! "SHA must be specified" if value.empty? }
93
+ ),
94
+ FastlaneCore::ConfigItem.new(
95
+ key: :job_name,
96
+ env_name: 'GITHUB_JOB_STATUS_JOB_NAME',
97
+ description: 'The string displayed next to the status indicator but before the description',
98
+ optional: true
99
+ ),
100
+ FastlaneCore::ConfigItem.new(
101
+ key: :build_url,
102
+ env_name: 'GITHUB_JOB_STATUS_BUILD_URL',
103
+ description: 'The url of the build upon which we are reporting the status',
104
+ optional: true
105
+ ),
106
+ FastlaneCore::ConfigItem.new(
107
+ key: :state,
108
+ env_name: 'GITHUB_JOB_STATUS_STATE',
109
+ description: 'The state of a build; must be pending, success, error, or failure',
110
+ verify_block: proc do |value|
111
+ unless ['pending', 'success', 'error', 'failure'].include?(value)
112
+ UI.user_error! "Invalid state '#{value}' given. State must be pending, success, error, or failure."
113
+ end
114
+ end
115
+ )
116
+ ]
117
+ end
118
+
119
+ def self.is_supported?(platform)
120
+ true
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,12 @@
1
+ module Fastlane
2
+ module Helper
3
+ class GithubJobStatusHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::GithubJobStatusHelper.your_method`
6
+ #
7
+ def self.show_message
8
+ UI.message("Hello from the github_job_status plugin helper!")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module GithubJobStatus
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-github_job_status
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Justin Singer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fastlane
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.107.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.107.0
111
+ description:
112
+ email: justinsinger1@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - LICENSE
118
+ - README.md
119
+ - lib/fastlane/plugin/github_job_status.rb
120
+ - lib/fastlane/plugin/github_job_status/actions/github_job_status_action.rb
121
+ - lib/fastlane/plugin/github_job_status/helper/github_job_status_helper.rb
122
+ - lib/fastlane/plugin/github_job_status/version.rb
123
+ homepage: https://github.com/justinsinger/fastlane_plugins/tree/github_job_status/fastlane-plugin-github_job_status
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.6.8
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Post the status of your test jobs to your pull requests
147
+ test_files: []
148
+ has_rdoc: