Skip to content

Commit

Permalink
test only_changed
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Jul 12, 2024
1 parent e50a873 commit 705dbf7
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,43 @@ jobs:
skip_install: 'true'
use_bundler: 'true'
- run: test "$(bundle exec rubocop --version)" == "1.18.1"
test-only_changed:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
INPUT_ONLY_CHANGED: 'true'
steps:
- uses: actions/checkout@v4
- name: setup
run: |
git config user.email "workflow@github.com"
git config user.name "I am an automated workflow"
- name: Check when there are relevant files
run: |
git checkout ${{ github.sha }}
cp test/only_changed/few_relevant/files/* .
git add *
git commit -m auto
export PATH=test/only_changed/few_relevant/mock_bins:test/only_changed/shared_mock_bins:$PATH
BASE_REF=$(git rev-parse HEAD~) HEAD_REF=$(git rev-parse HEAD) ./script.sh
- name: Check when there are no relevant files
run: |
git checkout ${{ github.sha }}
cp test/only_changed/nothing_relevant/files/* .
git add *
git commit -m auto
export PATH=test/only_changed/nothing_relevant/mock_bins:test/only_changed/shared_mock_bins:$PATH
BASE_REF=$(git rev-parse HEAD~) HEAD_REF=$(git rev-parse HEAD) ./script.sh
- name: Check when there are too many relevant files
run: |
git checkout ${{ github.sha }}
touch a{00..100}.rb
git add *
git commit -m auto
export PATH=test/only_changed/too_many_relevant/mock_bins:test/only_changed/shared_mock_bins:$PATH
BASE_REF=$(git rev-parse HEAD~) HEAD_REF=$(git rev-parse HEAD) ./script.sh
1 change: 1 addition & 0 deletions test/only_changed/few_relevant/files/a.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello, " + "world!"

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/few_relevant/files/a.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Prefer string interpolation to string concatenation. Raw Output: test/only_changed/few_relevant/files/a.rb:1:6: C: Style/StringConcatenation: Prefer string interpolation to string concatenation.

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Prefer single-quoted strings when you don't need string interpolation or special symbols. Raw Output: test/only_changed/few_relevant/files/a.rb:1:6: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Prefer single-quoted strings when you don't need string interpolation or special symbols. Raw Output: test/only_changed/few_relevant/files/a.rb:1:18: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/few_relevant/files/a.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Prefer string interpolation to string concatenation. Raw Output: test/only_changed/few_relevant/files/a.rb:1:6: C: Style/StringConcatenation: Prefer string interpolation to string concatenation.

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Prefer single-quoted strings when you don't need string interpolation or special symbols. Raw Output: test/only_changed/few_relevant/files/a.rb:1:6: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check warning on line 1 in test/only_changed/few_relevant/files/a.rb

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Prefer single-quoted strings when you don't need string interpolation or special symbols. Raw Output: test/only_changed/few_relevant/files/a.rb:1:18: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
1 change: 1 addition & 0 deletions test/only_changed/few_relevant/files/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello, " + "world!"
8 changes: 8 additions & 0 deletions test/only_changed/few_relevant/mock_bins/reviewdog
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

read -r input

if ! [ "$input" == "Mock message for reviewdog" ]; then
echo "reviewdog mock got unexpected input: $input"
exit 1
fi
10 changes: 10 additions & 0 deletions test/only_changed/few_relevant/mock_bins/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

Check warning on line 1 in test/only_changed/few_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/few_relevant/mock_bins/rubocop:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

Check warning on line 1 in test/only_changed/few_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/few_relevant/mock_bins/rubocop:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

case ARGV
when %w[--list-target-files]
puts Dir['**/*.rb']
when %W[--require #{ENV['GITHUB_ACTION_PATH']}/rdjson_formatter/rdjson_formatter.rb --format RdjsonFormatter --fail-level error a.rb]

Check warning on line 6 in test/only_changed/few_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Line is too long. [133/120] Raw Output: test/only_changed/few_relevant/mock_bins/rubocop:6:121: C: Layout/LineLength: Line is too long. [133/120]

Check warning on line 6 in test/only_changed/few_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Line is too long. [133/120] Raw Output: test/only_changed/few_relevant/mock_bins/rubocop:6:121: C: Layout/LineLength: Line is too long. [133/120]
puts 'Mock message for reviewdog'
else
abort "rubocop mock called with unexpected arguments:\n#{ARGV.join("\n")}"
end
1 change: 1 addition & 0 deletions test/only_changed/nothing_relevant/files/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello, " + "world!"
4 changes: 4 additions & 0 deletions test/only_changed/nothing_relevant/mock_bins/reviewdog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

echo "reviewdog mock got called unexpectedly"
exit 1
8 changes: 8 additions & 0 deletions test/only_changed/nothing_relevant/mock_bins/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby

Check warning on line 1 in test/only_changed/nothing_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/nothing_relevant/mock_bins/rubocop:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

Check warning on line 1 in test/only_changed/nothing_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/nothing_relevant/mock_bins/rubocop:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

case ARGV
when %w[--list-target-files]
puts Dir['**/*.rb']
else
abort "rubocop mock called with unexpected arguments:\n#{ARGV.join("\n")}"
end
9 changes: 9 additions & 0 deletions test/only_changed/shared_mock_bins/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ "$1" = "exec" ]; then
shift
eval "$@"
else
echo "Only 'exec' command is supported"
exit 1
fi
8 changes: 8 additions & 0 deletions test/only_changed/shared_mock_bins/curl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

arguments="$@"

if [ "$arguments" != "-sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh" ]; then
echo "curl mock got unexpected arguments: $arguments"
exit 1
fi
8 changes: 8 additions & 0 deletions test/only_changed/too_many_relevant/mock_bins/reviewdog
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

read -r input

if [ "$input" != "Mock message for reviewdog" ]; then
echo "reviewdog mock got unexpected input: $input"
exit 1
fi
10 changes: 10 additions & 0 deletions test/only_changed/too_many_relevant/mock_bins/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

Check warning on line 1 in test/only_changed/too_many_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/too_many_relevant/mock_bins/rubocop:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

Check warning on line 1 in test/only_changed/too_many_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: test/only_changed/too_many_relevant/mock_bins/rubocop:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

case ARGV
when %w[--list-target-files]
puts Dir['**/*.rb']
when %W[--require #{ENV['GITHUB_ACTION_PATH']}/rdjson_formatter/rdjson_formatter.rb --format RdjsonFormatter --fail-level error]

Check warning on line 6 in test/only_changed/too_many_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Line is too long. [128/120] Raw Output: test/only_changed/too_many_relevant/mock_bins/rubocop:6:121: C: Layout/LineLength: Line is too long. [128/120]

Check warning on line 6 in test/only_changed/too_many_relevant/mock_bins/rubocop

View workflow job for this annotation

GitHub Actions / test-skip-install-and-use-bundler

[rubocop] reported by reviewdog 🐶 Line is too long. [128/120] Raw Output: test/only_changed/too_many_relevant/mock_bins/rubocop:6:121: C: Layout/LineLength: Line is too long. [128/120]
puts 'Mock message for reviewdog'
else
abort "rubocop mock called with unexpected arguments:\n#{ARGV.join("\n")}"
end

0 comments on commit 705dbf7

Please sign in to comment.