danger-synx 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: 17c29d9dae89afa6205d49c9f5125a4b3ba18153
4
+ data.tar.gz: e02f2dfcc0064d33226c27154e38a41bee247523
5
+ SHA512:
6
+ metadata.gz: 6b222bb5bfe6b8367a8b540e123eb293e3b43b4b60540e1e38b5d8a6c649e9030ab15da4b8ac1b4cb60f71fc4628228150953fe4afea1c602a606b95af949556
7
+ data.tar.gz: c54aa133d280e38f433f3488effbabe6b2346abc87dc9b50f05fc93161d093bd28a13f5138ca76a7039dbe88af5c586ec1c2e11a2dc75e298ebe485fdfe58924
data/.gitignore ADDED
@@ -0,0 +1,54 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+ =======
52
+ .DS_Store
53
+ pkg
54
+ .idea/
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-synx.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-synx (0.1.0)
5
+ danger-plugin-api (~> 1.0)
6
+ synx
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ CFPropertyList (2.3.5)
12
+ activesupport (5.0.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (~> 0.7)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ addressable (2.5.0)
18
+ public_suffix (~> 2.0, >= 2.0.2)
19
+ ast (2.3.0)
20
+ claide (1.0.1)
21
+ claide-plugins (0.9.2)
22
+ cork
23
+ nap
24
+ open4 (~> 1.3)
25
+ clamp (0.6.5)
26
+ coderay (1.1.1)
27
+ colored (1.2)
28
+ colored2 (3.1.1)
29
+ colorize (0.8.1)
30
+ concurrent-ruby (1.0.4)
31
+ cork (0.2.0)
32
+ colored (~> 1.2)
33
+ danger (4.2.0)
34
+ claide (~> 1.0)
35
+ claide-plugins (>= 0.9.2)
36
+ colored2 (~> 3.1)
37
+ cork (~> 0.1)
38
+ faraday (~> 0.9)
39
+ faraday-http-cache (~> 1.0)
40
+ git (~> 1)
41
+ kramdown (~> 1.5)
42
+ octokit (~> 4.2)
43
+ terminal-table (~> 1)
44
+ danger-plugin-api (1.0.0)
45
+ danger (> 2.0)
46
+ diff-lcs (1.3)
47
+ faraday (0.11.0)
48
+ multipart-post (>= 1.2, < 3)
49
+ faraday-http-cache (1.3.1)
50
+ faraday (~> 0.8)
51
+ ffi (1.9.17)
52
+ formatador (0.2.5)
53
+ git (1.3.0)
54
+ guard (2.14.1)
55
+ formatador (>= 0.2.4)
56
+ listen (>= 2.7, < 4.0)
57
+ lumberjack (~> 1.0)
58
+ nenv (~> 0.1)
59
+ notiffany (~> 0.0)
60
+ pry (>= 0.9.12)
61
+ shellany (~> 0.0)
62
+ thor (>= 0.18.1)
63
+ guard-compat (1.2.1)
64
+ guard-rspec (4.7.3)
65
+ guard (~> 2.1)
66
+ guard-compat (~> 1.1)
67
+ rspec (>= 2.99.0, < 4.0)
68
+ i18n (0.8.0)
69
+ kramdown (1.13.2)
70
+ listen (3.0.7)
71
+ rb-fsevent (>= 0.9.3)
72
+ rb-inotify (>= 0.9.7)
73
+ lumberjack (1.0.11)
74
+ method_source (0.8.2)
75
+ minitest (5.10.1)
76
+ multipart-post (2.0.0)
77
+ nanaimo (0.2.3)
78
+ nap (1.1.0)
79
+ nenv (0.3.0)
80
+ notiffany (0.1.1)
81
+ nenv (~> 0.1)
82
+ shellany (~> 0.0)
83
+ octokit (4.6.2)
84
+ sawyer (~> 0.8.0, >= 0.5.3)
85
+ open4 (1.3.4)
86
+ parser (2.3.3.1)
87
+ ast (~> 2.2)
88
+ powerpack (0.1.1)
89
+ pry (0.10.4)
90
+ coderay (~> 1.1.0)
91
+ method_source (~> 0.8.1)
92
+ slop (~> 3.4)
93
+ public_suffix (2.0.5)
94
+ rainbow (2.2.1)
95
+ rake (10.5.0)
96
+ rb-fsevent (0.9.8)
97
+ rb-inotify (0.9.8)
98
+ ffi (>= 0.5.0)
99
+ rspec (3.5.0)
100
+ rspec-core (~> 3.5.0)
101
+ rspec-expectations (~> 3.5.0)
102
+ rspec-mocks (~> 3.5.0)
103
+ rspec-core (3.5.4)
104
+ rspec-support (~> 3.5.0)
105
+ rspec-expectations (3.5.0)
106
+ diff-lcs (>= 1.2.0, < 2.0)
107
+ rspec-support (~> 3.5.0)
108
+ rspec-mocks (3.5.0)
109
+ diff-lcs (>= 1.2.0, < 2.0)
110
+ rspec-support (~> 3.5.0)
111
+ rspec-support (3.5.0)
112
+ rubocop (0.47.1)
113
+ parser (>= 2.3.3.1, < 3.0)
114
+ powerpack (~> 0.1)
115
+ rainbow (>= 1.99.1, < 3.0)
116
+ ruby-progressbar (~> 1.7)
117
+ unicode-display_width (~> 1.0, >= 1.0.1)
118
+ ruby-progressbar (1.8.1)
119
+ sawyer (0.8.1)
120
+ addressable (>= 2.3.5, < 2.6)
121
+ faraday (~> 0.8, < 1.0)
122
+ shellany (0.0.1)
123
+ slop (3.6.0)
124
+ synx (0.2.1)
125
+ clamp (~> 0.6)
126
+ colorize (~> 0.7)
127
+ xcodeproj (~> 1.0)
128
+ terminal-table (1.7.3)
129
+ unicode-display_width (~> 1.1.1)
130
+ thor (0.19.4)
131
+ thread_safe (0.3.5)
132
+ tzinfo (1.2.2)
133
+ thread_safe (~> 0.1)
134
+ unicode-display_width (1.1.3)
135
+ xcodeproj (1.4.2)
136
+ CFPropertyList (~> 2.3.3)
137
+ activesupport (>= 3)
138
+ claide (>= 1.0.1, < 2.0)
139
+ colored (~> 1.2)
140
+ nanaimo (~> 0.2.3)
141
+ yard (0.9.8)
142
+
143
+ PLATFORMS
144
+ ruby
145
+
146
+ DEPENDENCIES
147
+ bundler (~> 1.3)
148
+ danger-synx!
149
+ guard (~> 2.14)
150
+ guard-rspec (~> 4.7)
151
+ listen (= 3.0.7)
152
+ pry
153
+ rake (~> 10.0)
154
+ rspec (~> 3.4)
155
+ rubocop (~> 0.41)
156
+ yard (~> 0.8)
157
+
158
+ BUNDLED WITH
159
+ 1.13.6
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Jakub Turek
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/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Jakub Turek <jkbturek@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Danger Synx
2
+
3
+ A Danger plugin for [Synx](https://github.com/venmo/synx/).
4
+
5
+ ## Installation
6
+
7
+ Currently only Bundler installations are supported. Add following contents to your `Gemfile`:
8
+
9
+ gem 'danger-synx'
10
+ gem 'synx', :github => 'turekj/synx', :branch => 'v0.3'
11
+
12
+ And run `bundle install`.
13
+
14
+ The plugin relies on a Synx fork because [PR #125](https://github.com/venmo/synx/pull/125) is not yet merged with the core app.
15
+
16
+ ## Usage
17
+
18
+ Add following line to the `Dangerfile`:
19
+
20
+ synx.ensure_clean_structure
21
+
22
+ `ensure_clean_structure` task runs Synx on every `.xcodeproj` file that is added/modified by a pull request. Issues are gathered and reported in a following format:
23
+
24
+ | Project file | Issue |
25
+ | --- | --- |
26
+ | MessyProject.xcodeproj | File reference RootController.swift is not synchronized with file system. |
27
+ | MessyProject.xcodeproj | Group /MessyGroup is not sorted alphabetically. |
28
+
29
+ ## Roadmap
30
+
31
+ - [x] Reporting synx issues for added/modified `.xcodeproj` files.
32
+ - [ ] Indicate unused files (`--prune`).
33
+ - [ ] Allow custom exclusions for directories (`--exclusion`).
34
+ - [ ] Support for toggleable unsorted group reports (`--no-sort-by-name`).
35
+ - [ ] Support for `--no-sort-by-name` option.
36
+
37
+ ## Development
38
+
39
+ 1. Clone this repo
40
+ 2. Run `bundle install` to setup dependencies.
41
+ 3. Run `bundle exec rspec` to run the tests.
42
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
43
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,50 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'synx/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-synx'
8
+ spec.version = Synx::VERSION
9
+ spec.authors = ['Jakub Turek']
10
+ spec.email = ['jkbturek@gmail.com']
11
+ spec.description = %q{A Danger plugin for running commited .xcodeproj through Synx.}
12
+ spec.summary = %q{A Danger plugin for running commited .xcodeproj through Synx.}
13
+ spec.homepage = 'https://github.com/elpassion/danger-synx'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
22
+ spec.add_dependency 'synx'
23
+
24
+ # General ruby development
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+
28
+ # Testing support
29
+ spec.add_development_dependency 'rspec', '~> 3.4'
30
+
31
+ # Linting code and docs
32
+ spec.add_development_dependency "rubocop", "~> 0.41"
33
+ spec.add_development_dependency "yard", "~> 0.8"
34
+
35
+ # Makes testing easy via `bundle exec guard`
36
+ spec.add_development_dependency 'guard', '~> 2.14'
37
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
38
+
39
+ # If you want to work on older builds of ruby
40
+ spec.add_development_dependency 'listen', '3.0.7'
41
+
42
+ # This gives you the chance to run a REPL inside your tests
43
+ # via:
44
+ #
45
+ # require 'pry'
46
+ # binding.pry
47
+ #
48
+ # This will stop test execution and let you inspect the results
49
+ spec.add_development_dependency 'pry'
50
+ end
@@ -0,0 +1 @@
1
+ require 'synx/plugin'
@@ -0,0 +1 @@
1
+ require 'synx/gem_version'
@@ -0,0 +1,3 @@
1
+ module Synx
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,122 @@
1
+ module Danger
2
+ # Enforces that .xcodeproj structure is tidy.
3
+ # It wraps around [Synx](https://github.com/venmo/synx)
4
+ # tool to perform the check.
5
+ #
6
+ # @example Ensure that all added / modified project files are synchronized
7
+ #
8
+ # danger_synx.ensure_clean_structure
9
+ #
10
+ # @see turekj/danger-synx
11
+ # @tags synx, xcodeproj
12
+ #
13
+ class DangerSynx < Plugin
14
+ # Ensures clean project structure. Runs Synx on all .xcodeproj
15
+ # files that where either added or modified.
16
+ #
17
+ # @return [void]
18
+ #
19
+ def ensure_clean_structure
20
+ unless synx_installed?
21
+ raise 'synx > 0.2.1 not found in PATH and failed to install'
22
+ end
23
+
24
+ generate_output synx_issues
25
+ end
26
+
27
+ # Checks whether Synx in a correct version is installed in the system.
28
+ # If not, tries to recover by installing it.
29
+ # Returns true if Synx is present or installation was successful.
30
+ #
31
+ # @return [bool]
32
+ #
33
+ def precheck_synx_installation?
34
+ `gem install synx` unless synx_installed?
35
+ synx_installed?
36
+ end
37
+
38
+ # Returns a command to run for synx
39
+ #
40
+ # @return [String]
41
+ def synx
42
+ "#{'bundle exec ' if File.exist?('Gemfile')}synx"
43
+ end
44
+
45
+ # Tests whether Synx is already installed and meets minimal
46
+ # version requirements.
47
+ #
48
+ # @return [bool]
49
+ #
50
+ def synx_installed?
51
+ match = `#{synx} --version`.match(/Synx (\d+)\.(\d+)\.(\d+)/i)
52
+ if match
53
+ major, minor, patch = match.captures.map { |c| Integer(c) }
54
+ major > 0 || minor > 2 || (minor == 2 && patch > 1)
55
+ else
56
+ false
57
+ end
58
+ end
59
+
60
+ # Triggers Synx on all projects that were modified or added
61
+ # to the project. Returns accumulated list of issues
62
+ # for those projects.
63
+ #
64
+ # @return [Array<(String, String)>]
65
+ #
66
+ def synx_issues
67
+ (git.modified_files + git.added_files)
68
+ .select { |f| f.include? '.xcodeproj' }
69
+ .reduce([]) { |i, f| i + synx_project(f) }
70
+ end
71
+
72
+ # Triggers Synx in a dry-run mode on a project file.
73
+ # Parses output and returns a list of issues.
74
+ #
75
+ # @param [String] modified_file_path
76
+ # Path of file contained in .xcodeproj to Synx
77
+ #
78
+ # @return [(String, String)]
79
+ #
80
+ def synx_project(modified_file_path)
81
+ path = project_path modified_file_path
82
+ name = project_name path
83
+ output = `#{synx} -w warning "#{path}" 2>&1`.lines
84
+ output
85
+ .map(&:strip)
86
+ .select { |o| o.start_with? 'warning: ' }
87
+ .map { |o| [name, strip_prefix(o)] }
88
+ end
89
+
90
+ private
91
+
92
+ def project_path(modified_file_path)
93
+ match = modified_file_path.match('(.+\.xcodeproj)*+')
94
+ match[0] if match
95
+ end
96
+
97
+ def project_name(project_path)
98
+ project_path.split('/').last
99
+ end
100
+
101
+ def strip_prefix(output_line)
102
+ output_line.slice(9, output_line.size - 9)
103
+ end
104
+
105
+ def generate_output(issues)
106
+ return if issues.empty?
107
+
108
+ warn("Synx detected #{issues.size} structural issue(s)")
109
+
110
+ message = "### Synx structural issues\n\n"
111
+ message << "| Project file | Issue |\n"
112
+ message << "| --- | --- |\n"
113
+
114
+ issues.each do |(project, issue)|
115
+ message << "| #{project} | #{issue} |\n"
116
+ end
117
+
118
+ markdown message
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,59 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'pry'
8
+
9
+ require 'rspec'
10
+ require 'danger'
11
+
12
+ # Use coloured output, it's the best.
13
+ RSpec.configure do |config|
14
+ config.filter_gems_from_backtrace "bundler"
15
+ config.color = true
16
+ config.tty = true
17
+ end
18
+
19
+ require 'danger_plugin'
20
+
21
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
22
+ # If you are expanding these files, see if it's already been done ^.
23
+
24
+ # A silent version of the user interface,
25
+ # it comes with an extra function `.string` which will
26
+ # strip all ANSI colours from the string.
27
+
28
+ # rubocop:disable Lint/NestedMethodDefinition
29
+ def testing_ui
30
+ @output = StringIO.new
31
+ def @output.winsize
32
+ [20, 9999]
33
+ end
34
+
35
+ cork = Cork::Board.new(out: @output)
36
+ def cork.string
37
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
38
+ end
39
+ cork
40
+ end
41
+ # rubocop:enable Lint/NestedMethodDefinition
42
+
43
+ # Example environment (ENV) that would come from
44
+ # running a PR on TravisCI
45
+ def testing_env
46
+ {
47
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
48
+ 'TRAVIS_PULL_REQUEST' => '800',
49
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
50
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
51
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
52
+ }
53
+ end
54
+
55
+ # A stubbed out Dangerfile for use in tests
56
+ def testing_dangerfile
57
+ env = Danger::EnvironmentManager.new(testing_env)
58
+ Danger::Dangerfile.new(env, testing_ui)
59
+ end
data/spec/synx_spec.rb ADDED
@@ -0,0 +1,153 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerSynx do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerSynx.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ describe 'with Dangerfile' do
10
+ before do
11
+ @dangerfile = testing_dangerfile
12
+ @synx = @dangerfile.synx
13
+ end
14
+
15
+ describe :synx do
16
+ it 'should return synx when Gemfile is not present' do
17
+ allow(File).to receive(:exist?).with('Gemfile').and_return(false)
18
+ expect(@synx.synx).to eq('synx')
19
+ end
20
+
21
+ it 'should return bundle exec synx when Gemfile is present' do
22
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
23
+ expect(@synx.synx).to eq('bundle exec synx')
24
+ end
25
+ end
26
+
27
+ describe :synx_installed? do
28
+ before do
29
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
30
+ end
31
+
32
+ it 'reports that synx is not installed if executable is not found' do
33
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('sh: synx not found')
34
+ expect(@synx.synx_installed?).to be_falsy
35
+ end
36
+
37
+ it 'reports that synx is not installed if version is 0.1.5' do
38
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 0.1.5')
39
+ expect(@synx.synx_installed?).to be_falsy
40
+ end
41
+
42
+ it 'reports that synx is not installed if version is 0.2.1' do
43
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 0.2.1')
44
+ expect(@synx.synx_installed?).to be_falsy
45
+ end
46
+
47
+ it 'reports that synx is installed if version is 0.2.2' do
48
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 0.2.2')
49
+ expect(@synx.synx_installed?).to be_truthy
50
+ end
51
+
52
+ it 'reports that synx is installed if version is 0.3.0' do
53
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 0.3.0')
54
+ expect(@synx.synx_installed?).to be_truthy
55
+ end
56
+
57
+ it 'reports that synx is installed if version is 1.0.0' do
58
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 1.0.0')
59
+ expect(@synx.synx_installed?).to be_truthy
60
+ end
61
+ end
62
+
63
+ describe :precheck_synx_installation do
64
+ before do
65
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
66
+ end
67
+
68
+ it 'should install synx if needed' do
69
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('sh: synx not found')
70
+ expect(@synx).to receive(:`).with('gem install synx')
71
+ @synx.precheck_synx_installation?
72
+ end
73
+
74
+ it 'should report that synx is installed correctly' do
75
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 0.3.0')
76
+ expect(@synx.precheck_synx_installation?).to be_truthy
77
+ end
78
+ end
79
+
80
+ describe :synx_issues do
81
+ before do
82
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
83
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 0.3.0')
84
+ end
85
+
86
+ it 'should return a list of issues found in all projects' do
87
+ allow(@synx.git).to receive(:modified_files).and_return(['A.xcodeproj/project.pbxproj', 'B.xcodeproj/project.xcworkspace'])
88
+ allow(@synx.git).to receive(:added_files).and_return([])
89
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "A.xcodeproj" 2>&1').and_return("warning: Warning.\nwarning: Another warning.\n")
90
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "B.xcodeproj" 2>&1').and_return("warning: Issue.\n")
91
+ expect(@synx.synx_issues).to match_array([['A.xcodeproj', 'Warning.'], ['A.xcodeproj', 'Another warning.'], ['B.xcodeproj', 'Issue.']])
92
+ end
93
+ end
94
+
95
+ describe :ensure_clean_structure do
96
+ before do
97
+ allow(File).to receive(:exist?).with('Gemfile').and_return(true)
98
+ allow(@synx).to receive(:`).with('bundle exec synx --version').and_return('Synx 0.3.0')
99
+ end
100
+
101
+ it 'should trigger synx for modified project files' do
102
+ allow(@synx.git).to receive(:modified_files).and_return(['Project/Sources/AppDelegate.swift', 'Project/Project.xcodeproj/project.pbxproj'])
103
+ allow(@synx.git).to receive(:added_files).and_return(['Other Project/Other Project.xcodeproj/project.pbxproj', 'Other Project/Resources/image.png/project.xcworkspace'])
104
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "Project/Project.xcodeproj" 2>&1').and_return('')
105
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "Other Project/Other Project.xcodeproj" 2>&1').and_return('')
106
+ @synx.ensure_clean_structure
107
+ end
108
+
109
+ it 'should output a warning with number of issues' do
110
+ allow(@synx.git).to receive(:modified_files).and_return(['A.xcodeproj/project.pbxproj', 'B.xcodeproj/project.xcworkspace'])
111
+ allow(@synx.git).to receive(:added_files).and_return([])
112
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "A.xcodeproj" 2>&1').and_return("warning: Warning.\nwarning: Another warning.\n")
113
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "B.xcodeproj" 2>&1').and_return("warning: Issue.\n")
114
+ expect(@synx).to receive(:warn).with('Synx detected 3 structural issue(s)')
115
+ @synx.ensure_clean_structure
116
+ end
117
+
118
+ it 'should not output warning if there are no issues' do
119
+ allow(@synx.git).to receive(:modified_files).and_return(['A.xcodeproj/project.pbxproj', 'B.xcodeproj/project.xcworkspace'])
120
+ allow(@synx.git).to receive(:added_files).and_return([])
121
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "A.xcodeproj" 2>&1').and_return('')
122
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "B.xcodeproj" 2>&1').and_return('')
123
+ expect(@synx).to_not receive(:warn)
124
+ @synx.ensure_clean_structure
125
+ end
126
+
127
+ it 'should not output markdown when there are no issues' do
128
+ allow(@synx.git).to receive(:modified_files).and_return(['A.xcodeproj/project.pbxproj', 'B.xcodeproj/project.xcworkspace'])
129
+ allow(@synx.git).to receive(:added_files).and_return([])
130
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "A.xcodeproj" 2>&1').and_return('')
131
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "B.xcodeproj" 2>&1').and_return('')
132
+ expect(@synx).to_not receive(:markdown)
133
+ @synx.ensure_clean_structure
134
+ end
135
+
136
+ it 'should output table with issues as markdown' do
137
+ allow(@synx.git).to receive(:modified_files).and_return(['A.xcodeproj/project.pbxproj', 'B.xcodeproj/project.xcworkspace'])
138
+ allow(@synx.git).to receive(:added_files).and_return([])
139
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "A.xcodeproj" 2>&1').and_return("warning: Warning.\nwarning: Another warning.\n")
140
+ expect(@synx).to receive(:`).with('bundle exec synx -w warning "B.xcodeproj" 2>&1').and_return("warning: Issue.\n")
141
+
142
+ @synx.ensure_clean_structure
143
+ output = @synx.status_report[:markdowns].first.to_s
144
+
145
+ expect(output).to include('Synx structural issues')
146
+ expect(output).to include('A.xcodeproj | Warning.')
147
+ expect(output).to include('A.xcodeproj | Another warning.')
148
+ expect(output).to include('B.xcodeproj | Issue.')
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-synx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jakub Turek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: synx
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
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.41'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.41'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.14'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.14'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '4.7'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '4.7'
139
+ - !ruby/object:Gem::Dependency
140
+ name: listen
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 3.0.7
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 3.0.7
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: A Danger plugin for running commited .xcodeproj through Synx.
168
+ email:
169
+ - jkbturek@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".travis.yml"
176
+ - Gemfile
177
+ - Gemfile.lock
178
+ - Guardfile
179
+ - LICENSE
180
+ - LICENSE.txt
181
+ - README.md
182
+ - Rakefile
183
+ - danger-synx.gemspec
184
+ - lib/danger_plugin.rb
185
+ - lib/danger_synx.rb
186
+ - lib/synx/gem_version.rb
187
+ - lib/synx/plugin.rb
188
+ - spec/spec_helper.rb
189
+ - spec/synx_spec.rb
190
+ homepage: https://github.com/elpassion/danger-synx
191
+ licenses:
192
+ - MIT
193
+ metadata: {}
194
+ post_install_message:
195
+ rdoc_options: []
196
+ require_paths:
197
+ - lib
198
+ required_ruby_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ requirements: []
209
+ rubyforge_project:
210
+ rubygems_version: 2.6.10
211
+ signing_key:
212
+ specification_version: 4
213
+ summary: A Danger plugin for running commited .xcodeproj through Synx.
214
+ test_files:
215
+ - spec/spec_helper.rb
216
+ - spec/synx_spec.rb