-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
135 lines (116 loc) · 4.5 KB
/
.gitlab-ci.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
stages:
- stylecheck
- test
- deploy
.conda_env: &conda_env
before_script:
# update conda
- conda config --set always_yes yes
- conda update -q conda
# create and activate environment
- conda create -q -n testenv_${CI_JOB_ID}_py${PYTHON_VERSION_TO_USE//./} python=${PYTHON_VERSION_TO_USE} pip
- source activate testenv_${CI_JOB_ID}_py${PYTHON_VERSION_TO_USE//./}
after_script:
# remove environment
- conda env remove --name testenv_${CI_JOB_ID}_py${PYTHON_VERSION_TO_USE//./}
.test_template: &test_template
<<: *conda_env
stage: test
rules:
- if: $CI_MERGE_REQUEST_TITLE =~ /^(Draft:|WIP:|\[Draft\]|\[WIP\])/
when: manual
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE !~ /^(Draft:|WIP:|\[Draft\]|\[WIP\])/
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "schedule"
script:
# install packages (use conda to avoid time-consuming installations)
- conda install -q pytest pytest-cov
- python -m pip install -q pytest-html
- python -m pip install pytest-xdist # multiple workers for pytest (-n 2 below)
# install dependencies
- |
if [ "${PYTHON_VERSION_TO_USE}" == "3.6" ]; then
conda install pytorch=1.10.1 torchvision=0.11.2 cpuonly -c pytorch
elif [ "${PYTHON_VERSION_TO_USE}" == "3.8" ]; then
# EMSANet
conda install pytorch=1.13.0 torchvision=0.14.0 cpuonly -c pytorch
else
conda install pytorch=2.0.1 torchvision=0.15.2 cpuonly -c pytorch
fi
- python -m pip install 'opencv-python>=4.2.0.34'
# install package (and all missing dependencies)
- python -m pip install -q --editable .[test]
# check conda installation
- conda info
- conda list
- python -m pip list
# test package (opt: get coverage)
- |
if [ "${REPORT_COVERAGE}" == "true" ]; then
py.test ./ -rx -s -vv -n 2 --maxfail=4 --ff --cov=${CI_PROJECT_NAME//-/_} --cov-report html --cov-report term --html=report_py${PYTHON_VERSION_TO_USE//./}.html --self-contained-html
else
py.test ./ -rx -s -vv -n 2 --maxfail=4 --ff --html=report_py${PYTHON_VERSION_TO_USE//./}.html --self-contained-html
fi
coverage: '/^TOTAL.*\s+(\d+\%)$/'
artifacts:
when: always
paths:
- report_py${PYTHON_VERSION_TO_USE//./}.html
- htmlcov
style_check:
<<: *conda_env
stage: stylecheck
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
variables:
PYTHON_VERSION_TO_USE: "3.8"
script:
# install packages
- conda install -q pycodestyle pylint
# check style using pep8
- find ./ -name "*.py" | xargs pycodestyle --show-source --show-pep8
# check style using pylint (without taking into account)
- pylint nicr_mt_scene_analysis --rcfile=${CI_PROJECT_DIR}/.pylintrc || true
# tests_py36: # ubuntu18
# <<: *test_template
# variables:
# PYTHON_VERSION_TO_USE: "3.6"
# REPORT_COVERAGE: "false"
tests_py38: # ubuntu20
<<: *test_template
variables:
PYTHON_VERSION_TO_USE: "3.8"
REPORT_COVERAGE: "true"
tests_py310: # ubuntu22
<<: *test_template
variables:
PYTHON_VERSION_TO_USE: "3.10"
REPORT_COVERAGE: "false"
tests_py311: # current
<<: *test_template
variables:
PYTHON_VERSION_TO_USE: "3.11"
REPORT_COVERAGE: "false"
update_pip_package:
<<: *conda_env
stage: deploy
variables:
PYTHON_VERSION_TO_USE: "3.11"
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: manual
script:
# install pytorch to pass pytorch check in setup.py
- conda install pytorch=2.0.1 torchvision=0.15.2 cpuonly -c pytorch
# install remaining dependencies
- python -m pip install twine
# build package
- python setup.py sdist bdist_wheel
# upload package
- export TWINE_USERNAME=${TWINE_USERNAME}
- export TWINE_PASSWORD=${TWINE_PASSWORD}
- python -m twine upload --skip-existing --repository-url ${CI_API_V4_URL}/projects/${PACKAGE_REGISTRY}/packages/pypi dist/*