forked from cern-fts/fts3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
170 lines (149 loc) · 4.66 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
stages:
- build
- docker
- test
- publish
#--------------------------
# Build templates
#--------------------------
.build-template: &build-template_definition
stage: build
script:
- ci/fedora-packages.sh
- ci/common-rpm-build.sh
- 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
#--------------------------
cc7:
image: gitlab-registry.cern.ch/linuxsupport/cc7-base
<<: *build-template_definition
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_build_cc7:
<<: *kaniko_build-template
variables:
DMC_REPO: https://dmc-repo.web.cern.ch/dmc-repo/dmc-devel-el7.repo
DESTINATION: gitlab-registry.cern.ch/fts/fts3:latest-cc7
IMAGE: Dockerfile-ci-cc7
needs:
- job: cc7
rules:
- if: $CI_COMMIT_REF_NAME == "develop"
docker_build_alma9:
<<: *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-alma9
IMAGE: Dockerfile-ci-alma9
needs:
- job: alma9
rules:
- if: $CI_COMMIT_REF_NAME == "develop"
docker_tag_cc7:
<<: *kaniko_build-template
variables:
DMC_REPO: https://dmc-repo.web.cern.ch/dmc-repo/dmc-rc-el7.repo
DESTINATION: gitlab-registry.cern.ch/fts/fts3:${CI_COMMIT_TAG}-cc7
IMAGE: Dockerfile-ci-cc7
needs:
- job: cc7
rules:
- if: $CI_COMMIT_TAG != null
docker_tag_alma9:
<<: *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}-alma9
IMAGE: Dockerfile-ci-alma9
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
#--------------------------
cc7-test:
before_script:
- yum install -y dnf
image: gitlab-registry.cern.ch/linuxsupport/cc7-base
needs:
- job: cc7
<<: *test-template_definition
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:
- cc7
- alma9
script:
- automount
- cat "$repo_passwd" | kinit "$repo_user"
- |
for platform in cc7 alma9; do
packaging/fts-repo-manager.py --action add --base /eos/workspace/f/fts/repo/www/repos/ --ref ${CI_COMMIT_REF_NAME} --packages ${platform}/RPMS/*/*.rpm ${platform}/SRPMS/*
done
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