Skip to content

Adds Docker build and GHA test of container #49

Adds Docker build and GHA test of container

Adds Docker build and GHA test of container #49

# Workflow to build nii2dcm and test different command line interface (CLI) options
name: Build nii2dcm
on:
pull_request:
jobs:
venv-build-and-test:
name: venv build
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: 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
container-build-and-test:
name: container build
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