forked from openebs/mayastor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
177 lines (168 loc) · 6.63 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
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
stages:
- build
- test
- image
- publish
.only-default: &only-default
only:
- master
- external_pull_requests
- web
# Check code style and common programming errors in JS and rust
# source code. Do this in parallel to the build of the product,
# because cargo clippy takes time and we don't want to wait for it.
lint:
stage: build
image: mayadata/ms-buildenv:latest
before_script:
- git submodule update --init
script:
- nix-shell --run 'prettier --version'
- nix-shell --run 'prettier --config .prettierrc --check csi/moac/*.js mayastor-test/*.js'
- nix-shell --run 'jshint --config .jshintrc csi/moac/*.js mayastor-test/*.js'
# We don't want to perform this check for the submodules as it should be done in their respective repos
- echo 'set -e; for d in */Cargo.toml; do dir=$(dirname "$d"); if [ ! -f "$dir"/.git ]; then echo "cargo fmt -p "$dir" -- --check"; cargo fmt -p "$dir" -- --check; fi; done' > fmt.sh
- nix-shell --run 'sh fmt.sh'
- nix-shell --run 'cargo clippy --all --all-targets -- -D warnings'
only:
- external_pull_requests
- web
# Build mayastor and grpc gateway (rust source code) and run rust unit tests.
# Save built binaries for API tests done in the next stage.
build-mayastor:
<<: *only-default
stage: build
image: mayadata/ms-buildenv:latest
cache:
paths:
- cargo/
before_script:
- git submodule update --init
# modprobe is symlink to /sbin/kmod invoking kmod "manually" does not work
# kmod is programmed such that is has to be invoked through the symlink (!!)
#
# So, the runner is configured to mount the hosts /bin to /host/bin and
# we create a symlink from there. Note that we also mount the hosts
# kernel modules. We do this loading of the kernel mod early so that we fail
# early.
- ln -s /host/bin/kmod /usr/local/bin/modprobe
- modprobe nbd
- modprobe xfs
# as we run on a auto scalar, we must set the hugepage sizes before we can
# run these tests.
- echo 512 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
script:
- nix-shell --run 'cargo build --all-targets'
- nix-shell --run 'cd jsonrpc && cargo test'
# remove cargo-config to avoid sudo for running the tests (we run as root)
- nix-shell --run 'cd mayastor && cargo test -- --test-threads=1'
artifacts:
expire_in: 1 day
paths:
- target/debug/initiator
- target/debug/mayastor
- target/debug/mayastor-agent
- target/debug/mayastor-client
- target/debug/mctl
- target/debug/spdk
# Test mayastor grpc & cli interfaces using JS mocha test framework.
test-mayastor:
<<: *only-default
stage: test
image: mayadata/ms-buildenv:latest
dependencies:
- build-mayastor
cache:
paths:
- mayastor-test/node_modules/
before_script:
# TODO: Isolate this code to a shell script or cargo makefile to avoid
# repeating it
- ln -s /host/bin/kmod /usr/local/bin/modprobe
- modprobe nbd
- modprobe xfs
# more HPs - we need to run mayastor and initiator at the same time
- echo 1024 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
script:
- nix-shell -p nodejs-10_x python --run 'cd mayastor-test && npm install --unsafe-perm'
- nix-shell --run 'cd mayastor-test && ./node_modules/mocha/bin/mocha test_cli.js'
- nix-shell --run 'cd mayastor-test && ./node_modules/mocha/bin/mocha test_csi.js'
- nix-shell --run 'cd mayastor-test && ./node_modules/mocha/bin/mocha test_replica.js'
- nix-shell --run 'cd mayastor-test && ./node_modules/mocha/bin/mocha test_nexus.js'
after_script:
- rm -rf /dev/shm/*
- rm -rf /dev/hugepages/spdk*
# Build moac which comprises installation of npm dependencies and run
# the tests on it.
build-moac:
<<: *only-default
stage: build
image: mayadata/ms-buildenv:latest
cache:
paths:
- csi/moac/node_modules/
script:
- cd csi/moac
- nix-shell -p nodejs-10_x python --run 'npm install --unsafe-perm'
- nix-shell -p nodejs-10_x --run './node_modules/mocha/bin/mocha'
# Build moac docker image using the NIX.
image-moac:
<<: *only-default
stage: image
image: mayadata/ms-buildenv:latest
script:
- NIX_PATH="$NIX_PATH:nixpkgs-overlays=`pwd`/nix" nix-build '<nixpkgs>' -A node-moacImage
- cp result image-moac
artifacts:
expire_in: 1 day
paths:
- image-moac
# Build mayastor docker images using the NIX.
image-mayastor:
<<: *only-default
stage: image
image: mayadata/ms-buildenv:latest
before_script:
- git submodule update --init
script:
# This is a bit dirty but artifacts can be stored only in the source
# directory and we cannot store them there while building the images
# because it would clobber mayastor dir and change the hash of mayastor
# src in nix hence build the mayastor twice.
- NIX_PATH="$NIX_PATH:nixpkgs-overlays=`pwd`/nix" nix-build '<nixpkgs>' -A mayastorImage
- readlink -f result >/tmp/artifact1
- rm result
- NIX_PATH="$NIX_PATH:nixpkgs-overlays=`pwd`/nix" nix-build '<nixpkgs>' -A mayastorCSIImage
- readlink -f result >/tmp/artifact2
- rm result
- cp `cat /tmp/artifact1` image-mayastor
- cp `cat /tmp/artifact2` image-mayastor-csi
artifacts:
expire_in: 1 day
paths:
- image-mayastor
- image-mayastor-csi
publish-images:
stage: publish
image: mayadata/buildah:latest
variables:
# REGISTRY_USERNAME - secret variable
# REGISTRY_PASSWORD - secret variable
# REGISTRY_SERVER - secret variable (registry.hub.docker.com)
dependencies:
- image-mayastor
- image-moac
script:
- podman login --authfile /tmp/auth.json --username "${REGISTRY_USERNAME}" --password "${REGISTRY_PASSWORD}" "${REGISTRY_SERVER}"
- skopeo copy --authfile /tmp/auth.json docker-archive:image-mayastor docker://${REGISTRY_SERVER}/mayadata/mayastor:${CI_COMMIT_SHORT_SHA}
- skopeo copy --authfile /tmp/auth.json docker-archive:image-mayastor-csi docker://${REGISTRY_SERVER}/mayadata/mayastor-grpc:${CI_COMMIT_SHORT_SHA}
- skopeo copy --authfile /tmp/auth.json docker-archive:image-moac docker://${REGISTRY_SERVER}/mayadata/moac:${CI_COMMIT_SHORT_SHA}
# tag all images which have been just uploaded as latest
- skopeo copy --authfile /tmp/auth.json docker-archive:image-mayastor docker://${REGISTRY_SERVER}/mayadata/mayastor:latest
- skopeo copy --authfile /tmp/auth.json docker-archive:image-mayastor-csi docker://${REGISTRY_SERVER}/mayadata/mayastor-grpc:latest
- skopeo copy --authfile /tmp/auth.json docker-archive:image-moac docker://${REGISTRY_SERVER}/mayadata/moac:latest
when: manual
only:
- master