Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Jul 12, 2024
1 parent b1804b7 commit f72274f
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 9 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@ on: [pull_request]
jobs:
test-only-changed:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
INPUT_ONLY_CHANGED: 'true'
INPUT_USE_BUNDLER: 'false'
steps:
- uses: actions/checkout@v4
- run: |
cp test/only_checked/files/* .
git add *
- 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_checked/few_relevant/files/* .
git add *
git commit -m auto
PATH="test/only_checked/mock_bins:$PATH" \
PATH="test/only_checked/few_relevant/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_checked/nothing_relevant/files/* .
git add *
git commit -m auto
PATH="test/only_checked/nothing_relevant/mock_bins:$PATH" \
BASE_REF=$(git rev-parse HEAD~) \
HEAD_REF=$(git rev-parse HEAD) \
INPUT_ONLY_CHANGED=true \
INPUT_USE_BUNDLER=false \
./script.sh
shell: bash
File renamed without changes.
1 change: 1 addition & 0 deletions test/only_checked/few_relevant/files/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello, " + "world!"
9 changes: 9 additions & 0 deletions test/only_checked/few_relevant/mock_bins/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ "$1" = "exec" ]; then
shift
eval "$@"
else
echo "Only 'exec' command is supported"
exit 1
fi
8 changes: 8 additions & 0 deletions test/only_checked/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
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

case ARGV
when %w[--list-target-files]
puts %w[a.rb b.rb c.rb]
puts Dir['**/*.rb']
when %W[--require #{ENV['GITHUB_ACTION_PATH']}/rdjson_formatter/rdjson_formatter.rb --format RdjsonFormatter --fail-level error a.rb]
puts '{"source":{"name":"rubocop","url":"https://rubocop.org/"},"diagnostics":[],"severity":"INFO"}'
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_checked/nothing_relevant/files/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello, " + "world!"
9 changes: 9 additions & 0 deletions test/only_checked/nothing_relevant/mock_bins/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ "$1" = "exec" ]; then
shift
eval "$@"
else
echo "Only 'exec' command is supported"
exit 1
fi
4 changes: 4 additions & 0 deletions test/only_checked/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_checked/nothing_relevant/mock_bins/rubocop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby

case ARGV
when %w[--list-target-files]
puts Dir['**/*.rb']
else
abort "rubocop mock called with unexpected arguments:\n#{ARGV.join("\n")}"
end

0 comments on commit f72274f

Please sign in to comment.