1- name : premerge-min
1+ name : tests
22
33on :
44 # quick tests for pull requests and the releasing branches
@@ -17,6 +17,39 @@ concurrency:
1717 cancel-in-progress : true
1818
1919jobs :
20+ static-checks :
21+ runs-on : ubuntu-latest
22+ strategy :
23+ matrix :
24+ opt : ["codeformat", "pytype", "mypy"]
25+ steps :
26+ - uses : actions/checkout@v4
27+ - name : Set up Python 3.9
28+ uses : actions/setup-python@v5
29+ with :
30+ python-version : ' 3.9'
31+ - name : cache weekly timestamp
32+ id : pip-cache
33+ run : |
34+ echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
35+ - name : cache for pip
36+ uses : actions/cache@v4
37+ id : cache
38+ with :
39+ path : ~/.cache/pip
40+ key : ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
41+ - name : Install dependencies
42+ run : |
43+ find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
44+ python -m pip install --upgrade pip wheel
45+ python -m pip install -r requirements-dev.txt
46+ - name : Lint and type check
47+ run : |
48+ # clean up temporary files
49+ $(pwd)/runtests.sh --build --clean
50+ # Github actions have 2 cores, so parallelize pytype
51+ $(pwd)/runtests.sh --build --${{ matrix.opt }} -j 2
52+
2053 min-dep : # min dependencies installed tests for different OS
2154 runs-on : ${{ matrix.os }}
2255 strategy :
@@ -91,151 +124,191 @@ jobs:
91124 NGC_ORG : ${{ secrets.NGC_ORG }}
92125 NGC_TEAM : ${{ secrets.NGC_TEAM }}
93126
94- # # caching of these jobs:
95- # # - docker-py3-pip- (shared)
96- # # - ubuntu py37 pip-
97- # # - os-latest-pip- (shared)
98- # min-dep-os: # min dependencies installed tests for different OS
99- # runs-on: ${{ matrix.os }}
100- # strategy:
101- # fail-fast: false
102- # matrix:
103- # os: [windows-latest, macOS-latest, ubuntu-latest]
104- # timeout-minutes: 40
105- # steps:
106- # - uses: actions/checkout@v4
107- # - name: Set up Python 3.9
108- # uses: actions/setup-python@v5
109- # with:
110- # python-version: '3.9'
111- # - name: Prepare pip wheel
112- # run: |
113- # which python
114- # python -m pip install --upgrade pip wheel
115- # - name: cache weekly timestamp
116- # id: pip-cache
117- # run: |
118- # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
119- # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
120- # shell: bash
121- # - name: cache for pip
122- # uses: actions/cache@v4
123- # id: cache
124- # with:
125- # path: ${{ steps.pip-cache.outputs.dir }}
126- # key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }}
127- # - name: Install the dependencies
128- # run: |
129- # # min. requirements
130- # python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
131- # python -m pip install -r requirements-min.txt
132- # python -m pip list
133- # BUILD_MONAI=0 python setup.py develop # no compile of extensions
134- # shell: bash
135- # - name: Run quick tests (CPU ${{ runner.os }})
136- # run: |
137- # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
138- # python -c "import monai; monai.config.print_config()"
139- # ./runtests.sh --min
140- # shell: bash
141- # env:
142- # QUICKTEST: True
143- # NGC_API_KEY: ${{ secrets.NGC_API_KEY }}
144- # NGC_ORG: ${{ secrets.NGC_ORG }}
145- # NGC_TEAM: ${{ secrets.NGC_TEAM }}
127+ full-dep : # full dependencies installed tests for different OS
128+ runs-on : ${{ matrix.os }}
129+ strategy :
130+ fail-fast : false
131+ matrix :
132+ os : [windows-latest, macOS-latest, ubuntu-latest]
133+ timeout-minutes : 120
134+ steps :
135+ - if : runner.os == 'windows'
136+ name : Config pagefile (Windows only)
137+ uses : al-cheb/configure-pagefile-action@v1.4
138+ with :
139+ minimum-size : 8GB
140+ maximum-size : 16GB
141+ disk-root : " D:"
142+ - uses : actions/checkout@v4
143+ - name : Set up Python 3.9
144+ uses : actions/setup-python@v5
145+ with :
146+ python-version : ' 3.9'
147+ - name : Prepare pip wheel
148+ run : |
149+ which python
150+ python -m pip install --upgrade pip wheel
151+ - name : cache weekly timestamp
152+ id : pip-cache
153+ run : |
154+ echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
155+ echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
156+ shell : bash
157+ - name : cache for pip
158+ uses : actions/cache@v4
159+ id : cache
160+ with :
161+ path : ${{ steps.pip-cache.outputs.dir }}
162+ key : ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }}
163+ - if : runner.os == 'windows'
164+ name : Install torch cpu from pytorch.org (Windows only)
165+ run : |
166+ python -m pip install torch==2.5.1 torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu
167+ - if : runner.os == 'Linux'
168+ name : Install itk pre-release (Linux only)
169+ run : |
170+ python -m pip install --pre -U itk
171+ find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
172+ - name : Install the dependencies
173+ run : |
174+ python -m pip install --user --upgrade pip wheel
175+ python -m pip install torch==2.5.1 torchvision==0.20.1
176+ cat "requirements-dev.txt"
177+ python -m pip install -r requirements-dev.txt
178+ python -m pip list
179+ python setup.py develop # test no compile installation
180+ shell : bash
181+ - name : Run compiled (${{ runner.os }})
182+ run : |
183+ python setup.py develop --uninstall
184+ BUILD_MONAI=1 python setup.py develop # compile the cpp extensions
185+ shell : bash
186+ - name : Run quick tests (CPU ${{ runner.os }})
187+ run : |
188+ python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
189+ python -c "import monai; monai.config.print_config()"
190+ # python -m unittest -v
191+ env :
192+ QUICKTEST : True
193+ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION : python # https://github.com/Project-MONAI/MONAI/issues/4354
194+
195+ packaging :
196+ runs-on : ubuntu-latest
197+ env :
198+ QUICKTEST : True
199+ shell : bash
200+ steps :
201+ - uses : actions/checkout@v4
202+ with :
203+ fetch-depth : 0
204+ - name : Set up Python 3.9
205+ uses : actions/setup-python@v5
206+ with :
207+ python-version : ' 3.9'
208+ - name : cache weekly timestamp
209+ id : pip-cache
210+ run : |
211+ echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
212+ - name : cache for pip
213+ uses : actions/cache@v4
214+ id : cache
215+ with :
216+ path : |
217+ ~/.cache/pip
218+ ~/.cache/torch
219+ key : ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
220+ - name : Install dependencies
221+ run : |
222+ find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
223+ python -m pip install --user --upgrade pip setuptools wheel twine packaging
224+ # install the latest pytorch for testing
225+ # however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
226+ # fresh torch installation according to pyproject.toml
227+ python -m pip install torch>=2.5.1 torchvision
228+ - name : Check packages
229+ run : |
230+ pip uninstall monai
231+ pip list | grep -iv monai
232+ git fetch --depth=1 origin +refs/tags/*:refs/tags/*
233+ set -e
146234
147- # min-dep-py3: # min dependencies installed tests for different python
148- # runs-on: ubuntu-latest
149- # strategy:
150- # fail-fast: false
151- # matrix:
152- # python-version: ['3.9', '3.10', '3.11', '3.12']
153- # timeout-minutes: 40
154- # steps:
155- # - uses: actions/checkout@v4
156- # - name: Set up Python ${{ matrix.python-version }}
157- # uses: actions/setup-python@v5
158- # with:
159- # python-version: ${{ matrix.python-version }}
160- # - name: Prepare pip wheel
161- # run: |
162- # which python
163- # python -m pip install --user --upgrade pip setuptools wheel
164- # - name: cache weekly timestamp
165- # id: pip-cache
166- # run: |
167- # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
168- # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
169- # shell: bash
170- # - name: cache for pip
171- # uses: actions/cache@v4
172- # id: cache
173- # with:
174- # path: ${{ steps.pip-cache.outputs.dir }}
175- # key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }}
176- # - name: Install the dependencies
177- # run: |
178- # # min. requirements
179- # python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
180- # python -m pip install -r requirements-min.txt
181- # python -m pip list
182- # BUILD_MONAI=0 python setup.py develop # no compile of extensions
183- # shell: bash
184- # - name: Run quick tests (CPU ${{ runner.os }})
185- # run: |
186- # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
187- # python -c "import monai; monai.config.print_config()"
188- # ./runtests.sh --min
189- # env:
190- # QUICKTEST: True
191- # NGC_API_KEY: ${{ secrets.NGC_API_KEY }}
192- # NGC_ORG: ${{ secrets.NGC_ORG }}
193- # NGC_TEAM: ${{ secrets.NGC_TEAM }}
235+ # build tar.gz and wheel
236+ python setup.py check -m -s
237+ python setup.py sdist bdist_wheel
238+ python -m twine check dist/*
239+ - run : echo "pwd=$PWD" >> $GITHUB_OUTPUT
240+ id : root
241+ - run : echo "tmp_dir=$(mktemp -d)" >> $GITHUB_OUTPUT
242+ id : mktemp
243+ - name : Move packages
244+ run : |
245+ printf ${{ steps.root.outputs.pwd }}
246+ printf ${{ steps.mktemp.outputs.tmp_dir }}
247+ # move packages to a temp dir
248+ cp dist/monai* "${{ steps.mktemp.outputs.tmp_dir }}"
249+ rm -r build dist monai.egg-info
250+ cd "${{ steps.mktemp.outputs.tmp_dir }}"
251+ ls -al
252+ - name : Install wheel file
253+ working-directory : ${{ steps.mktemp.outputs.tmp_dir }}
254+ run : |
255+ # install from wheel
256+ python -m pip install monai*.whl
257+ python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
258+ python -c 'import monai; print(monai.__file__)'
259+ python -m pip uninstall -y monai
260+ rm monai*.whl
261+ - name : Install source archive
262+ working-directory : ${{ steps.mktemp.outputs.tmp_dir }}
263+ run : |
264+ # install from tar.gz
265+ name=$(ls *.tar.gz | head -n1)
266+ echo $name
267+ python -m pip install $name[all]
268+ python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
269+ python -c 'import monai; print(monai.__file__)'
270+ - name : Quick test
271+ working-directory : ${{ steps.mktemp.outputs.tmp_dir }}
272+ run : |
273+ # run min tests
274+ cp ${{ steps.root.outputs.pwd }}/requirements*.txt .
275+ cp -r ${{ steps.root.outputs.pwd }}/tests .
276+ ls -al
277+ python -m pip install -r requirements-dev.txt
278+ python -m unittest -v
279+ env :
280+ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION : python # https://github.com/Project-MONAI/MONAI/issues/4354
194281
195- # min-dep-pytorch: # min dependencies installed tests for different pytorch
196- # runs-on: ubuntu-latest
197- # strategy:
198- # fail-fast: false
199- # matrix:
200- # pytorch-version: ['2.5.1', '2.6.0', '2.7.1', '2.8.0']
201- # timeout-minutes: 40
202- # steps:
203- # - uses: actions/checkout@v4
204- # - name: Set up Python 3.9
205- # uses: actions/setup-python@v5
206- # with:
207- # python-version: '3.9'
208- # - name: Prepare pip wheel
209- # run: |
210- # which python
211- # python -m pip install --user --upgrade pip setuptools wheel
212- # - name: cache weekly timestamp
213- # id: pip-cache
214- # run: |
215- # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
216- # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
217- # shell: bash
218- # - name: cache for pip
219- # uses: actions/cache@v4
220- # id: cache
221- # with:
222- # path: ${{ steps.pip-cache.outputs.dir }}
223- # key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }}
224- # - name: Install the dependencies
225- # run: |
226- # # min. requirements
227- # python -m pip install torch==${{ matrix.pytorch-version }}
228- # python -m pip install -r requirements-min.txt
229- # python -m pip list
230- # BUILD_MONAI=0 python setup.py develop # no compile of extensions
231- # shell: bash
232- # - name: Run quick tests (pytorch ${{ matrix.pytorch-version }})
233- # run: |
234- # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
235- # python -c "import monai; monai.config.print_config()"
236- # ./runtests.sh --min
237- # env:
238- # QUICKTEST: True
239- # NGC_API_KEY: ${{ secrets.NGC_API_KEY }}
240- # NGC_ORG: ${{ secrets.NGC_ORG }}
241- # NGC_TEAM: ${{ secrets.NGC_TEAM }}
282+ build-docs :
283+ runs-on : ubuntu-latest
284+ steps :
285+ - uses : actions/checkout@v4
286+ - name : Set up Python 3.9
287+ uses : actions/setup-python@v5
288+ with :
289+ python-version : ' 3.9'
290+ - name : cache weekly timestamp
291+ id : pip-cache
292+ run : |
293+ echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
294+ - name : cache for pip
295+ uses : actions/cache@v4
296+ id : cache
297+ with :
298+ path : |
299+ ~/.cache/pip
300+ ~/.cache/torch
301+ key : ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
302+ - name : Install dependencies
303+ run : |
304+ python -m pip install --upgrade pip wheel
305+ python -m pip install -r docs/requirements.txt
306+ - name : Make html
307+ run : |
308+ cd docs/
309+ make clean
310+ make html 2>&1 | tee tmp_log
311+ if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "found errors"; grep "ERROR:" tmp_log; exit 1; fi
312+ sed '/WARNING.*pip/d' tmp_log > tmp_log1; mv tmp_log1 tmp_log # monai#7133
313+ if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; grep "WARNING:" tmp_log; exit 1; fi
314+ shell : bash
0 commit comments