Skip to content

Commit 7eaf2bc

Browse files
committed
Add parallel testing demo
1 parent 388d991 commit 7eaf2bc

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

.github/workflows/parallel_dir.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Collect
1212
runs-on: ubuntu-latest
1313
outputs:
14-
TEST_DIRS: "${{ steps.generate.outputs.TEST_DIRS }}"
14+
directories: "${{ steps.build.outputs.TEST_DIRS }}"
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -33,8 +33,8 @@ jobs:
3333
sed -e '$d' collected.tmp | sed -e '$d' | tee collected.txt
3434
echo '::endgroup::'
3535
36-
- name: Generate matrix
37-
id: generate
36+
- name: Build test matrix
37+
id: build
3838
shell: uv run -- python {0}
3939
run: |
4040
from os import environ
@@ -55,7 +55,8 @@ jobs:
5555
needs: collect
5656

5757
strategy:
58-
matrix: ${{ fromJSON(needs.collect.outputs.TEST_DIRS) }}
58+
matrix:
59+
directory: ${{ fromJSON(needs.collect.outputs.directories) }}
5960

6061
steps:
6162
- uses: actions/checkout@v4
@@ -78,4 +79,4 @@ jobs:
7879
echo '::notice ::Enabled pytest norecursedirs.'
7980
8081
- name: Run test
81-
run: uv run -- pytest '${{ matrix.test_dirs }}'
82+
run: uv run -- pytest '${{ matrix.directory }}'

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ See the [workflow](.github/workflows/log_annotation.yml).
165165

166166
<summary>Define a matrix of different job configurations.</summary>
167167

168-
<br/>The matrix strategy lets easily target multiple operating systems or test multiple versions of a language.
168+
<br/>The matrix strategy helps you easily target multiple operating systems and language versions.
169169

170170
- Uses `actions/setup-node`
171171

@@ -187,6 +187,20 @@ See the [workflow](.github/workflows/mise.yml).
187187

188188
</details>
189189

190+
## parallel_*.yml
191+
192+
<details>
193+
194+
<summary>Parallel testing without any code changes or extra dependencies.</summary>
195+
196+
<br/>The matrix strategy can be used in a particular way to enable parallel testing for free. This means no code changes and no extra dependencies. This isn't a single runner using multiple cores, it's multiple runners each running its own set of tests.
197+
198+
See the workflows:
199+
- [Directory-level parallel testing](.github/workflows/parallel_dir.yml)
200+
- [File-level parallel testing](.github/workflows/parallel_file.yml)
201+
202+
</details>
203+
190204
## References
191205

192206
- [GitHub Actions](https://docs.github.com/en/actions)

0 commit comments

Comments
 (0)