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)

0 commit comments

Comments
 (0)