-
Notifications
You must be signed in to change notification settings - Fork 66
/
.gitlab-ci.yml
144 lines (130 loc) · 4.48 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
136
137
138
139
140
141
142
143
144
image: "python:3.8"
#cache:
# key:
# files:
# - poetry.lock
# prefix: "${CI_JOB_NAME}"
# paths:
# - .venv
stages:
- tests
- deploy
.install-deps-template: &install-deps
before_script:
- pip install --upgrade pip virtualenv
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - --version 1.1.8
- export PATH="/root/.local/bin:$PATH"
- poetry --version
# Force a recent pip version inside the virtualenv
- virtualenv .venv
- .venv/bin/pip install --upgrade pip
- poetry config virtualenvs.in-project true
- poetry install -E all -E webserver
# Install mmseqs2 SSE2 (the slowest version, for compatibility)
- wget https://mmseqs.com/latest/mmseqs-linux-sse2.tar.gz; tar xvfz mmseqs-linux-sse2.tar.gz; export PATH=$(pwd)/mmseqs/bin/:$PATH
.test-template: &test
<<: *install-deps
variables:
SKIP_NEGLECTED_EMBEDDER_TESTS: 1
SKIP_AVX2_TESTS: 1
stage: tests
coverage: '/TOTAL.*\s(\d+\.\d+\%)/'
script: poetry run pytest -v
python3.8:
<<: *test
image: python:3.8
python3.9:
<<: *test
image: python:3.9
# Those two are ran weekly to also run test the more expensive tests
python3.8-scheduled:
<<: *install-deps
stage: tests
variables:
SKIP_AVX2_TESTS: 1
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
image: python:3.8
script: poetry run pytest -v
python3.9-scheduled:
<<: *install-deps
stage: tests
variables:
SKIP_AVX2_TESTS: 1
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
image: python:3.9
script: poetry run pytest -v
docs:
<<: *install-deps
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
when: always
- if: '$CI_COMMIT_TAG'
when: always
script:
- . .venv/bin/activate
- cd docs
- make html
# https://about.gitlab.com/blog/2017/11/02/automating-boring-git-operations-gitlab-ci/
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$GIT_SSH_PRIV_KEY")
- git config --global user.name "bio_embeddings"
- git config --global user.email "[email protected]"
# https://stackoverflow.com/a/29380765/3549270
- mkdir ~/.ssh
- ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
- git clone [email protected]:sacdallago/bio_embeddings.git docs-branch
- cd docs-branch
- git checkout gh-pages
# We want to have separate documentation for every release while updating develop with every commit
# https://unix.stackexchange.com/a/412262/77322
- cp -r ../_build/html/. ${CI_COMMIT_TAG:-develop}
# Update the index page redirect to the latest tag
- if [ -n "$CI_COMMIT_TAG" ]; then echo "<meta http-equiv=refresh content=0;url='$CI_COMMIT_TAG/'>" > index.html; fi
# Update the "latest" redirect to the latest tag
- if [ -n "$CI_COMMIT_TAG" ]; then rm latest && ln -s $CI_COMMIT_TAG latest; fi
- git add .
- git commit --allow-empty -m 'Upload docs'
- git push
.setup-kaniko-template: &setup-kaniko
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
when: always
- if: '$CI_COMMIT_TAG'
when: always
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [ "" ]
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"ghcr.io\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
docker-webserver-develop:
<<: *setup-kaniko
stage: deploy
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/webserver/Dockerfile.webserver --destination ghcr.io/bioembeddings/webserver:${CI_COMMIT_TAG:-latest}
docker-worker-develop:
<<: *setup-kaniko
stage: deploy
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/webserver/Dockerfile.worker --destination ghcr.io/bioembeddings/worker:${CI_COMMIT_TAG:-latest}
docker-bio_embeddings-develop:
<<: *setup-kaniko
stage: deploy
script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination ghcr.io/bioembeddings/bio_embeddings:${CI_COMMIT_TAG:-latest}
release-to-pypi:
stage: deploy
rules:
- if: '$CI_COMMIT_TAG'
when: always
image: python:3.8
script:
- pip install --upgrade pip virtualenv
- curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
- source $HOME/.local/env
- poetry --version
- poetry publish --build -u __token__ -p $PYPI_TOKEN