Skip to content

Commit

Permalink
run only modified spec (#1287)
Browse files Browse the repository at this point in the history
* task for running modified tests
  • Loading branch information
lemonowl authored Dec 23, 2024
1 parent 3ded7f4 commit 2432219
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ jobs:
- name: Check that code 100% documented
run: yardoc . | grep -q '100.00% documented'

run_all_specs_in_default_docker:
run_modified_files_in_default_docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Running test inside doc-builder-testing
run: |
docker build -t doc-builder-testing .
docker run -t doc-builder-testing
docker run -t doc-builder-testing in_modified_specs
run_critical_in_default_docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Running test inside doc-builder-testing
run: |
docker build -t doc-builder-testing .
docker run -t doc-builder-testing rspec_critical
run_critical_in_all_dockerfiles:
runs-on: ubuntu-latest
Expand Down
24 changes: 24 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,27 @@ desc 'run project spec'
task :project_spec do
system('bundle exec parallel_rspec project_spec')
end

desc 'run tests in modified specs'
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?

# 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
end

Rake::Task['default'].invoke if run_default
end

0 comments on commit 2432219

Please sign in to comment.