-
Notifications
You must be signed in to change notification settings - Fork 14
120 lines (96 loc) · 3.18 KB
/
build_and_test_cli.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# 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/[email protected]
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