-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
173 lines (150 loc) · 5.14 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
173 lines (150 loc) · 5.14 KB
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
stages:
- static_code_analysis
- build
- docker
- test
- publish
#---------------------------------
# Static Code Analysis
#---------------------------------
.pylint_template: &pylint_definition
# Check for Python syntax errors
image: gitlab-registry.cern.ch/fts/fts3:ci
stage: static_code_analysis
script:
- PY="PY${CI_JOB_NAME##pylint}"
- VENV="VENV_${CI_JOB_NAME##pylint}"
- export PYENV_ROOT="$HOME/.pyenv"
- export PATH="$PYENV_ROOT/bin:$PATH"
- pyenv global ${!PY}
- source ${!VENV}/bin/activate
- pylint --version
- pylint --output-format colorized --source-roots ./src/scheduler/python/fts_scheduler ./src/scheduler/python/fts_scheduler
- pylint --output-format colorized --disable C,R,W ./src/tokens/scripts/ftstokenhousekeeperd
black:
# Check that every file has been formatted with black
image: gitlab-registry.cern.ch/fts/fts3:ci
stage: static_code_analysis
script:
- black --version
- black --check --fast --diff --target-version py39 ./src/scheduler/python
- black --check --fast --diff --target-version py39 ./src/tokens/scripts/ftstokenhousekeeperd
pylint39:
<<: *pylint_definition
pylint310:
<<: *pylint_definition
pylint311:
<<: *pylint_definition
#--------------------------
# Build templates
#--------------------------
.build-template: &build-template_definition
stage: build
script:
- ci/fedora-packages.sh
- ci/common-rpm-build.sh
- if [[ -n "$CI_COMMIT_TAG" ]]; then gpg --batch --import ${FTS_GPG_KEY} ; rpmsign --addsign --define '%_signature gpg' --define '%_gpg_name FTS Development' build/RPMS/*/*.rpm ; fi
- mkdir ${CI_JOB_NAME}
- cp -rv build/RPMS build/SRPMS ${CI_JOB_NAME}
- tree ${CI_JOB_NAME}
variables:
BRANCH: ${CI_COMMIT_REF_NAME}
artifacts:
paths:
- "$CI_JOB_NAME"
#--------------------------
# Build jobs
#--------------------------
alma9:
image: gitlab-registry.cern.ch/linuxsupport/alma9-base
<<: *build-template_definition
#--------------------------
# Docker build templates
#--------------------------
.kaniko_build: &kaniko_build-template
stage: docker
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- if [[ -z "$CI_COMMIT_TAG" ]]; then CACHE="true"; else CACHE="false"; fi
- printf "CACHE=${CACHE}\nDESTINATION=${DESTINATION}\nDMCREPO=${DMC_REPO}\n"
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --dockerfile ci/docker/${IMAGE} --context "${CI_PROJECT_DIR}" --cache=${CACHE} --destination ${DESTINATION} --build-arg dmcrepo=${DMC_REPO}
retry: 1
#--------------------------
# Docker build jobs
#--------------------------
docker_latest:
<<: *kaniko_build-template
variables:
DMC_REPO: https://dmc-repo.web.cern.ch/dmc-repo/dmc-devel-el9.repo
DESTINATION: gitlab-registry.cern.ch/fts/fts3:latest
IMAGE: Dockerfile-ci
needs:
- job: alma9
rules:
- if: '$CI_PROJECT_NAMESPACE != "fts"'
when: never
- if: $CI_COMMIT_REF_NAME == "develop"
docker_tag:
<<: *kaniko_build-template
variables:
DMC_REPO: https://dmc-repo.web.cern.ch/dmc-repo/dmc-rc-el9.repo
DESTINATION: gitlab-registry.cern.ch/fts/fts3:${CI_COMMIT_TAG}
IMAGE: Dockerfile-ci
needs:
- job: alma9
rules:
- if: $CI_COMMIT_TAG != null
#--------------------------
# Testing templates
#--------------------------
.test-template: &test-template_definition
stage: test
script:
- dnf install -y git createrepo epel-release
- ci/write-repo-file.sh
- ARTIFACTS="${CI_JOB_NAME%%-test}"
- mkdir -p /repo/fts ; cp -v ${ARTIFACTS}/RPMS/*/*.rpm /repo/fts ; createrepo /repo/fts
- echo -e "[fts]\nname=FTS\nbaseurl=file:///repo/fts\ngpgcheck=0\nenabled=1\npriority=2" > /etc/yum.repos.d/fts.repo
- dnf install -y fts-tests
- fts-unit-tests --log_level=all --report_level=detailed
#--------------------------
# Testing jobs
#--------------------------
alma9-test:
image: gitlab-registry.cern.ch/linuxsupport/alma9-base
needs:
- job: alma9
<<: *test-template_definition
#--------------------------
# Publish templates
#--------------------------
.publish-template: &publish-template_definition
stage: publish
image: gitlab-registry.cern.ch/eos/gitlab-eos/alma9:latest
dependencies:
- alma9
script:
- automount
- cat "$repo_passwd" | kinit "$repo_user"
- packaging/fts-repo-manager.py --action add --base /eos/workspace/f/fts/repo/www/repos/ --ref ${CI_COMMIT_REF_NAME} --packages alma9/RPMS/*/*.rpm alma9/SRPMS/*
tags:
- docker-privileged-xl
retry: 2
#--------------------------
# Publish jobs
#--------------------------
rpms:
<<: *publish-template_definition
rules:
- if: '$CI_PROJECT_NAMESPACE != "fts"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: '$CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_TAG != null'
- if: '$CI_COMMIT_REF_NAME == "FTS-1925_token_project" || $CI_COMMIT_TAG != null'
- if: '$CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_TAG == null'
when: manual