rspec-github-actions-formatter 0.1.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 +7 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/Rakefile +2 -0
- data/bin/setup +8 -0
- data/lib/rspec_github_actions_formatter.rb +116 -0
- data/rspec-github-actions-formatter.gemspec +27 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 781da4bb8f3efbc09d80174d5ac3e3e84233750370ac609dca294bdac9adad5d
|
4
|
+
data.tar.gz: ba58cf117e2f896d6426fe66cbefc25ef9aa895a55266f564ce85c5ccb3bace9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e79067ab9c853f93a22c6f9f89dced12c7859d5ce85d30cb1def8017b0c290f93e85fb1aca5f4363aa8109122e86285690ae3d2d64acb9460922c59f2931a68a
|
7
|
+
data.tar.gz: a9f774943edd415a01192cd19d43aa01a1f0158fe24fe1bec61a860eb3d5cf937a8cec1913c3798e0375bc0b36f3626cd7fc8d58039165e47467061677b2cb88
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at steve.hill@divido.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-github-actions-formatter (0.1.0)
|
5
|
+
rspec (~> 3.9.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
rake (12.3.3)
|
12
|
+
rspec (3.9.0)
|
13
|
+
rspec-core (~> 3.9.0)
|
14
|
+
rspec-expectations (~> 3.9.0)
|
15
|
+
rspec-mocks (~> 3.9.0)
|
16
|
+
rspec-core (3.9.2)
|
17
|
+
rspec-support (~> 3.9.3)
|
18
|
+
rspec-expectations (3.9.2)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.9.0)
|
21
|
+
rspec-mocks (3.9.1)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.9.0)
|
24
|
+
rspec-support (3.9.3)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
rake (~> 12.0)
|
31
|
+
rspec-github-actions-formatter!
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Steve Hill
|
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,59 @@
|
|
1
|
+
# rspec-github-actions-formatter
|
2
|
+
|
3
|
+
This is a custom formatter for use with RSpec 3.9 and above.
|
4
|
+
|
5
|
+
It's designed to integrate with GitHub Actions, so that failing and
|
6
|
+
pending specs are annotated correctly, but it also solves an issue
|
7
|
+
I had with the way that actions handles streaming to STDOUT.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'rspec-github-actions-formatter'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install rspec-github-actions-formatter
|
24
|
+
|
25
|
+
If you're using this with Rails, you can probably just add it to
|
26
|
+
the `test` group in your Gemfile.
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
Once you've installed the gem, you'll need to tell Rspec to use it.
|
31
|
+
This can be done by adding this line to the `.rspec` file:
|
32
|
+
|
33
|
+
--format RspecGithubActionsFormatter
|
34
|
+
|
35
|
+
You could also require it directly when executing RSpec:
|
36
|
+
|
37
|
+
$ bundle exec rspec --format RspecGithubActionsFormatter
|
38
|
+
|
39
|
+
The annotations output won't be very useful unless you're executing
|
40
|
+
your tests within GitHub Actions, but the progress display is quite
|
41
|
+
useful no matter where you run your tests!
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec-github-actions-formatter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rspec-github-actions-formatter/blob/master/CODE_OF_CONDUCT.md).
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
56
|
+
|
57
|
+
## Code of Conduct
|
58
|
+
|
59
|
+
Everyone interacting in the Rspec::Github::Actions::Formatter project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rspec-github-actions-formatter/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require "rspec/core/formatters/progress_formatter"
|
2
|
+
|
3
|
+
class RspecGithubActionsFormatter < RSpec::Core::Formatters::ProgressFormatter
|
4
|
+
VERSION = "0.1.0"
|
5
|
+
|
6
|
+
RSpec::Core::Formatters.register self, :dump_pending, :dump_failures, :example_passed, :example_pending, :example_failed, :example_started, :start
|
7
|
+
|
8
|
+
def start(example_count)
|
9
|
+
@example_count = example_count.count
|
10
|
+
@examples_executed = 0
|
11
|
+
@tests_per_line = terminal_width - progress_display_width(@example_count)
|
12
|
+
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def example_started(_notification)
|
17
|
+
@examples_executed += 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def example_passed(notification)
|
21
|
+
super
|
22
|
+
|
23
|
+
split_progress_into_lines(notification)
|
24
|
+
end
|
25
|
+
|
26
|
+
def example_pending(notification)
|
27
|
+
super
|
28
|
+
|
29
|
+
split_progress_into_lines(notification)
|
30
|
+
end
|
31
|
+
|
32
|
+
def example_failed(notification)
|
33
|
+
super
|
34
|
+
|
35
|
+
split_progress_into_lines(notification)
|
36
|
+
end
|
37
|
+
|
38
|
+
def dump_pending(notification)
|
39
|
+
if notification.pending_examples.length > 0
|
40
|
+
super
|
41
|
+
@output << pending_examples_output(notification)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def dump_failures(notification)
|
46
|
+
if notification.failed_examples.length > 0
|
47
|
+
super
|
48
|
+
@output << failed_examples_output(notification)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def split_progress_into_lines(_notification)
|
55
|
+
if @examples_executed % @tests_per_line == 0 || @examples_executed == @example_count
|
56
|
+
output.print progress_display(@examples_executed, @example_count)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def pending_examples_output(notification)
|
61
|
+
pending_examples_output = notification.pending_examples.map do |example|
|
62
|
+
pending_example_output(example)
|
63
|
+
end
|
64
|
+
build_examples_output(pending_examples_output)
|
65
|
+
end
|
66
|
+
|
67
|
+
def pending_example_output(example)
|
68
|
+
execution_result = example.execution_result
|
69
|
+
message = execution_result.pending_message
|
70
|
+
file, line = file_and_line(example.location)
|
71
|
+
|
72
|
+
"::warning file=#{file},line=#{line},#{message}"
|
73
|
+
end
|
74
|
+
|
75
|
+
# Loops through all of the failed examples and rebuilds the exception message
|
76
|
+
def failed_examples_output(notification)
|
77
|
+
failed_examples_output = notification.failed_examples.map do |example|
|
78
|
+
failed_example_output example
|
79
|
+
end
|
80
|
+
build_examples_output(failed_examples_output)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Extracts the full_description, location and formats the message of each example exception
|
84
|
+
def failed_example_output(example)
|
85
|
+
execution_result = example.execution_result
|
86
|
+
message = escape_newlines(execution_result.exception.message)
|
87
|
+
file, line = file_and_line(example.location)
|
88
|
+
|
89
|
+
"::error file=#{file},line=#{line},#{message}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def build_examples_output(output)
|
93
|
+
output.join("\n")
|
94
|
+
end
|
95
|
+
|
96
|
+
def escape_newlines(message)
|
97
|
+
message.gsub('\n', '\\n')
|
98
|
+
end
|
99
|
+
|
100
|
+
def file_and_line(location)
|
101
|
+
location.delete_prefix("./").split(":")
|
102
|
+
end
|
103
|
+
|
104
|
+
def terminal_width
|
105
|
+
`tput cols`.to_i || 80
|
106
|
+
end
|
107
|
+
|
108
|
+
def progress_display(executed_examples, total_examples)
|
109
|
+
max_width = total_examples.to_s.size
|
110
|
+
sprintf " [%#{max_width}d / %#{max_width}d]", executed_examples, total_examples
|
111
|
+
end
|
112
|
+
|
113
|
+
def progress_display_width(example_count)
|
114
|
+
progress_display(example_count, example_count).size
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "rspec-github-actions-formatter"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Steve Hill"]
|
5
|
+
spec.email = ["steve@stevehill.xyz"]
|
6
|
+
|
7
|
+
spec.summary = %q{RSpec formatter for use with GitHub Actions.}
|
8
|
+
spec.description = %q{This custom formatter provides a line-streaming output for RSpec, and will also output annotations from any pending, skipped or failing tests in the format GitHub Actions requires.}
|
9
|
+
spec.homepage = "https://github.com/stevehill1981/rspec-github-actions-formatter"
|
10
|
+
spec.license = "MIT"
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
12
|
+
|
13
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
14
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
15
|
+
spec.metadata["changelog_uri"] = "https://github.com/stevehill1981/rspec-github-actions-formatter/blob/master/CHANGELOG.md"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "rspec", "~> 3.9.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-github-actions-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steve Hill
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.9.0
|
27
|
+
description: This custom formatter provides a line-streaming output for RSpec, and
|
28
|
+
will also output annotations from any pending, skipped or failing tests in the format
|
29
|
+
GitHub Actions requires.
|
30
|
+
email:
|
31
|
+
- steve@stevehill.xyz
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".gitignore"
|
37
|
+
- CHANGELOG.md
|
38
|
+
- CODE_OF_CONDUCT.md
|
39
|
+
- Gemfile
|
40
|
+
- Gemfile.lock
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- bin/setup
|
45
|
+
- lib/rspec_github_actions_formatter.rb
|
46
|
+
- rspec-github-actions-formatter.gemspec
|
47
|
+
homepage: https://github.com/stevehill1981/rspec-github-actions-formatter
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata:
|
51
|
+
homepage_uri: https://github.com/stevehill1981/rspec-github-actions-formatter
|
52
|
+
source_code_uri: https://github.com/stevehill1981/rspec-github-actions-formatter
|
53
|
+
changelog_uri: https://github.com/stevehill1981/rspec-github-actions-formatter/blob/master/CHANGELOG.md
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.3.0
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.1.2
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: RSpec formatter for use with GitHub Actions.
|
73
|
+
test_files: []
|