Skip to content

Commit d1ac0e7

Browse files
author
Ryan Bauman
committed
RELENG-623 - add gitlab ci support
1 parent 81de09b commit d1ac0e7

File tree

1 file changed

+172
-0
lines changed

1 file changed

+172
-0
lines changed

.gitlab-ci.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
variables:
2+
test_suite: test_$CI_PROJECT_NAME.py
3+
namespace: rh.
4+
rh_20_release: '2.0.6'
5+
rh_21_release: '2.1.1'
6+
7+
.package: &package
8+
image: ${docker_registry}utils/docker:latest-rpm
9+
stage: build
10+
tags:
11+
- dind
12+
script:
13+
# Ensure newest version of FROM image
14+
- docker pull ${docker_registry}rpmbuild:${dist}-${arch}-onbuild
15+
# Use RPM release from specfile if this is a tag
16+
- safe_version=$(echo ${short_version} | tr -d -)
17+
- safe_ref=$(echo ${CI_COMMIT_REF_NAME} | tr -d /| tr '[:upper:]' '[:lower:]')
18+
- if [ -z "$CI_COMMIT_TAG" ]; then
19+
rpm_release="0.$CI_PIPELINE_ID.rh${safe_version}";
20+
else
21+
rpm_release="`rpm --query --queryformat "%{release}\n" --specfile ${namespace}$CI_PROJECT_NAME.spec | awk -F"." "{print $1}"`.rh${safe_version}";
22+
fi
23+
- other_repos="$yum_repo_url/redhawk-core-framework/$redhawk_version/$dist/$arch $yum_repo_url/redhawk-sharedlibs/VITA49Libraries/3.0/rh${safe_version}/$dist/$arch"
24+
- docker pull ${docker_registry}rpmbuild:$dist-$arch-onbuild
25+
- printf "FROM ${docker_registry}rpmbuild:$dist-$arch-onbuild" > Dockerfile
26+
- name=$(echo $CI_PROJECT_NAME| tr '[:upper:]' '[:lower:]')
27+
- docker build -t $name:$safe_ref-$dist-$arch-rh${safe_version} --build-arg "project=$CI_PROJECT_NAME"
28+
--build-arg "rpm_release=$rpm_release"
29+
--build-arg "spec_file=${namespace}$CI_PROJECT_NAME.spec"
30+
--build-arg "arch=$arch"
31+
--build-arg "other_repos=$other_repos" .
32+
- id=$(docker create $name:$safe_ref-$dist-$arch-rh${safe_version})
33+
- docker cp $id:/root/rpmbuild/RPMS/ output/
34+
- docker rm -f $id || true
35+
artifacts:
36+
paths:
37+
- output/*/*.rpm
38+
expire_in: 2 days
39+
40+
.test: &test
41+
image: ${docker_registry}redhawk/buildenv:$dist-$arch
42+
stage: test
43+
dependencies: []
44+
script:
45+
- . /usr/local/redhawk/python-virtualenv/bin/activate
46+
- safe_version=$(echo ${short_version} | tr -d -)
47+
- yum-config-manager --add-repo $yum_repo_url/redhawk-core-framework/$redhawk_version/$dist/$arch
48+
- yum-config-manager --add-repo $yum_repo_url/redhawk-sharedlibs/VITA49Libraries/3.0/rh${safe_version}/$dist/$arch
49+
- touch /var/lib/rpm/* && yum-builddep --nogpgcheck -y ${namespace}$CI_PROJECT_NAME.spec
50+
- source /etc/profile.d/redhawk.sh
51+
- export SDRROOT=/var/redhawk/sdr
52+
- if [ -d cpp ] && [ "${dist}" == "el7" ]; then
53+
export CXXFLAGS='-g -Og -fprofile-arcs -ftest-coverage' V=1;
54+
fi
55+
- ./build.sh
56+
- cd tests
57+
- env | tee -a ../$CI_PROJECT_NAME-$CI_COMMIT_SHA-tests.log
58+
- pip list | tee -a ../$CI_PROJECT_NAME-$CI_COMMIT_SHA-tests.log
59+
- python $test_suite 2>&1 | tee -a ../$CI_PROJECT_NAME-$CI_COMMIT_SHA-tests.log
60+
- cd ..
61+
- if [ -d cpp ]; then
62+
gcovr -r . --xml --exclude-directories=tests > gcovr.xml;
63+
cppcheck --enable=all --xml-version=2 -i tests . 2> cppcheck-results.xml;
64+
fi
65+
- find * -name '*.cpp' -o -name '*.h' -o -name '*.xml' -o -name '*.py' -o -name '*.java' -o -name '*.log' | tar czvf $CI_PROJECT_DIR/output.tar.gz --files-from -
66+
artifacts:
67+
paths:
68+
- $CI_PROJECT_DIR/output.tar.gz
69+
expire_in: 2 days
70+
71+
package:el6:rh2.0:
72+
variables:
73+
short_version: '2.0'
74+
redhawk_version: $rh_20_release
75+
dist: el6
76+
arch: x86_64
77+
<<: *package
78+
79+
package:el6-i386:rh2.0:
80+
variables:
81+
redhawk_version: $rh_20_release
82+
short_version: '2.0'
83+
dist: el6
84+
arch: i686
85+
<<: *package
86+
87+
package:el6:rh2.1:
88+
variables:
89+
redhawk_version: $rh_21_release
90+
short_version: '2.1'
91+
dist: el6
92+
arch: x86_64
93+
<<: *package
94+
95+
package:el6-i386:rh2.1:
96+
variables:
97+
redhawk_version: $rh_21_release
98+
short_version: '2.1'
99+
dist: el6
100+
arch: i686
101+
<<: *package
102+
103+
package:el7:rh2.1:
104+
variables:
105+
redhawk_version: $rh_21_release
106+
short_version: '2.1'
107+
dist: el7
108+
arch: x86_64
109+
<<: *package
110+
111+
test:el6:rh2.0:
112+
variables:
113+
redhawk_version: $rh_20_release
114+
short_version: '2.0'
115+
dist: el6
116+
arch: x86_64
117+
<<: *test
118+
119+
test:el6-i386:rh2.0:
120+
variables:
121+
redhawk_version: $rh_20_release
122+
short_version: '2.0'
123+
dist: el6
124+
arch: i686
125+
<<: *test
126+
127+
test:el6:rh2.1:
128+
variables:
129+
redhawk_version: $rh_21_release
130+
short_version: '2.1'
131+
dist: el6
132+
arch: x86_64
133+
<<: *test
134+
135+
test:el6-i386:rh2.1:
136+
variables:
137+
redhawk_version: $rh_21_release
138+
short_version: '2.1'
139+
dist: el6
140+
arch: i686
141+
<<: *test
142+
143+
test:el7:rh2.1:
144+
variables:
145+
redhawk_version: $rh_21_release
146+
short_version: '2.1'
147+
dist: el7
148+
arch: x86_64
149+
<<: *test
150+
151+
deploy:
152+
image: centos:7
153+
stage: deploy
154+
dependencies: []
155+
script:
156+
- if [ -n "$jenkins_url" ]; then
157+
curl --insecure -X POST $jenkins_url/job/$CI_PROJECT_NAMESPACE/job/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME/buildWithParameters?pipeline_id=$CI_PIPELINE_ID --user $jenkins_user:$jenkins_api_token;
158+
fi
159+
only:
160+
- branches
161+
162+
deploy:release:
163+
image: centos:7
164+
stage: deploy
165+
dependencies: []
166+
#Note, must set set associated redhawk_release
167+
script:
168+
- if [ -n "$jenkins_url" ]; then
169+
curl --insecure -X POST $jenkins_url/job/$rh_21_release/job/$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME/buildWithParameters?pipeline_id=$CI_PIPELINE_ID --user $jenkins_user:$jenkins_api_token;
170+
fi
171+
only:
172+
- tags

0 commit comments

Comments
 (0)