diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/cicd_tests.yml similarity index 66% rename from .github/workflows/pythonapp.yml rename to .github/workflows/cicd_tests.yml index c68c879231..b48b8468f4 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/cicd_tests.yml @@ -1,5 +1,4 @@ -# Jenkinsfile.monai-premerge -name: premerge +name: tests on: # quick tests for pull requests and the releasing branches @@ -14,15 +13,15 @@ on: concurrency: # automatically cancel the previously triggered workflows when there's a newer version - group: build-${{ github.event.pull_request.number || github.ref }} + group: cicd-tests-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +# These jobs run the CICD tests, type checking, and testing packaging and documentation generation. These use the +# minimum supported versions of Python and PyTorch in many places hard-coded as literals, so when support is dropped +# for a version it is important to go through all jobs and check the versions they use are correct. + jobs: - # caching of these jobs: - # - docker-py3-pip- (shared) - # - ubuntu py37 pip- - # - os-latest-pip- (shared) - flake8-py3: + static-checks: # Perform static type and other checks using runtests.sh runs-on: ubuntu-latest strategy: matrix: @@ -48,14 +47,94 @@ jobs: find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; python -m pip install --upgrade pip wheel python -m pip install -r requirements-dev.txt - - name: Lint and type check + - name: Lint and type check with "./runtests.sh --build --${{ matrix.opt }}" run: | # clean up temporary files $(pwd)/runtests.sh --build --clean - # Github actions have 2 cores, so parallelize pytype - $(pwd)/runtests.sh --build --${{ matrix.opt }} -j 2 + # Github actions have multiple cores, so parallelize pytype + $(pwd)/runtests.sh --build --${{ matrix.opt }} -j $(nproc --all) + + min-dep: # Test with minumum dependencies installed for different OS, Python, and PyTorch combinations + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, macOS-latest, ubuntu-latest, linux-gpu-runner] + python-version: ['3.9'] + pytorch-version: ['2.5.1'] + include: + # Test Python versions under Ubuntu with lowest PyTorch version supported + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.10' + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.11' + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.12' + + # Test PyTorch versions under Ubuntu with lowest Python version supported + - os: ubuntu-latest + python-version: '3.9' + pytorch-version: '2.6.0' + - os: ubuntu-latest + python-version: '3.9' + pytorch-version: '2.7.1' + - os: ubuntu-latest + python-version: '3.9' + pytorch-version: '2.8.0' + + timeout-minutes: 40 + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Prepare pip wheel + run: | + which python + python -m pip install --upgrade pip wheel + - name: cache weekly timestamp + id: pip-cache + run: | + echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + shell: bash + - name: cache for pip + uses: actions/cache@v4 + id: cache + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} + - name: Install the minimum dependencies + run: | + # min. requirements + python -m pip install torch==${{ matrix.pytorch-version }} + python -m pip install -r requirements-min.txt + python -m pip list + BUILD_MONAI=0 python setup.py develop # no compile of extensions + shell: bash + - if: matrix.os == 'linux-gpu-runner' + name: Print GPU Info + run: | + nvidia-smi + python -c 'import torch; print(torch.rand(2,2).to("cuda:0"))' + shell: bash + - name: Run quick tests + run: | + python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' + python -c "import monai; monai.config.print_config()" + # ./runtests.sh --min + shell: bash + env: + QUICKTEST: True + NGC_API_KEY: ${{ secrets.NGC_API_KEY }} + NGC_ORG: ${{ secrets.NGC_ORG }} + NGC_TEAM: ${{ secrets.NGC_TEAM }} - quick-py3: # full dependencies installed tests for different OS + full-dep: # Test with full dependencies installed for different OS runners runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -100,7 +179,7 @@ jobs: run: | python -m pip install --pre -U itk find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; - - name: Install the dependencies + - name: Install the complete dependencies run: | python -m pip install --user --upgrade pip wheel python -m pip install torch==2.5.1 torchvision==0.20.1 @@ -114,16 +193,16 @@ jobs: python setup.py develop --uninstall BUILD_MONAI=1 python setup.py develop # compile the cpp extensions shell: bash - - name: Run quick tests (CPU ${{ runner.os }}) + - name: Run quick tests run: | python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' python -c "import monai; monai.config.print_config()" - python -m unittest -v + # python -m unittest -v env: QUICKTEST: True PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 - packaging: + packaging: # Test package generation runs-on: ubuntu-latest env: QUICKTEST: True @@ -210,7 +289,7 @@ jobs: env: PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 - build-docs: + build-docs: # Test building documentation runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -239,7 +318,7 @@ jobs: cd docs/ make clean make html 2>&1 | tee tmp_log - if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "found errors"; grep "ERROR:" tmp_log; exit 1; fi + if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "Found errors:"; grep "ERROR:" tmp_log; exit 1; fi sed '/WARNING.*pip/d' tmp_log > tmp_log1; mv tmp_log1 tmp_log # monai#7133 - if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; grep "WARNING:" tmp_log; exit 1; fi + if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "Found warnings:"; grep "WARNING:" tmp_log; exit 1; fi shell: bash diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml deleted file mode 100644 index 0d147ca264..0000000000 --- a/.github/workflows/pythonapp-min.yml +++ /dev/null @@ -1,168 +0,0 @@ -# Jenkinsfile.monai-premerge -name: premerge-min - -on: - # quick tests for pull requests and the releasing branches - push: - branches: - - dev - - main - - releasing/* - pull_request: - head_ref-ignore: - - dev - -concurrency: - # automatically cancel the previously triggered workflows when there's a newer version - group: build-min-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - # caching of these jobs: - # - docker-py3-pip- (shared) - # - ubuntu py37 pip- - # - os-latest-pip- (shared) - min-dep-os: # min dependencies installed tests for different OS - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [windows-latest, macOS-latest, ubuntu-latest] - timeout-minutes: 40 - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Prepare pip wheel - run: | - which python - python -m pip install --upgrade pip wheel - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install the dependencies - run: | - # min. requirements - python -m pip install torch --index-url https://download.pytorch.org/whl/cpu - python -m pip install -r requirements-min.txt - python -m pip list - BUILD_MONAI=0 python setup.py develop # no compile of extensions - shell: bash - - name: Run quick tests (CPU ${{ runner.os }}) - run: | - python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - python -c "import monai; monai.config.print_config()" - ./runtests.sh --min - shell: bash - env: - QUICKTEST: True - NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - NGC_ORG: ${{ secrets.NGC_ORG }} - NGC_TEAM: ${{ secrets.NGC_TEAM }} - - min-dep-py3: # min dependencies installed tests for different python - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] - timeout-minutes: 40 - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Prepare pip wheel - run: | - which python - python -m pip install --user --upgrade pip setuptools wheel - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install the dependencies - run: | - # min. requirements - python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu - python -m pip install -r requirements-min.txt - python -m pip list - BUILD_MONAI=0 python setup.py develop # no compile of extensions - shell: bash - - name: Run quick tests (CPU ${{ runner.os }}) - run: | - python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - python -c "import monai; monai.config.print_config()" - ./runtests.sh --min - env: - QUICKTEST: True - NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - NGC_ORG: ${{ secrets.NGC_ORG }} - NGC_TEAM: ${{ secrets.NGC_TEAM }} - - min-dep-pytorch: # min dependencies installed tests for different pytorch - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - pytorch-version: ['2.5.1', '2.6.0', '2.7.1', '2.8.0'] - timeout-minutes: 40 - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Prepare pip wheel - run: | - which python - python -m pip install --user --upgrade pip setuptools wheel - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install the dependencies - run: | - # min. requirements - python -m pip install torch==${{ matrix.pytorch-version }} - python -m pip install -r requirements-min.txt - python -m pip list - BUILD_MONAI=0 python setup.py develop # no compile of extensions - shell: bash - - name: Run quick tests (pytorch ${{ matrix.pytorch-version }}) - run: | - python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - python -c "import monai; monai.config.print_config()" - ./runtests.sh --min - env: - QUICKTEST: True - NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - NGC_ORG: ${{ secrets.NGC_ORG }} - NGC_TEAM: ${{ secrets.NGC_TEAM }}