-
Notifications
You must be signed in to change notification settings - Fork 10
/
.gitlab-ci.yml
210 lines (197 loc) · 6.18 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
variables:
HOME_DIR: /home/eos
NODSNAX: http://localhost:8888
PATH_TO_MINTS: $HOME_DIR/$CI_PROJECT_DIR
JEST_TESTS: $HOME_DIR/$CI_PROJECT_DIR/jest_tests
SNAX_HOME: $HOME_DIR/$CI_PROJECT_DIR/build/
WALLET_DIR: $HOME_DIR/snax-wallet
MONGOD_CONF: $HOME_DIR/opt/mongodb/mongod.conf
DOCKER_DRIVER: overlay2
USERNAME: SnaxOne
ORG: SnaxFoundation
REGISTRY_PUB: snaxfoundation
stages:
- cleanup
- build
- test
- build-docker
- deploy
- publish
cleanup:
stage: cleanup
script:
- sudo rm -rf /tmp/*-*-*-*
- sudo rm -rf $WALLET_DIR
- docker stop mongo || true
except:
changes:
- "*.md"
tags:
- build1
build:
stage: build
script:
- git submodule update --init --recursive
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- ./snax_build.sh
- rm -rf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz && tar -czf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz build
- sudo ./snax_install.sh
artifacts:
name: "$CI_COMMIT_REF_NAME"
paths:
- build/bin/
except:
variables:
- $CI_COMMIT_MESSAGE =~ /skip-build/
changes:
- "*.md"
tags:
- build1
build:tag:
stage: build
script:
- git submodule update --init --recursive
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- ./snax_build.sh
- rm -rf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz && tar -czf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz build
- sudo ./snax_install.sh
artifacts:
name: "$CI_COMMIT_REF_NAME"
paths:
- build/bin/
only:
- tags
tags:
- build1
build:tag:macos:
stage: build
script:
- git submodule update --init --recursive
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- ./snax_build.sh
- rm -rf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz && tar -czf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz build
- mv build/bin build/bin-mac
artifacts:
name: "macos-$CI_COMMIT_REF_NAME"
paths:
- build/bin-mac
only:
- tags
tags:
- macos
build:tag:elastic:
stage: build
script:
- git submodule update --init --recursive
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- git clone https://github.com/SnaxFoundation/elasticsearch_plugin.git plugins/elasticsearch_plugin
- cd plugins/elasticsearch_plugin/
- git checkout release/1.5.x
- git submodule update --init --recursive
- cd ../../
- sed -i '/add_subdirectory(login_plugin)/a add_subdirectory(elasticsearch_plugin)' plugins/CMakeLists.txt
- sed -i '/PRIVATE -Wl,${whole_archive_flag} history_plugin/a PRIVATE -Wl,${whole_archive_flag} elasticsearch_plugin -Wl,${no_whole_archive_flag}' programs/snaxnode/CMakeLists.txt
- ./snax_build.sh
- rm -rf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz && tar -czf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz build
- sudo ./snax_install.sh
artifacts:
name: "elastic-$CI_COMMIT_REF_NAME"
paths:
- build/bin-elastic
only:
- tags
tags:
- build1
test:jest:
stage: test
script:
- rm -rf $WALLET_DIR
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- cd $JEST_TESTS && yarn install && yarn test -u
except:
variables:
- $CI_COMMIT_MESSAGE =~ /skip-test/
changes:
- "*.md"
tags:
- build1
test:core:
stage: test
script:
- docker stop mongo || true && docker run --rm -d --name mongo -p 27017:27017 mvertes/alpine-mongo
- rm -rf $WALLET_DIR
- export PATH=$HOME_DIR/opt/mongodb/bin:$PATH
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- cd $SNAX_HOME && ctest --output-on-failure
except:
variables:
- $CI_COMMIT_MESSAGE =~ /skip-test/
changes:
- contracts/platform/*
- contracts/p.steem/*
- jest_tests/*
- "*.md"
- contracts/*
tags:
- build1
build:docker:
stage: build-docker
script:
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- cp -r /usr/local/lib .
- cp -r /usr/local/snax/bin .
- echo "$CI_COMMIT_REF_NAME:$CI_COMMIT_SHA" > snax-version
- docker build --rm -t $REGISTRY/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME .
- docker push $REGISTRY/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME
- docker rmi $REGISTRY/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME
except:
changes:
- "*.md"
tags:
- build1
build:docker:tag:
stage: build-docker
script:
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- cp -r /usr/local/lib .
- cp -r /usr/local/snax/bin .
- echo "$CI_COMMIT_REF_NAME:$CI_COMMIT_SHA" > snax-version
- docker build --rm -t $REGISTRY_PUB/$CI_PROJECT_NAME:$CI_COMMIT_TAG .
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker push $REGISTRY_PUB/$CI_PROJECT_NAME:$CI_COMMIT_TAG
- docker rmi $REGISTRY_PUB/$CI_PROJECT_NAME:$CI_COMMIT_TAG
only:
- tags
tags:
- build1
build:docker:tag:elastic:
stage: build-docker
script:
- if [ -f /tmp/build-$CI_COMMIT_REF_NAME.tar.gz ]; then tar -xf /tmp/build-$CI_COMMIT_REF_NAME.tar.gz; fi
- cp -r /usr/local/lib .
- cp -r /usr/local/snax/bin .
- echo "$CI_COMMIT_REF_NAME:$CI_COMMIT_SHA" > snax-version
- docker build --rm -t $REGISTRY_PUB/$CI_PROJECT_NAME:$CI_COMMIT_TAG-elastic .
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker push $REGISTRY_PUB/$CI_PROJECT_NAME:$CI_COMMIT_TAG-elastic
- docker rmi $REGISTRY_PUB/$CI_PROJECT_NAME:$CI_COMMIT_TAG-elastic
only:
- tags
tags:
- build1
publish:
stage: publish
image: ${REGISTRY}/ok.sh:master
script:
- cd build/bin && tar cvzf bin-linux.tar.gz *
- cd ../bin-mac && tar cvzf bin-macos.tar.gz *
- ok.sh create_release $ORG $CI_PROJECT_NAME $CI_COMMIT_TAG prerelease=true
- docker-entrypoint.sh $ORG $CI_PROJECT_NAME $CI_COMMIT_TAG bin-linux.tar.gz ../bin/bin-linux.tar.gz
- docker-entrypoint.sh $ORG $CI_PROJECT_NAME $CI_COMMIT_TAG bin-macos.tar.gz ./bin-macos.tar.gz
dependencies:
- build:tag
- build:tag:macos
only:
- tags
tags:
- docker