Skip to content

Workflow file for this run

name: Tests
on:
- push
- pull_request
jobs:
pytest:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0} # setup-miniconda requires bash
steps:
- uses: actions/checkout@v4
- run: |
pip3 install toml
echo "python_version=$(python3 scripts/get_python_version.py)" >> "$GITHUB_OUTPUT"
pip3 install --user uv
id: get-python-version
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: test
python-version: ${{ steps.get-python-version.outputs.python_version }}
- name: Cache Conda environment
id: cache-conda
uses: actions/cache@v4
env:
cache-name: cache-conda
with:
path: ~/miniconda3/envs/test
key: ${{ runner.os }}-conda-${{ env.cache-name }}-${{ hashFiles('deps/x86_64-unknown-linux-gnu/requirements_dev.txt') }}
# restore-keys: |
# ${{ runner.os }}-conda-${{ env.cache-name }}-
# ${{ runner.os }}-conda-
# ${{ runner.os }}-
- if: steps.cache-conda.outputs.cache-hit == 'true'
run: echo 'conda cache hit!'
- name: Install dependencies
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
# python -m pip install --upgrade pip
uv pip install -r deps/x86_64-unknown-linux-gnu/requirements_dev.txt
uv pip install -e .
bash scripts/install_binaries.sh
- name: Run pytest
run: |
set +e # Do not exit shell on pytest failure
out=$(pytest 2> stderr.txt)
exit_code=$?
err=$(<stderr.txt)
# Display the raw output in the step
echo "${out}"
echo "${err}"
# Display the Markdown output in the job summary
echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY
echo "${out}" >> $GITHUB_STEP_SUMMARY
echo "${err}" >> $GITHUB_STEP_SUMMARY
if [[ $exit_code -eq 5 ]]
then
echo
echo 'WARNING: No tests were run and it is considered as success' >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
exit 0
else
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# Exit with the exit-code returned by pytest
exit ${exit_code}
fi
doctest:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0} # setup-miniconda requires bash
steps:
- uses: actions/checkout@v4
- run: |
pip3 install toml
echo "python_version=$(python3 scripts/get_python_version.py)" >> "$GITHUB_OUTPUT"
pip3 install --user uv
id: get-python-version
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: test
python-version: ${{ steps.get-python-version.outputs.python_version }}
- name: Cache Conda environment
id: cache-conda
uses: actions/cache@v4
env:
cache-name: cache-conda
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/miniconda3/envs/test
key: ${{ runner.os }}-conda-${{ env.cache-name }}-${{ hashFiles('deps/x86_64-unknown-linux-gnu/requirements_dev.txt') }}
# restore-keys: |
# ${{ runner.os }}-conda-${{ env.cache-name }}-
# ${{ runner.os }}-conda-
# ${{ runner.os }}-
- if: steps.cache-conda.outputs.cache-hit == 'true'
run: echo 'conda cache hit!'
- name: Install dependencies
if: steps.cache-conda.outputs.cache-hit != 'true'
run: |
# python -m pip install --upgrade pip
uv pip install -r deps/x86_64-unknown-linux-gnu/requirements_dev.txt
uv pip install -e .
bash scripts/install_binaries.sh
- name: Run doctest
run: |
set +e # Do not exit shell on pytest failure
out=$(python scripts/run_doctest.py 2> stderr.txt)
exit_code=$?
err=$(<stderr.txt)
# Display the raw output in the step
echo "${out}"
echo "${err}"
# Display the Markdown output in the job summary
echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY
echo "${out}" >> $GITHUB_STEP_SUMMARY
echo "${err}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# Exit with the exit-code returned by pytest
exit ${exit_code}