undercover 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1eb3fb245f9d09808a19a1605fb6c70aac3c77cc8f52b8cc07b756ba33542ac3
4
- data.tar.gz: d8895855e6e3e3c98446c43ce59e489ba5e2e79c5da6a2e091a195284462bff9
3
+ metadata.gz: 0d1c42774adbdc9699ebdd44b4ec5d20b3a00aa5ac8da172c61fd4742932ecc8
4
+ data.tar.gz: 914cd5575c028904029e9958e6cab614937a1fc654cc59077994870b1ef687dd
5
5
  SHA512:
6
- metadata.gz: b57b782e8e9258729c94d9455bf9c410cc51761ce97082550e7ed1eb78f38bb5fa8ccc6ed4678c64cb6f662ddf36f3d961d6856371026fe5d2fb5a57fce51fa4
7
- data.tar.gz: 2748d7c27b2636323c15e08bbb27d7cf9d2ae58992f34e33afd79214d11adae7ba2180e383d26814271d2058c6bf16fb03d8ed552b6ef0376b497b10111532f1
6
+ metadata.gz: 2957a4d20fe41d13835985e23213e1ddaf19786d09d451faecf269074f9e21f7d1120f2d7aec8d4f17e59c63dde430100e799fa2915648f5d549cc305f7b3e49
7
+ data.tar.gz: 4a1e0805e0b9cf51d4eb9ebd0f962637f04b523584568cab7196a9875cf48f7457b01d7f01f0281bbc466d21043c5b145a8b88308306dbbe31a38f767141b43b
@@ -0,0 +1,25 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/brigade/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/brigade/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+
18
+ CommitMsg:
19
+ CapitalizedSubject:
20
+ enabled: false
21
+ PrePush:
22
+ Undercover:
23
+ enabled: true
24
+ required: true
25
+ command: ['undercover', '--compare', 'origin/master']
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5.1
4
- - 2.4.4
5
- - 2.3.4
3
+ - 2.5.3
4
+ - 2.4.5
5
+ - 2.3.8
6
6
  before_install:
7
7
  - gem install bundler undercover
8
8
  - gem update --system
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.2] - 2018-12-16
10
+ ### Fixed
11
+ - Change stale_coverage error into a warning
12
+
9
13
  ## [0.2.1] - 2018-09-26
10
14
  ### Fixed
11
15
  - Bug in mapping changed lines to coverage results
@@ -54,7 +58,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
54
58
  ### Added
55
59
  - First release of `undercover` 🎉
56
60
 
57
- [Unreleased]: https://github.com/grodowski/undercover/compare/v0.2.1...HEAD
61
+ [Unreleased]: https://github.com/grodowski/undercover/compare/v0.2.2...HEAD
62
+ [0.2.2]: https://github.com/grodowski/undercover/compare/v0.2.1...v0.2.2
58
63
  [0.2.1]: https://github.com/grodowski/undercover/compare/v0.2.0...v0.2.1
59
64
  [0.2.0]: https://github.com/grodowski/undercover/compare/v0.1.7...v0.2.0
60
65
  [0.1.7]: https://github.com/grodowski/undercover/compare/v0.1.6...v0.1.7
data/README.md CHANGED
@@ -4,30 +4,13 @@
4
4
 
5
5
  **Inspects files in a git diff and warns on methods, classes and blocks which need test coverage.** Use it locally or as part of an automated build to shorten your code coverage feedback loop!
6
6
 
7
- ## Why?
8
-
9
- I wanted to create a tool to help others and myself ensure that tests are written for all the recent code changes. This should be useful for any ruby project, but especially those large or legacy codebases that lack testing (and we can't or don't want to invest in full test coverage).
10
-
11
- The goal was to provide automated warnings, that are:
12
- - relevant, so scoped to the actual code changes
13
- - timely, so we don't end up writing tests long after the implementation
14
- - actionable, so we can fix them before the code is committed or reaches production
15
-
16
- For more background, please [read the blog post](https://medium.com/futuredev/stop-shipping-untested-ruby-code-with-undercover-1edc963be4a6).
17
-
18
- ## How?
19
-
20
- Technically, `undercover` combines data from git, coverage reports and code structure graphs.
21
-
22
7
  A sample output of `undercover` ran before a commit may look like this:
23
8
 
24
- ![screenshot warning](screenshot_warnings.png)
9
+ ![screenshot warning](docs/screenshot_warnings.png)
25
10
 
26
11
  And like this, given that specs were added:
27
12
 
28
- ![screenshot success](screenshot_success.png)
29
-
30
- The project is in an early phase, so please expect the unexpected and [report any problems or feedback as issues](https://github.com/grodowski/undercover/issues).
13
+ ![screenshot success](docs/screenshot_success.png)
31
14
 
32
15
  [![Build Status](https://travis-ci.org/grodowski/undercover.svg?branch=master)](https://travis-ci.org/grodowski/undercover)
33
16
  [![Maintainability](https://api.codeclimate.com/v1/badges/b403feed68a18c072ec5/maintainability)](https://codeclimate.com/github/grodowski/undercover/maintainability)
@@ -67,7 +50,6 @@ SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
67
50
  SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
68
51
  SimpleCov.start do
69
52
  add_filter(/^\/spec\//) # For RSpec
70
-
71
53
  add_filter(/^\/test\//) # For Minitest
72
54
  end
73
55
 
@@ -80,22 +62,25 @@ Then run your test suite once through to generate the initial `coverage/lcov/*.l
80
62
 
81
63
  ## Usage
82
64
 
83
- ### Compare method and class coverage with latest commit
65
+ Invoked with no arguments, Undercover will flag all untested methods and classes from the current diff:
84
66
 
85
67
  ```sh
86
68
  undercover
87
69
  ```
88
70
 
89
- ### Compare with branch/ref
90
-
91
- Undercover will list all methods and classes that haven't been covered in specs and have been added since a given git `ref`. Use the `-c --compare ref` flag to specify a git ref (commit hash, branch name, tag) to compare against.
92
-
93
- **This is a recommended usage for CI/CD build environments**, as `undercover` will `exit 1` if there are any warnings.
71
+ Use the `-c --compare ref` flag to specify a git ref (commit hash, branch name, tag) to compare against. **This is a recommended usage for CI/CD build environments**, as `undercover` will `exit 1` if there are any warnings.
94
72
 
95
73
  ```sh
96
- undercover --compare master
74
+ undercover --compare origin/master
97
75
  ```
98
76
 
77
+ Check out `docs/` for CI configuration examples:
78
+ - [Travis CI](docs/travis.yml)
79
+ - [CircleCI - simple](docs/circleci_config.yml)
80
+ - [CircleCI - advanced](docs/circleci_advanced.yml)
81
+ - [Semaphore](docs/semaphore.yml)
82
+ - [Codeship](docs/codeship.md)
83
+
99
84
  ### Options
100
85
 
101
86
  ```sh
@@ -109,7 +94,18 @@ Usage: undercover [options]
109
94
  --version Show version
110
95
  ```
111
96
 
112
- The defaults assume that the program is run from the top level of the project directory.
97
+ Default options assume that the program is run from the top level of the project directory.
98
+
99
+ ## Why?
100
+
101
+ I wanted to create a tool to help others and myself ensure that tests are written for all the recent code changes. This should be useful for any ruby project, but especially those large or legacy codebases that lack testing (and we can't or don't want to invest in full test coverage).
102
+
103
+ The goal was to provide automated warnings, that are:
104
+ - relevant, so scoped to the actual code changes
105
+ - timely, so we don't end up writing tests long after the implementation
106
+ - actionable, so we can fix them before the code is committed or reaches production
107
+
108
+ For more background, please [read the blog post](https://medium.com/futuredev/stop-shipping-untested-ruby-code-with-undercover-1edc963be4a6).
113
109
 
114
110
  ## Development
115
111
 
@@ -0,0 +1,55 @@
1
+ # Advanced CircleCI workflow config with file sharing
2
+ # and separate jobs for tests and running coverage checks.
3
+
4
+ version: 2
5
+ jobs:
6
+ test:
7
+ docker:
8
+ - image: circleci/ruby:2.5-browsers
9
+ steps:
10
+ - checkout
11
+ - run:
12
+ name: Install dependencies
13
+ command: |
14
+ sudo apt-get install cmake
15
+ bundle install
16
+ - run:
17
+ name: Run RSpec
18
+ command: |
19
+ mkdir -p /tmp/coverage
20
+ bundle exec rspec
21
+ - run:
22
+ name: Store coverage report
23
+ command: mv coverage/lcov/project.lcov /tmp/coverage/
24
+ - persist_to_workspace:
25
+ root: /tmp/coverage
26
+ paths: .
27
+ - store_artifacts:
28
+ path: /tmp/coverage
29
+ destination: coverage
30
+ analyse_coverage:
31
+ docker:
32
+ - image: circleci/ruby:2.5-browsers
33
+ steps:
34
+ - checkout
35
+ - attach_workspace:
36
+ at: /tmp/coverage # gives access to project's LCOV report
37
+ - run:
38
+ name: Check coverage
39
+ command: |
40
+ sudo apt-get install cmake
41
+ gem install undercover
42
+ undercover --lcov /tmp/coverage/project.lcov \
43
+ --compare origin/master
44
+
45
+ workflows:
46
+ version: 2
47
+ build_and_test:
48
+ jobs:
49
+ - test
50
+ - analyse_coverage:
51
+ requires:
52
+ - test
53
+ filters:
54
+ branches:
55
+ ignore: master
@@ -0,0 +1,24 @@
1
+ # Simple CircleCI config.yml example.
2
+ # See workflow_config.yml for a more advanced example,
3
+ # that includes sharing data between containers.
4
+
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ - image: circleci/ruby:2.5-browsers
10
+ steps:
11
+ - checkout
12
+ - run:
13
+ name: Install dependencies
14
+ command: |
15
+ sudo apt-get install cmake
16
+ bundle install
17
+ - run:
18
+ name: Run RSpec
19
+ command: bundle exec rspec
20
+ - run:
21
+ name: Check coverage
22
+ command: |
23
+ gem install undercover
24
+ undercover --compare origin/master
@@ -0,0 +1,19 @@
1
+ Sample configuration to run `undercover` in Codeship CI. Edit these fields in **Project Settings**.
2
+
3
+ **Setup commands**
4
+
5
+ ```
6
+ rvm use 2.5.3 --install
7
+ bundle install
8
+ gem install undercover
9
+ ```
10
+
11
+ **Test pipeline**
12
+
13
+ ```
14
+ bundle exec rspec --format documentation --color
15
+ # pull origin/master to have a ref to compare against
16
+ git remote set-branches --add origin master
17
+ git fetch
18
+ undercover -c origin/master
19
+ ```
@@ -0,0 +1,18 @@
1
+ version: v1.0
2
+ name: RSpec + Undercover
3
+ agent:
4
+ machine:
5
+ type: e1-standard-2
6
+ os_image: ubuntu1804
7
+
8
+ blocks:
9
+ - name: "RSpec"
10
+ task:
11
+ jobs:
12
+ - name: Run Specs and Coverage
13
+ commands:
14
+ - checkout
15
+ - bundle install
16
+ - bundle exec rspec
17
+ - gem install undercover
18
+ - undercover --compare origin/master
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.5.1
4
+ - 2.4.4
5
+ - 2.3.4
6
+ before_install:
7
+ - gem install bundler undercover
8
+ - gem update --system
9
+ script:
10
+ - bundle exec rake
11
+ - git pull origin master:master
12
+ - undercover --compare master
@@ -9,13 +9,12 @@ module Undercover
9
9
  # traversing the whole project at first!
10
10
 
11
11
  WARNINGS_TO_S = {
12
- stale_coverage: Rainbow('♻️ Coverage data is older than your ' \
13
- 'latest changes. Re-run tests to update').yellow,
12
+ stale_coverage: Rainbow('🚨 WARNING: Coverage data is older than your ' \
13
+ 'latest changes and results might be incomplete. ' \
14
+ 'Re-run tests to update').yellow,
14
15
  no_changes: Rainbow('✅ No reportable changes').green
15
16
  }.freeze
16
17
 
17
- WARNINGS_TO_EXITCODE = {stale_coverage: 1, no_changes: 0}.freeze
18
-
19
18
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
20
19
  def self.run(args)
21
20
  opts = Undercover::Options.new.parse(args)
@@ -25,7 +24,7 @@ module Undercover
25
24
  error = report.validate(opts.lcov)
26
25
  if error
27
26
  puts(WARNINGS_TO_S[error])
28
- return WARNINGS_TO_EXITCODE[error]
27
+ return 0 if error == :no_changes
29
28
  end
30
29
 
31
30
  warnings = report.build_warnings
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Undercover
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undercover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Grodowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2018-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: imagen
@@ -188,6 +188,7 @@ extra_rdoc_files: []
188
188
  files:
189
189
  - ".codebeatsettings"
190
190
  - ".gitignore"
191
+ - ".overcommit.yml"
191
192
  - ".rspec"
192
193
  - ".rubocop.yml"
193
194
  - ".travis.yml"
@@ -197,6 +198,13 @@ files:
197
198
  - README.md
198
199
  - Rakefile
199
200
  - bin/undercover
201
+ - docs/circleci_advanced.yml
202
+ - docs/circleci_config.yml
203
+ - docs/codeship.md
204
+ - docs/screenshot_success.png
205
+ - docs/screenshot_warnings.png
206
+ - docs/semaphore.yml
207
+ - docs/travis.yml
200
208
  - lib/undercover.rb
201
209
  - lib/undercover/changeset.rb
202
210
  - lib/undercover/cli.rb
@@ -205,8 +213,6 @@ files:
205
213
  - lib/undercover/options.rb
206
214
  - lib/undercover/result.rb
207
215
  - lib/undercover/version.rb
208
- - screenshot_success.png
209
- - screenshot_warnings.png
210
216
  - undercover.gemspec
211
217
  homepage: https://github.com/grodowski/undercover
212
218
  licenses: