Skip to content

Commit a4e6a7a

Browse files
authored
Test workflow improvements
- Better triggers - Common hashseed generation for test matrix
1 parent c8d9c1a commit a4e6a7a

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

.github/workflows/tests.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ name: Run tests
22

33
# Controls when the workflow will run
44
on:
5-
# Triggers the workflow on push or pull request events but only for the master branch
5+
# Triggers the workflow on push or pull request events but only for important files
66
push:
7+
branches:
8+
- master
9+
paths:
10+
- "dpath/"
11+
- "**.py"
12+
- "tox.ini"
13+
pull_request:
714
paths:
815
- "dpath/"
916
- "**.py"
@@ -14,11 +21,29 @@ on:
1421

1522
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1623
jobs:
17-
# This workflow contains a single job called "tests"
24+
# Generate a common hashseed for all tests
25+
generate-hashseed:
26+
runs-on: ubuntu-latest
27+
28+
outputs:
29+
hashseed: ${{ steps.generate.outputs.hashseed }}
30+
31+
steps:
32+
- name: Generate Hashseed
33+
id: generate
34+
run: |
35+
python -c "from random import randint;
36+
hashseed = randint(0, 4294967295)
37+
print(f'{hashseed=}')
38+
print(f'::set-output name=hashseed::{hashseed}')"
39+
40+
# Tests job
1841
tests:
1942
# The type of runner that the job will run on
2043
runs-on: ubuntu-latest
2144

45+
needs: generate-hashseed
46+
2247
strategy:
2348
matrix:
2449
# Match versions specified in tox.ini
@@ -38,4 +63,4 @@ jobs:
3863
- name: Run tox with tox-gh-actions
3964
uses: ymyzk/run-tox-gh-actions@main
4065
with:
41-
tox-args: -vv
66+
tox-args: -vv --hashseed=${{ needs.generate-hashseed.outputs.hashseed }}

0 commit comments

Comments
 (0)