forked from LINBIT/linstor-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
141 lines (131 loc) · 4.72 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
image: $LINBIT_DOCKER_REGISTRY/linstor-build:latest
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- ./gradlew -PoverrideVersion= getProtoc
variables:
GIT_SUBMODULE_STRATEGY: recursive
VIRTER_VERSION: v0.7.1
VMSHED_VERSION: v0.8.1
BUILD_HELPERS_VERSION: c0d39c0e5a2235262f21d072c4bf3b2dd62b2040
cache:
paths:
- .gradle/wrapper
- .gradle/caches
- tools
stages:
- build
- test
- deploy
- test-e2e
check-openapi:
stage: build
image:
name: jamescooke/openapi-validator
entrypoint: [""] # force empty entrypoint to workaround a gitlab issue
rules:
- changes:
- docs/rest_v1_openapi.yaml
before_script:
- echo default before disabled
script:
# openapi-validator currently can't disable the null property check, so sed them out
- "sed 's/default: null//g' docs/rest_v1_openapi.yaml > /tmp/openapi_null_fixed.yaml"
- lint-openapi -e /tmp/openapi_null_fixed.yaml -c docs/.validaterc
build:
stage: build
rules:
- when: on_success
script:
- ./gradlew -PversionOverride= assemble
artifacts:
paths:
- build/distributions/linstor-server.tar
expire_in: 4 days
test:
stage: test
rules:
- when: on_success
script:
- JAVA_OPTS="-ea" ./gradlew -PversionOverride= test
artifacts:
reports:
junit: build/test-results/test/TEST-*.xml
deploy:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
before_script:
- echo "DEPLOY"
script:
- cp Dockerfile.test-controller Dockerfile
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY/linstor/linstor-server/controller:latest .
- docker push $CI_REGISTRY/linstor/linstor-server/controller:latest
tags:
- shell
deploy-nexus:
stage: deploy
image: $LINBIT_DOCKER_REGISTRY/build-helpers:latest
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: $CI_COMMIT_BRANCH == 'jenkins'
- if: $CI_COMMIT_BRANCH == 'master'
before_script:
- curl -sSL $LINBIT_REGISTRY_URL/repository/lbbuild/lbbuildctl-latest -o /usr/local/bin/lbbuildctl
- chmod +x /usr/local/bin/lbbuildctl
script:
- LINSTOR_VERSION=1.99.0.$CI_COMMIT_SHORT_SHA
- dummy-release.sh linstor-server $LINSTOR_VERSION 1 linstor.spec
- FORCE=1 VERSION=$LINSTOR_VERSION make debrelease
- curl -isSf -u $LINBIT_REGISTRY_USER:$LINBIT_REGISTRY_PASSWORD --upload-file linstor-server-$LINSTOR_VERSION.tar.gz $LINBIT_REGISTRY_URL/repository/lbbuild-upstream/
- lbbuildctl build linstor-server --arch amd64 --ci -v "$LINSTOR_VERSION" -l -e LINBIT_REGISTRY_USER=$LINBIT_REGISTRY_USER -e LINBIT_REGISTRY_PASSWORD=$LINBIT_REGISTRY_PASSWORD -e LINBIT_REGISTRY_URL=$LINBIT_REGISTRY_URL -d ubuntu-bionic,ubuntu-focal,rhel7.0,rhel8.0
test-e2e:
stage: test-e2e
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: $CI_COMMIT_BRANCH == 'jenkins'
- if: $CI_COMMIT_BRANCH == 'master'
tags:
- libvirt
before_script:
- echo "no before"
script:
- TEST_BRANCH=latest
- TEST_BUNDLE_BRANCH=master
- |
SAFE_REF_NAME=${CI_COMMIT_REF_NAME//\//-}
if docker image pull $LINBIT_DOCKER_REGISTRY/linstor-tests:$SAFE_REF_NAME ; then
TEST_BRANCH=$CI_COMMIT_REF_NAME
TEST_BUNDLE_BRANCH=$SAFE_REF_NAME
else
docker image pull $LINBIT_DOCKER_REGISTRY/linstor-tests:latest
fi
- mkdir -p linstor-test-bundle
- curl -sSL $LINBIT_REGISTRY_URL/repository/test-suite/linstor-test-bundle-$TEST_BUNDLE_BRANCH.tgz | tar -C linstor-test-bundle -xvzf -
- |
curl -sSfL -u gitlab-ci-token:$CI_JOB_TOKEN https://gitlab.at.linbit.com/linbit/build-helpers/-/archive/$BUILD_HELPERS_VERSION/ignored.tar.gz | tar -xvzf -
mv build-helpers-* build-helpers
. build-helpers/gitlab-utils.sh
- |
ci_prepare_tools
ci_fetch_rq
ci_fetch_binary virter virter-$VIRTER_VERSION https://github.com/LINBIT/virter/releases/download/$VIRTER_VERSION/virter-linux-amd64
ci_fetch_binary vmshed vmshed-$VMSHED_VERSION https://github.com/LINBIT/vmshed/releases/download/$VMSHED_VERSION/vmshed-linux-amd64
- |
case "$CI_COMMIT_BRANCH" in
"jenkins") VARIANTS="--variant default --variant etcd" ;;
*) VARIANTS=$VMSHED_VARIANTS ;;
esac
- echo "Running variants $VARIANTS"
- echo "LINSTOR-TEST BRANCH = $TEST_BRANCH"
- export LINSTOR_VERSION=1.99.0.$CI_COMMIT_SHORT_SHA
- export LINSTOR_TESTS_VERSION=$TEST_BRANCH
- ./linstor-test-bundle/virter/run-test.sh $VARIANTS $VMSHED_TORUN
artifacts:
# provide a convenient name so that the downloaded artifacts can be identified
name: $CI_PROJECT_NAME-$CI_JOB_ID
paths:
- tests-out/
when: always
reports:
junit: tests-out/test-results/*.xml