fix potential TimeoutError #344
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Run Test with PyTest and Codecov | |
on: | |
push: | |
branches: [ dev ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
# Don't run on forked repos. | |
if: github.repository_owner == 'DeepPSP' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Clear unnecessary system components | |
run: | | |
echo "Free space:" | |
df -h | |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android | |
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET | |
sudo rm -rf /opt/ghc | |
sudo rm -rf /usr/local/share/boost | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
- name: Install system libraries | |
run: | | |
sudo apt update | |
sudo apt install build-essential ffmpeg libsm6 libxext6 libsndfile1 -y | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.0' # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' # caching pip dependencies | |
- name: List existing Python packages | |
run: | | |
python -m pip list | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install -r requirements.txt | |
python -m pip install pytest pytest-xdist pytest-cov # Testing packages | |
python -m pip uninstall torch-ecg --yes # Remove if already installed | |
python setup.py install_egg_info # Workaround https://github.com/pypa/pip/issues/4537 | |
python -m pip install -e .[dev] | |
python -m pip freeze | |
- name: List installed Python packages | |
run: | | |
python -m pip list | |
- name: Install nsrr and download a samll part of SHHS to do test | |
# ref. https://github.com/DeepPSP/nsrr-automate | |
uses: gacts/run-and-post-run@v1 | |
with: | |
# if ~/tmp/nsrr-data/shhs is empty (no files downloaded), | |
# fail and terminate the workflow | |
run: | | |
gem install nsrr --no-document | |
nsrr download shhs/polysomnography/edfs/shhs1/ --file="^shhs1\-20010.*\.edf" --token=${{ secrets.NSRR_TOKEN }} | |
nsrr download shhs/polysomnography/annotations-events-nsrr/shhs1/ --file="^shhs1\-20010.*\-nsrr\.xml" --token=${{ secrets.NSRR_TOKEN }} | |
nsrr download shhs/polysomnography/annotations-events-profusion/shhs1/ --file="^shhs1\-20010.*\-profusion\.xml" --token=${{ secrets.NSRR_TOKEN }} | |
nsrr download shhs/polysomnography/annotations-rpoints/shhs1/ --file="^shhs1\-20010.*\-rpoint\.csv" --token=${{ secrets.NSRR_TOKEN }} | |
nsrr download shhs/datasets/ --shallow --token=${{ secrets.NSRR_TOKEN }} | |
nsrr download shhs/datasets/hrv-analysis/ --token=${{ secrets.NSRR_TOKEN }} | |
mkdir -p ~/tmp/nsrr-data/ | |
mv shhs/ ~/tmp/nsrr-data/ | |
du -sh ~/tmp/nsrr-data/* | |
if [ "$(find ~/tmp/nsrr-data/shhs -type f | wc -l)" -eq 0 ]; \ | |
then (echo "No files downloaded. Exiting..." && exit 1); \ | |
else echo "Found $(find ~/tmp/nsrr-data/shhs -type f | wc -l) files"; fi | |
post: | | |
touch ~/tmp/.keep | |
rm -rf ~/tmp/nsrr-data/ | |
du -sh ~/tmp/* | |
- name: Run test with pytest and collect coverage | |
run: | | |
pytest -vv -s \ | |
--cov=torch_ecg \ | |
--ignore=test/test_pipelines \ | |
test | |
- name: Upload coverage to Codecov | |
if: matrix.python-version == '3.8' | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true # optional (default = false) | |
verbose: true # optional (default = false) | |
token: ${{ secrets.CODECOV_TOKEN }} # required |