Skip to content

Commit 58d7081

Browse files
authored
FIX: install additional packages in pytest (#109)
1 parent b4770a4 commit 58d7081

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

.github/workflows/pytest.yml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,51 @@ jobs:
6868
**/uv.lock
6969
enable-cache: true
7070
- uses: ComPWA/actions/cache-sympy@v2
71-
- name: Determine extras to install
71+
- id: extra
72+
if: inputs.additional-extras
73+
name: Determine extras to install
7274
run: |
73-
test_extras='--extra test'
74-
for extra in ${{ inputs.specific-pip-packages }}; do
75+
test_extras=''
76+
for extra in ${{ inputs.additional-extras }}; do
7577
test_extras="$test_extras --extra $extra"
7678
done
77-
echo "TEST_EXTRAS=$test_extras" | tee -a $GITHUB_ENV
78-
- name: Determine pytest flags
79+
echo "extras=$test_extras" | tee -a $GITHUB_OUTPUT
80+
- id: with
81+
if: inputs.specific-pip-packages
82+
name: Determine additional packages to install
7983
run: |
80-
pytest_flags='-m "not slow or slow"'
81-
if [[ ! -z '${{ inputs.coverage-target }}' ]]; then
82-
pytest_flags="$pytest_flags --cov-report=xml --cov=${{ matrix.coverage-target }}"
83-
fi
84-
if [[ ! -z '${{ inputs.multithreaded }}' ]]; then
85-
pytest_flags="$pytest_flags --numprocesses=auto"
86-
fi
87-
echo "PYTEST_FLAGS=$pytest_flags" | tee -a $GITHUB_ENV
84+
additional_packages=''
85+
for package in ${{ inputs.specific-pip-packages }}; do
86+
additional_packages="$additional_packages --with $package"
87+
done
88+
echo "packages=$additional_packages" | tee -a $GITHUB_OUTPUT
89+
- id: coverage
90+
if: matrix.coverage-target
91+
name: Determine pytest coverage flags
92+
run: echo "flags=--cov-report=xml --cov=${{ matrix.coverage-target }}" | tee -a $GITHUB_OUTPUT
93+
- id: multithreaded
94+
if: inputs.multithreaded
95+
name: Determine pytest multithreading flags
96+
run: echo "flags=--numprocesses=auto" | tee -a $GITHUB_OUTPUT
8897
- env:
8998
UV_SYSTEM_PYTHON: 1
90-
run: uv run ${{ env.TEST_EXTRAS }} pytest ${{ env.PYTEST_FLAGS }}
91-
- if: matrix.coverage-target != ''
99+
name: Run tests with pytest
100+
run: >-
101+
uv run \
102+
--extra test \
103+
${{ steps.extra.outputs.extras }} \
104+
${{ steps.with.outputs.packages }} \
105+
pytest \
106+
${{ steps.coverage.outputs.flags }} \
107+
${{ steps.multithreaded.outputs.flags }} \
108+
-m "not slow or slow"
109+
- if: matrix.coverage-target
92110
uses: codecov/codecov-action@v4
93111
with:
94112
file: ./coverage.xml
95113
flags: unittests
96-
97114
- uses: actions/upload-artifact@v4
98-
if: inputs.test-output-path != ''
115+
if: inputs.test-output-path
99116
with:
100117
name: test-output-${{ matrix.runs-on }}-${{ matrix.python-version }}
101118
path: ${{ inputs.test-output-path }}

0 commit comments

Comments
 (0)