Skip to content

Minor bugfix

Minor bugfix #63

# Workflow to build nii2dcm, run unit tests and then execute command line interface (CLI) end-to-end
name: Build & Test nii2dcm
on:
pull_request:
jobs:
venv-build-and-test:
name: venv + E2E
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.9' ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python packages
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install flake8 pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Display installed pip packages
run: |
pip list
- name: Setup flake8 annotations
uses: rbialon/flake8-annotations@v1
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build nii2dcm
run: |
pip install .
- name: Test nii2dcm install
run: |
nii2dcm -h
nii2dcm -v
- name: Run unit tests
run: |
pytest tests/
- name: Test DicomMRISVR creation
run: |
# run nii2dcm
mkdir output
nii2dcm tests/data/DicomMRISVR/t2-svr-atlas-35wk.nii.gz ./output -d SVR
ls ./output
# assert DICOM files exist
[ -f "./output/IM_0001.dcm" ] && echo "Output DICOM file exists" || exit 1
- name: Build pytest coverage file
run: |
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=nii2dcm tests/ | tee pytest-coverage.txt ; echo $?
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
- name: Update Coverage Badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.PYTEST_COVERAGE_COMMENT }}
gistID: 57ef8057d04f67dbe6e64df410b83079
filename: nii2dcm-pytest-coverage-comment.json
label: Coverage Report
message: ${{ steps.coverageComment.outputs.coverage }}
color: ${{ steps.coverageComment.outputs.color }}
namedLogo: python
container-build-and-test:
name: Container
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.9' ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build container
run: |
docker build -t nii2dcm --progress=plain --no-cache .
docker ps
- name: Test nii2dcm container
run: |
docker run nii2dcm -h
echo "nii2dcm version:"
docker run nii2dcm -v