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

Fix rake task for modified spec #1302

Merged
merged 7 commits into from
Dec 26, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
run_modified_files_in_default_docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout HEAD
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch the full history to access other branches
- name: Fetch master branch
run: git fetch origin master # Fetch the master branch
- name: Running test inside doc-builder-testing
run: |
docker build -t doc-builder-testing .
Expand Down
17 changes: 10 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,23 @@ task :in_modified_specs do
run_default = false

# get changes in framework
lib_diff = `git diff --name-only origin/master -- lib dockerfiles Dockerfile Gemfile Gemfile.lock`
run_default = true unless lib_diff.empty?
lib_diff = `git diff --name-only origin/master -- lib dockerfiles Dockerfile Gemfile Gemfile.lock 2>&1`
# check of comparison results/errors
run_default = true if !lib_diff.empty? || lib_diff.include?('fatal:')

# get changes in scripts and find them in spec
scripts_diff = `git diff --name-only origin/master -- js python | xargs -I {} grep -Rl {} spec`
# get changes in spec
spec_diff = `git diff --name-only origin/master -- spec ':!spec/spec_helper.rb' ':!spec/test_data.rb'`
files = spec_diff.split | scripts_diff.split

if files.all? { |element| element =~ %r{^spec/.*\.rb} }
files.empty? ? print('NO TESTS TO RUN.') : sh("bundle exec parallel_rspec #{files.join(' ')}")
else
print("An incorrect file type for rspec has been detected: #{files}")
run_default = true
unless run_default
if files.all? { |element| element =~ %r{^spec/.*\.rb} }
files.empty? ? print('NO TESTS TO RUN.') : sh("bundle exec parallel_rspec #{files.join(' ')}")
else
print("An incorrect file type for rspec has been detected: #{files}")
run_default = true
end
end

Rake::Task['default'].invoke if run_default
Expand Down
Loading