travis_skipper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/travis_skipper +11 -0
- data/lib/travis_skipper.rb +21 -0
- data/lib/travis_skipper/listener.rb +78 -0
- data/lib/travis_skipper/logger.rb +17 -0
- data/lib/travis_skipper/version.rb +3 -0
- data/travis_skipper.gemspec +27 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9418eb32063fb752055b6f02e786addf8b492a65
|
4
|
+
data.tar.gz: e2ae09b6630b566d26c34ab8b93dc0fd7e78f07a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb25cbdfed2852504b794d23d8ea5096097f49d6a76510d2d8965ac25b21f0e4f3b22e82e09beb960796074b608ab907bb6335f1d9b52b6df97823a04c1c4d58
|
7
|
+
data.tar.gz: 427265423bee30bfc13e0f37e1c919fa5fc3b4bf90e7bb783e203389f6bb523724be93b4ee6922f1019826551b124ddc0b7975af9f303ebd0bc4bdb6d08e92b3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Infakt DevTeam
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# TravisSkipper
|
2
|
+
|
3
|
+
TravisSkipper allows you to build only newset changes on PRs, and Branches. When you push many commits to repo TS will cancel all build besides newest one on each branch/PR. It also cancel builds on a branch if this branch is use in PR.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'travis_skipper'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install travis_skipper
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
TravisSkipper.configure do |config|
|
25
|
+
config.travis.token = "XXX" # Token from travis
|
26
|
+
config.repository.name = "infakt/travis_skipper" # repository name
|
27
|
+
config.repository.branches = %w(master) # branches on which we want to let jobs run
|
28
|
+
config.logger.path = "logs/skipper.log" # path to log file
|
29
|
+
end
|
30
|
+
|
31
|
+
TravisSkipper::Listener.start
|
32
|
+
```
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/infakt/travis_skipper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
37
|
+
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/travis_skipper
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'travis_skipper'
|
4
|
+
|
5
|
+
TravisSkipper.configure do |config|
|
6
|
+
config.travis.token = ENV['TRAVIS_TOKEN']
|
7
|
+
config.repository.name = ENV['REPO']
|
8
|
+
config.repository.branches = ENV['BRANCHES'].split(",").map(&:strip).compact
|
9
|
+
end
|
10
|
+
|
11
|
+
TravisSkipper::Listener.start
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'dry-configurable'
|
2
|
+
require "travis_skipper/version"
|
3
|
+
require "travis_skipper/logger"
|
4
|
+
require "travis_skipper/listener"
|
5
|
+
|
6
|
+
module TravisSkipper
|
7
|
+
extend Dry::Configurable
|
8
|
+
|
9
|
+
setting :travis do
|
10
|
+
setting :token
|
11
|
+
end
|
12
|
+
|
13
|
+
setting :repository do
|
14
|
+
setting :name
|
15
|
+
setting :branches, %w(master)
|
16
|
+
end
|
17
|
+
|
18
|
+
setting :logger do
|
19
|
+
setting :path
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'travis'
|
2
|
+
|
3
|
+
module TravisSkipper
|
4
|
+
class Listener
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def start
|
8
|
+
new.start
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
Travis::Pro.access_token = config.travis.token
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
Travis::Pro.listen(repo) do |stream|
|
18
|
+
logger.log("starts..")
|
19
|
+
stream.on('build:created') do |event|
|
20
|
+
logger.log("build: ##{event.build.number}")
|
21
|
+
|
22
|
+
if event.build.pull_request?
|
23
|
+
handle_pr(event)
|
24
|
+
else
|
25
|
+
handler_branch(event)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
attr_reader :logger
|
33
|
+
|
34
|
+
def repo
|
35
|
+
@repo ||= Travis::Pro::Repository.find(config.repository.name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def config
|
39
|
+
TravisSkipper.config
|
40
|
+
end
|
41
|
+
|
42
|
+
def logger
|
43
|
+
@logger ||= TravisSkipper::Logger.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def handle_pr(event)
|
47
|
+
cancel_after(event) do |build, other_build|
|
48
|
+
other_build.pull_request? && other_build.pull_request_number == build.pull_request_number
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def handler_branch(event)
|
53
|
+
if config.repository.branches.include?(event.build.commit.branch) || config.repository.branches.empty?
|
54
|
+
cancel_after(event) do |build, other_build|
|
55
|
+
!other_build.pull_request? && other_build.commit.branch == build.commit.branch
|
56
|
+
end
|
57
|
+
else
|
58
|
+
cancel(build: event.build)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def cancel_after(event, &block)
|
63
|
+
repo.builds(after_number: event.build.number).each do | build|
|
64
|
+
if block.call(event.build, build)
|
65
|
+
cancel(build: build)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def cancel(build:)
|
71
|
+
unless build.running?
|
72
|
+
logger.log("build canceled: ##{build.number}")
|
73
|
+
build.cancel
|
74
|
+
end
|
75
|
+
rescue Travis::Client::ValidationFailed
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'travis_skipper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "travis_skipper"
|
8
|
+
spec.version = TravisSkipper::VERSION
|
9
|
+
spec.authors = ["Infakt DevTeam"]
|
10
|
+
spec.email = ["p@infakt.pl"]
|
11
|
+
|
12
|
+
spec.summary = %q{Skips duplicated build on travis}
|
13
|
+
spec.description = %q{Skips duplicated build on travis}
|
14
|
+
spec.homepage = "https://github.com/infakt/travis_skipper"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
|
25
|
+
spec.add_dependency 'travis', "~> 1.0"
|
26
|
+
spec.add_dependency 'dry-configurable', "~> 0.3"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: travis_skipper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Infakt DevTeam
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-05 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: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: travis
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dry-configurable
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.3'
|
69
|
+
description: Skips duplicated build on travis
|
70
|
+
email:
|
71
|
+
- p@infakt.pl
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/travis_skipper
|
82
|
+
- lib/travis_skipper.rb
|
83
|
+
- lib/travis_skipper/listener.rb
|
84
|
+
- lib/travis_skipper/logger.rb
|
85
|
+
- lib/travis_skipper/version.rb
|
86
|
+
- travis_skipper.gemspec
|
87
|
+
homepage: https://github.com/infakt/travis_skipper
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.5.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Skips duplicated build on travis
|
111
|
+
test_files: []
|