Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup GitHub Actions formatter when run in non-default directory #9933

Merged
merged 1 commit into from Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_github_actions_in_non_default_directory.md
@@ -0,0 +1 @@
* [#9933](https://github.com/rubocop/rubocop/pull/9933): Fix GitHub Actions formatter when running in non-default directory. ([@ojab][])
2 changes: 1 addition & 1 deletion lib/rubocop/formatter/git_hub_actions_formatter.rb
Expand Up @@ -33,7 +33,7 @@ def report_offense(file, offense)
output.printf(
"\n::%<severity>s file=%<file>s,line=%<line>d,col=%<column>d::%<message>s\n",
severity: github_severity(offense),
file: file,
file: PathUtil.smart_path(file),
line: offense.line,
column: offense.real_column,
message: github_escape(offense.message)
Expand Down
9 changes: 9 additions & 0 deletions spec/rubocop/formatter/git_hub_actions_formatter_spec.rb
Expand Up @@ -30,6 +30,15 @@
end
end

context 'when file is relative to the current directory' do
let(:file) { "#{Dir.pwd}/path/to/file" }

it 'reports offenses as error with the relative path' do
expect(output.string)
.to include('::error file=path/to/file,line=1,col=1::This is a message.')
end
end

context 'when no offenses are detected' do
let(:offenses) { [] }

Expand Down