Skip to content

Commit b3fa6d5

Browse files
authored
[Fix #44] Support Parallel Testing (#47)
* [Fix #44] Support Parallel Testing RSpec Tracer is now able to generate valid cache reports when running specs using `parallel_tests` gem. * Add Feature Specs for Parallel Tests Support
1 parent 8091fc6 commit b3fa6d5

File tree

92 files changed

+7423
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7423
-408
lines changed

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "2"
22
checks:
33
file-lines:
44
config:
5-
threshold: 300
5+
threshold: 500
66
method-complexity:
77
config:
88
threshold: 15

.github/workflows/jruby-ruby-project.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- name: Install Dependencies
3434
run: bundle install --jobs 3 --retry 3
3535

36-
- name: Run Features for Ruby Project
36+
- name: Run Features
3737
env:
3838
RSPEC_VERSION: "~> ${{ matrix.rspec }}"
3939
SIMPLECOV_VERSION: "~> ${{ matrix.simplecov }}"
40-
run: JRUBY_OPTS="--debug -X+O" bundle exec cucumber --retry 3 --no-strict-flaky --tags @ruby-app
40+
run: JRUBY_OPTS="--debug -X+O" bundle exec cucumber --retry 3 --no-strict-flaky --tags "@ruby-app and not @parallel-tests"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: parallel-tests-ruby-project
2+
3+
on:
4+
push:
5+
branches: [ 'main' ]
6+
pull_request:
7+
8+
concurrency:
9+
group: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}-ruby-parallel-tests
10+
cancel-in-progress: true
11+
12+
jobs:
13+
main:
14+
name: ruby-${{ matrix.ruby }} rspec-${{ matrix.rspec }} simplecov-${{ matrix.simplecov }} parallel-tests-${{ matrix.parallel_tests }}
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
ruby: [ '2.5', '2.6', '2.7', '3.0', 'head' ]
21+
rspec: [ '3.6.0', '3.8.0', '3.10.0' ]
22+
simplecov: [ '0.14.0', '0.19.0', '0.21.0' ]
23+
parallel_tests: [ '2.10.0', '2.32.0', '3.0.0', '3.5.0', '3.7.0' ]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
29+
- name: Setup Ruby
30+
uses: ruby/setup-ruby@v1
31+
with:
32+
ruby-version: ${{ matrix.ruby }}
33+
34+
- name: Install Dependencies
35+
run: bundle install --jobs 3 --retry 3
36+
37+
- name: Run Features
38+
env:
39+
RSPEC_VERSION: "~> ${{ matrix.rspec }}"
40+
SIMPLECOV_VERSION: "~> ${{ matrix.simplecov }}"
41+
PARALLEL_TESTS_VERSION: "~> ${{ matrix.parallel_tests }}"
42+
run: |
43+
mkdir -p exit-codes
44+
if bundle exec cucumber --retry 3 --no-strict-flaky --tags "@ruby-app and @parallel-tests"; then
45+
echo 0 > exit-codes/ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt
46+
else
47+
echo 1 > exit-codes/ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt
48+
fi
49+
50+
- name: Save Exit Code
51+
uses: actions/upload-artifact@v2
52+
with:
53+
name: ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt
54+
path: exit-codes/ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt
55+
retention-days: 1
56+
57+
parallel-tests-success-rate:
58+
needs: [ 'main' ]
59+
name: parallel-tests-success-rate
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Download Exit Code Reports
64+
uses: actions/download-artifact@v2
65+
with:
66+
path: exit-codes-temp
67+
68+
- name: Finalize Artifacts
69+
run: |
70+
mkdir -p exit-codes
71+
find exit-codes-temp -mindepth 2 -type f -exec mv -i '{}' exit-codes ';'
72+
73+
- name: Install dc
74+
run: |
75+
sudo apt-get update
76+
sudo apt-get install dc -y
77+
78+
- name: Measure Success Rate
79+
run: |
80+
cat exit-codes/*.txt
81+
[[ `ls -1q exit-codes/*.txt | wc -l | sed 's/^ *//g'` == 225 ]] || exit 1
82+
[[ `cat exit-codes/*.txt | sed '2,$s/$/+/;$s/$/p/' | dc` < 6 ]] || exit 1

.github/workflows/rails-5-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Install Dependencies
3535
run: bundle install --jobs 3 --retry 3
3636

37-
- name: Run Features for Rails Project
37+
- name: Run Features
3838
env:
3939
RAILS_VERSION: "~> ${{ matrix.rails }}"
4040
RSPEC_RAILS_VERSION: "~> ${{ matrix.rspec-rails }}"

.github/workflows/rails-6-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Install Dependencies
3535
run: bundle install --jobs 3 --retry 3
3636

37-
- name: Run Features for Rails Project
37+
- name: Run Features
3838
env:
3939
RAILS_VERSION: "~> ${{ matrix.rails }}"
4040
RSPEC_RAILS_VERSION: "~> ${{ matrix.rspec-rails }}"

.github/workflows/ruby-project-part-1.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- name: Install Dependencies
3434
run: bundle install --jobs 3 --retry 3
3535

36-
- name: Run Features for Ruby Project
36+
- name: Run Features
3737
env:
3838
RSPEC_VERSION: "~> ${{ matrix.rspec }}"
3939
SIMPLECOV_VERSION: "~> ${{ matrix.simplecov }}"
40-
run: bundle exec cucumber --retry 3 --no-strict-flaky --tags @ruby-app
40+
run: bundle exec cucumber --retry 3 --no-strict-flaky --tags "@ruby-app and not @parallel-tests"

.github/workflows/ruby-project-part-2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
- name: Install Dependencies
3434
run: bundle install --jobs 3 --retry 3
3535

36-
- name: Run Features for Ruby Project
36+
- name: Run Features
3737
env:
3838
RSPEC_VERSION: "~> ${{ matrix.rspec }}"
3939
SIMPLECOV_VERSION: "~> ${{ matrix.simplecov }}"
4040
BRANCH_COVERAGE: true
41-
run: bundle exec cucumber --retry 3 --no-strict-flaky --tags @ruby-app
41+
run: bundle exec cucumber --retry 3 --no-strict-flaky --tags "@ruby-app and not @parallel-tests"

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Layout/MultilineMethodCallIndentation:
3636
Layout/MultilineOperationIndentation:
3737
EnforcedStyle: indented
3838

39+
Metrics/AbcSize:
40+
Max: 35
41+
3942
Metrics/BlockLength:
4043
Exclude:
4144
- "tasks/**/*"

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
55
group :development do
66
gem 'aruba', '~> 2.0'
77
gem 'cucumber', '~> 7.0'
8+
gem 'parallel_tests', '~> 3.7'
89
gem 'pry', '~> 0.14'
910
gem 'rake', '~> 13.0'
1011
gem 'rspec', '~> 3.10'

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ GEM
6262
mime-types-data (3.2021.0901)
6363
multi_test (0.1.2)
6464
parallel (1.20.1)
65+
parallel_tests (3.7.3)
66+
parallel
6567
parser (3.0.2.0)
6668
ast (~> 2.4.1)
6769
pry (0.14.1)
@@ -130,6 +132,7 @@ PLATFORMS
130132
DEPENDENCIES
131133
aruba (~> 2.0)
132134
cucumber (~> 7.0)
135+
parallel_tests (~> 3.7)
133136
pry (~> 0.14)
134137
rake (~> 13.0)
135138
rspec (~> 3.10)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"b5963ecab8d95c1024a46117fce4e907": {
3+
"example_group": "RSpec::ExampleGroups::Course::Enrolled::WithoutStudent",
4+
"description": "does not enroll",
5+
"full_description": "Course enrolled without student does not enroll",
6+
"file_name": "/spec/course_spec.rb",
7+
"line_number": 11,
8+
"rerun_file_name": "/spec/course_spec.rb",
9+
"rerun_line_number": 11,
10+
"example_id": "b5963ecab8d95c1024a46117fce4e907"
11+
},
12+
"e295e625ca1afa091751bcc3d43e373c": {
13+
"example_group": "RSpec::ExampleGroups::Course::Enrolled::WithStudent",
14+
"description": "enrolls student",
15+
"full_description": "Course enrolled with student enrolls student",
16+
"file_name": "/spec/course_spec.rb",
17+
"line_number": 25,
18+
"rerun_file_name": "/spec/course_spec.rb",
19+
"rerun_line_number": 25,
20+
"example_id": "e295e625ca1afa091751bcc3d43e373c"
21+
}
22+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"app/course.rb": [
3+
null,
4+
null,
5+
1,
6+
null,
7+
1,
8+
1,
9+
null,
10+
1,
11+
2,
12+
2,
13+
2,
14+
null,
15+
null,
16+
1,
17+
1,
18+
null,
19+
1,
20+
null,
21+
null,
22+
1,
23+
2,
24+
null,
25+
null,
26+
1,
27+
0,
28+
null,
29+
null
30+
],
31+
"app/student.rb": [
32+
null,
33+
null,
34+
1,
35+
null,
36+
1,
37+
1,
38+
null,
39+
1,
40+
1,
41+
1,
42+
1,
43+
null,
44+
null,
45+
1,
46+
1,
47+
null,
48+
null,
49+
1,
50+
1,
51+
null,
52+
null,
53+
1,
54+
0,
55+
null,
56+
null,
57+
1,
58+
0,
59+
null,
60+
0,
61+
0,
62+
null,
63+
null,
64+
1,
65+
0,
66+
null,
67+
null
68+
],
69+
"app/foo.rb": [
70+
null,
71+
null,
72+
0,
73+
0,
74+
null,
75+
0,
76+
0,
77+
null,
78+
null,
79+
0,
80+
0,
81+
null,
82+
null,
83+
0,
84+
0,
85+
null,
86+
null
87+
]
88+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"b5963ecab8d95c1024a46117fce4e907": [
3+
"/spec/course_spec.rb",
4+
"/app/course.rb",
5+
"/spec/spec_helper.rb"
6+
],
7+
"e295e625ca1afa091751bcc3d43e373c": [
8+
"/spec/course_spec.rb",
9+
"/app/course.rb",
10+
"/app/student.rb",
11+
"/spec/spec_helper.rb"
12+
]
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"/app/course.rb": {
3+
"example_count": 2,
4+
"examples": {
5+
"/spec/course_spec.rb": 2
6+
}
7+
},
8+
"/spec/course_spec.rb": {
9+
"example_count": 2,
10+
"examples": {
11+
"/spec/course_spec.rb": 2
12+
}
13+
},
14+
"/spec/spec_helper.rb": {
15+
"example_count": 2,
16+
"examples": {
17+
"/spec/course_spec.rb": 2
18+
}
19+
},
20+
"/app/student.rb": {
21+
"example_count": 1,
22+
"examples": {
23+
"/spec/course_spec.rb": 1
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)