-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
187 lines (169 loc) · 5.22 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# CARS-MESH Gitlab-ci configuration file
# Workflow to allow no duplicated pipeline between branch and MR : https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
stages:
- init
- quality
- sync-github
# Default configuration for all jobs
default:
tags:
- Usine_Logicielle
# Variable definition for all jobs
variables:
# Variable to show more logs
# Allows to have predefined variables for manual pipelines: https://docs.gitlab.com/ee/ci/pipelines/index.html#prefill-variables-in-manual-pipelines
DEBUG:
value: "false"
description: "Show more logs"
# Allow to minimize useless logs (example downloads logs)
CI: "true"
# Needed to download pip through CNES internal artifactory without internet
PIP_INDEX_URL: "https://${ARTIFACTORY_USER}:${ARTIFACTORY_TOKEN}@${ARTIFACTORY_HOST}/artifactory/api/pypi/pypi/simple"
PIP_CERT: "${CNES_CERTIFICATE}"
# TAGS for images if each stages: base python and at3d cnes3d/testall for tox
TAG_IMAGE_PYTHON: "python:3.10.8"
TAG_IMAGE_CNES3D: "cnes3d/testall:0.1.0"
TAG_IMAGE_GIT: "alpine/git:v2.45.2"
# Can be used to move pip cache in local directory
PIP_CACHE_DIR: "${WORKSPACE}/.pip-cache/"
# Local artifactory Dockerhub URL containing copies of docker hub images
ARTIFACTORY_URL_DOCKER: "${ARTIFACTORY_HOST}/docker"
ARTIFACTORY_URL_PUBLIC: "${ARTIFACTORY_HOST}/publicremotes-docker"
# Paramètres proxy
HTTP_PROXY: http://${PROXY_USER}:${PROXY_PWD}@${PROXY_URL}
HTTPS_PROXY: http://${PROXY_USER}:${PROXY_PWD}@${PROXY_URL}
NO_PROXY: ${NO_PROXY}
# Steps:
# - checkout (done automatically as gitlab-ci is in the same project)
# - build (stage, init)
# - test (only fast tests)
# - test-all (all combinations, slow)
# - lint
# - docs
# - sync-github
build:
stage: init
image:
${ARTIFACTORY_URL_DOCKER}/${TAG_IMAGE_CNES3D}
# before_script:
# set up proxy
#- export HTTP_PROXY=http://${PROXY_USER}:${PROXY_PWD}@proxy-tech-web.cnes.fr:8060
#- export HTTPS_PROXY=http://${PROXY_USER}:${PROXY_PWD}@proxy-tech-web.cnes.fr:8060
script:
# Install cars-mesh + requirements in venv
- VENV="venv" make install
# Activate virtualenv
- source venv/bin/activate
# Test quickly cars-mesh
- cars-mesh -h
# Show artifact size
- du -h --max-depth=1
- deactivate
artifacts:
untracked: true
expire_in: 1 day
test:
stage: quality
image: ${ARTIFACTORY_URL_DOCKER}/${TAG_IMAGE_CNES3D}
needs:
- build
script:
# Load previous python venv
- source venv/bin/activate
# Run only fast tests with tox and several python3 versions
- make tox
- deactivate
- make clean
artifacts:
untracked: false
expire_in: 1 day
test-all:
stage: quality
image: ${ARTIFACTORY_URL_DOCKER}/${TAG_IMAGE_CNES3D}
needs:
- build
script:
# Load previous python venv
- source venv/bin/activate
# Run all tests (slow) with tox and several python3 versions
- make tox-all
- deactivate
- make clean
only:
- master
- tags
artifacts:
untracked: false
expire_in: 1 day
linting:
stage: quality
image: ${ARTIFACTORY_URL_DOCKER}/${TAG_IMAGE_CNES3D}
needs:
- build
script:
# Load previous python venv
- source venv/bin/activate
# Run project quality code.
- make lint
- deactivate
- make clean
artifacts:
untracked: false
expire_in: 1 day
docs:
stage: quality
image: ${ARTIFACTORY_URL_DOCKER}/${TAG_IMAGE_CNES3D}
needs:
- build
script:
# Load previous python venv
- source venv/bin/activate
# Generate documentation
- make docs
- deactivate
- make clean
artifacts:
untracked: false
expire_in: 1 day
sync-github:
stage: sync-github
needs:
- test-all
- linting
- docs
# Get a small docker git image
image:
name: ${ARTIFACTORY_URL_PUBLIC}/${TAG_IMAGE_GIT}
entrypoint: [""]
before_script:
# Add CNES certificates to allow the runner to clone gitlab repo.
# CNES_CERTIFICATE is defined in the CNES global gitlab instance
- cat ${CNES_CERTIFICATE} > /usr/local/share/ca-certificates/my-cert.crt
# Certificate update
- update-ca-certificates
script:
# Clone this repo
- git clone $CI_REPOSITORY_URL
# Get in the repo directory
- cd $(basename $CI_REPOSITORY_URL .git)
# Checkout to tag or master
- git checkout ${CI_COMMIT_REF_NAME}
# push to our branch from HEAD (since we always are on a detached HEAD)
# configure proxy TECH ! (depends on proxy creds!)
- git -c http.proxy=http://${PROXY_USER}:${PROXY_PWD}@${PROXY_URL} push https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/CNES/cars-mesh HEAD:${CI_COMMIT_REF_NAME}
# Add remote github with identification information
#- git remote add gitlabsync https://${GITHUB_TOKEN_NAME}:${GITHUB_TOKEN}@${GITHUB_URL}/gitlabsync.git
# Push modifications from gitlab master to github master
#- git push gitlabsync master:master
# Trigger only on master branch
only:
- master
- tags
timeout: 20 minutes