-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
95 lines (90 loc) · 2.59 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
stages:
- linting
- test
- deploy
cache:
paths:
- coverage.tar.gz
.env_setup:
before_script:
# install pyenv and python versions
- if [[ -z "${PYENV_DIR}" ]]; then export PYENV_DIR=${HOME}/.pyenv; fi
- export PYENV_ROOT="${PYENV_DIR}" && export PATH="$PYENV_ROOT/bin:$PATH" && export TMPDIR="$PYENV_ROOT/.pip-tmp"
- if ! command -v pyenv; then rm -rf ${PYENV_DIR} || true; git clone https://github.com/pyenv/pyenv.git ${PYENV_DIR}; else cd ${PYENV_DIR}; git pull; cd -; eval "$(pyenv init --path)"; fi
- pyenv local | xargs -L1 pyenv install -s
- which python
# install poetry
- curl -sSL https://install.python-poetry.org | python -
# add poetry install path to PATH
- export PATH="$HOME/.local/bin:${PATH}"
# update poetry, configure, and install tox
- poetry self update
- poetry config virtualenvs.in-project true; poetry config cache-dir ${PYENV_DIR}/.poetry-cache;
- poetry config --list
- poetry run pip install tox
linting:
stage: linting
extends: .env_setup
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "public"
when: never
- if: $CI_COMMIT_BRANCH == "nist-pages"
when: never
- when: always
retry: 2
script:
- poetry install
- poetry run tox -e lint
needs: []
nexusLIMS_tests:
stage: test
script:
# run tests with coverage and output coverage report to html
- TOX_SKIP_ENV=lint poetry run tox
retry: 2
extends: .env_setup
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "public"
when: never
- if: $CI_COMMIT_BRANCH == "nist-pages"
when: never
- when: always
after_script:
# cache the coverage results so they can be published, always returning true
- mv tests/coverage .
- tar -czf coverage.tar.gz coverage || true
coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/
artifacts:
paths:
- coverage
reports:
junit: tests/test_report.xml
expire_in: 30 days
needs: ['linting']
pages:
stage: deploy
script:
- poetry run tox -e docs
- mkdir -p public/doc && rsync -avr _build/ public/doc/
retry: 2
extends: .env_setup
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == "public"
when: never
- if: $CI_COMMIT_BRANCH == "nist-pages"
when: never
- when: always
after_script:
- tar -xzf coverage.tar.gz -C public/ || true
artifacts:
paths:
- public
dependencies:
- nexusLIMS_tests
needs: ['nexusLIMS_tests']