66 pull_request :
77 paths :
88 - " python/**"
9+ workflow_dispatch :
910
10- defaults :
11- run :
12- working-directory : ./python
11+ concurrency :
12+ group : test-python-${{ github.head_ref }}
13+ cancel-in-progress : true
1314
1415jobs :
15- ci :
16- name : CI Python
17- runs-on : oss-4-core-runner
16+ changes :
17+ name : Filter Changes
18+ runs-on : ubuntu-latest
19+ outputs :
20+ diff : ${{ steps.filter.outputs.diff }}
21+ diff_files : ${{ steps.filter.outputs.diff_files }}
1822 steps :
1923 - uses : actions/checkout@v4
2024 - uses : dorny/paths-filter@v3
2125 id : filter
2226 with :
23- working-directory : python
2427 list-files : json
2528 filters : |
2629 diff:
27- - "python/**/*.py"
28- - "python/**/*.toml"
29- - run : >-
30- echo "packages=$(echo '${{ steps.filter.outputs.diff_files }}'
30+ - "python/instrumentation/**/*.py"
31+ - "python/instrumentation/**/*.toml"
32+ - "python/openinference-*/**/*.py"
33+ - "python/openinference-*/**/*.toml"
34+
35+ find-tox-testenv :
36+ name : Find Tox Testenv
37+ needs : changes
38+ if : ${{ needs.changes.outputs.diff == 'true' }}
39+ runs-on : ubuntu-latest
40+ outputs :
41+ list : ${{ steps.testenv.outputs.list }}
42+ steps :
43+ - name : Convert JSON list to regex
44+ run : >-
45+ echo "list=$(echo '${{ needs.changes.outputs.diff_files }}'
3146 | jq -r '.[]'
3247 | sed -n
3348 -e 's/^python\/instrumentation\/openinference-instrumentation-\([^/]*\)\/.*/\1/p'
@@ -37,20 +52,42 @@ jobs:
3752 | sed -e 's/semantic-conventions/semconv/' -e 's/-/_/' -e 's/^/\\b/'
3853 | paste -sd "|" -)"
3954 >> "$GITHUB_OUTPUT"
40- if: ${{ steps.filter.outputs.diff == 'true' }}
41- id: changes
42- - uses : actions/setup-python@v5
43- if : ${{ (steps.filter.outputs.diff == 'true') && (steps.changes.outputs.packages != '') }}
55+ id : packages
56+ - uses : actions/checkout@v4
57+ with :
58+ sparse-checkout : python
59+ - uses : astral-sh/setup-uv@v5
60+ with :
61+ version : 0.5.27
62+ enable-cache : false
63+ - name : Extract testenv into JSON list
64+ run : >-
65+ echo "list=$(uvx --with tox-uv tox -l
66+ | egrep -e '${{ steps.packages.outputs.list }}'
67+ | jq -R -s -c 'split("\n")[:-1]')"
68+ >> $GITHUB_OUTPUT
69+ working-directory : python
70+ id : testenv
71+ - name : Fail if no testenv is found
72+ if : ${{ steps.testenv.outputs.list == '[]' }}
73+ run : exit 1
74+
75+ run-tox-testenv :
76+ name : ${{ matrix.testenv }}
77+ needs : find-tox-testenv
78+ if : ${{ needs.find-tox-testenv.outputs.list != '[]' }}
79+ runs-on : ubuntu-latest
80+ strategy :
81+ fail-fast : false
82+ matrix :
83+ testenv : ${{ fromJSON(needs.find-tox-testenv.outputs.list) }}
84+ steps :
85+ - uses : actions/checkout@v4
86+ with :
87+ sparse-checkout : python
88+ - uses : astral-sh/setup-uv@v5
4489 with :
45- python-version : |
46- 3.8
47- 3.9
48- 3.10
49- 3.11
50- 3.12
51- - run : pip install tox-uv==1.11.2
52- if : ${{ (steps.filter.outputs.diff == 'true') && (steps.changes.outputs.packages != '') }}
53- - run : >-
54- tox run-parallel --parallel-no-spinner
55- -e $(tox -l | egrep -e '${{ steps.changes.outputs.packages }}' | paste -sd, -)
56- if: ${{ (steps.filter.outputs.diff == 'true') && (steps.changes.outputs.packages != '') }}
90+ version : 0.5.27
91+ enable-cache : false
92+ - run : uvx --with tox-uv tox run -e ${{ matrix.testenv }} -- -ra -x
93+ working-directory : python
0 commit comments