Skip to content

Commit

Permalink
Merge pull request #9933 from ojab/fixup_github_actions_formatter
Browse files Browse the repository at this point in the history
Fixup GitHub Actions formatter when run in non-default directory
  • Loading branch information
koic committed Jul 16, 2021
2 parents 3e1cc1a + 903a4f9 commit 117511e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

0 comments on commit 117511e

Please sign in to comment.