Skip to content

Commit 97821f5

Browse files
committed
Try splitting tests into separate groups by the top-level
context/describe. This is done by doing `rspec -fd --dry-run` and selecting only top-level descriptions Hopefully this will make testing faster/easier to debug when there are flakey tests.
1 parent d68675e commit 97821f5

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/ruby.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,29 @@ on:
66
branches: [main]
77

88
jobs:
9+
split:
10+
runs-on: ubuntu-24.04
11+
outputs:
12+
rspec_groups: ${{ steps.groups.outputs.rspec_groups }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: ruby/setup-ruby@v1
16+
with:
17+
ruby-version: '3.4'
18+
bundler-cache: true
19+
- id: groups
20+
run: |
21+
printf "rspec_groups<<JSON\n" >> $GITHUB_OUTPUT
22+
bundle exec rspec -fd --dry-run | sed -ne '/^Finished in /q; /^\S/p' | jq -R | jq -s >> $GITHUB_OUTPUT
23+
printf "JSON\n" >> $GITHUB_OUTPUT
24+
925
test:
1026
runs-on: ubuntu-22.04
27+
needs: [ split ]
1128
strategy:
1229
matrix:
1330
ruby-version: ['2.7', '3.0', '3.1', '3.4']
31+
rspec-group: ${{ fromJSON(needs.split.outputs.rspec_groups) }}
1432
steps:
1533
- run: |
1634
sudo apt-get update
@@ -21,10 +39,7 @@ jobs:
2139
ruby-version: ${{ matrix.ruby-version }}
2240
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
2341
- run: |
24-
if [ ! -z "$RUNNER_DEBUG" ] ; then
25-
DEBUG=1 bundle exec rspec -fd
26-
else
27-
bundle exec rspec
28-
fi
42+
[ ! -z "$RUNNER_DEBUG" ] && export DEBUG=1
43+
bundle exec rspec -fd -e "${{ matrix.rspec-group }}"
2944
env:
3045
SHELL: /usr/bin/bash

0 commit comments

Comments
 (0)