-
Notifications
You must be signed in to change notification settings - Fork 17
/
.gitlab-ci.yml
300 lines (283 loc) · 9.74 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
stages:
- build
- test
- release
variables:
RUNNER_SCRIPT_TIMEOUT: 30m
DOCKER_TLS_CERTDIR: "/certs"
TNN_BUILD_MAC: false
TNN_BUILD_WIN: true
AMD64_TARGET_LEVEL: x86-64-v3
PACKAGE_VERSION: "0.0.1"
CMAKE_ARGS: "-DWITH_HIP=OFF"
LINUX_AMD64_TGZ: "Tnn-miner-amd64-${PACKAGE_VERSION}.tar.gz"
LINUX_ARM64_TGZ: "Tnn-miner-arm64-${PACKAGE_VERSION}.tar.gz"
MACOS_ARM64_TGZ: "Tnn-miner-macos-arm64-${PACKAGE_VERSION}.tar.gz"
WRAPPER_TEMP: "wrapper.tar.gz"
WIN_AMD64_ZIP: "Tnn-miner-win64-${PACKAGE_VERSION}.zip"
# https://docs.gitlab.com/ee/ci/runners/hosted_runners/macos.html#optimizing-homebrew
HOMEBREW_NO_AUTO_UPDATE: 1
#CI_DEBUG_TRACE: "true"
# global workflow:rules:variables can change variables outside of jobs
workflow:
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH == "dev"
# if the pipeline is executing because of a tag, then change the variables for a
- if: $CI_COMMIT_TAG
variables:
PACKAGE_VERSION: $CI_COMMIT_TAG
LINUX_AMD64_TGZ: "Tnn-miner-amd64-${PACKAGE_VERSION}.tar.gz"
LINUX_ARM64_TGZ: "Tnn-miner-arm64-${PACKAGE_VERSION}.tar.gz"
MACOS_ARM64_TGZ: "Tnn-miner-macos-arm64-${PACKAGE_VERSION}.tar.gz"
WRAPPER_TEMP: "wrapper.tar.gz"
WIN_AMD64_ZIP: "Tnn-miner-win64-${PACKAGE_VERSION}.zip"
.macos_saas_runners:
tags:
- saas-macos-medium-m1
image: macos-14-xcode-15
before_script:
- echo "started by ${GITLAB_USER_NAME} / @${GITLAB_USER_LOGIN}"
- which clang
#- brew install clang
#- brew install fmt
- brew install cmake
.windows_job:
tags:
- saas-windows-medium-amd64
before_script:
- Set-Variable -Name "time" -Value (date -Format "%H:%m")
- echo ${time}
- echo "started by ${GITLAB_USER_NAME} / @${GITLAB_USER_LOGIN}"
build-linux-amd64:
image: docker:24.0.5
stage: build
tags:
- linux
- amd64
before_script:
- until docker info; do sleep 1; done
script:
- docker buildx build --platform=linux/amd64 --build-arg PACKAGE_VERSION=${PACKAGE_VERSION} --build-arg TARGZ_FILE=${LINUX_AMD64_TGZ} --build-arg CMAKE_ARGS=${CMAKE_ARGS} -f docker/Dockerfile.ubu . --output ./
- export HIVEOS_MMPOS_AMD64_TGZ="tnn-miner-hiveos_mmpos_amd64_${PACKAGE_VERSION//-/.}.tar.gz"
- echo "HIVEOS_MMPOS_AMD64_TGZ=$HIVEOS_MMPOS_AMD64_TGZ" >> linux-amd64-job.env
after_script:
- echo "LINUX_AMD64_BUILD_JOB_ID=$CI_JOB_ID" >> linux-amd64-job.env
artifacts:
name: ${LINUX_AMD64_TGZ}
paths:
- ${LINUX_AMD64_TGZ}
reports:
dotenv: linux-amd64-job.env
services:
- name: docker:24.0.5-dind
build-hiveos-mmpos:
needs:
- build-linux-amd64
script:
- tar -xvf ${LINUX_AMD64_TGZ}
- mv ./tnn-miner-cpu ./wrappers/hiveos+mmpos/tnn-miner/tnn-miner
- sed "s/^EXTERNAL_VERSION=custom/EXTERNAL_VERSION=$PACKAGE_VERSION/g" -i ./wrappers/hiveos+mmpos/tnn-miner/mmp-external.conf
- chmod +x ./wrappers/hiveos+mmpos/tnn-miner/tnn-miner
- chmod +x ./wrappers/hiveos+mmpos/tnn-miner/h-run.sh
- chmod +x ./wrappers/hiveos+mmpos/tnn-miner/h-stats.sh
- chmod +x ./wrappers/hiveos+mmpos/tnn-miner/mmp-stats.sh
- tar -czvf ${HIVEOS_MMPOS_AMD64_TGZ} -C ./wrappers/hiveos+mmpos/ tnn-miner
after_script:
- echo "HIVEOS_MMPOS_BUILD_JOB_ID=$CI_JOB_ID" >> hiveos-job.env
artifacts:
name: ${HIVEOS_MMPOS_AMD64_TGZ}
paths:
- ${HIVEOS_MMPOS_AMD64_TGZ}
# depending on your build setup it's most likely a good idea to cache outputs to reduce the build time
# cache:
# paths:
reports:
dotenv: hiveos-job.env
build-macos:
rules:
- if: $CI_COMMIT_TAG && $TNN_BUILD_MAC == "true" # Run this job when a tag is created
extends:
- .macos_saas_runners
stage: build
script:
- export
- mkdir ./build
- cd ./build
- cmake -DTNN_VERSION=$PACKAGE_VERSION ..
- make -j$(nproc)
- cd ../
- mv ./build/Tnn-miner-cpu ./Tnn-miner
- ls -la ./
- ls -la ./build/
- tar -czvf Tnn-miner-macos-arm64.tar.gz ./Tnn-miner
after_script:
- pwd
- ls -la ./
- echo "MACOS_BUILD_JOB_ID=$CI_JOB_ID" >> macos-job.env
artifacts:
name: Tnn-miner-macos-arm64.tar.gz
paths:
- Tnn-miner-macos-arm64.tar.gz
reports:
dotenv: macos-job.env
build-windows:
rules:
- if: $CI_COMMIT_TAG || ($TNN_BUILD_WIN == "true" && $CI_COMMIT_MESSAGE =~ /windows\|Windows/) # Run this job when a tag is created
extends:
- .windows_job
stage: build
script:
- echo "running scripts in the build job"
- $PSVersionTable.PSVersion
- .\scripts\prereqs.bat ci
- .\scripts\build.ps1 $PACKAGE_VERSION
- dir .\build\
- dir .\build\bin\
- move build\bin\tnn-miner-cpu.exe .\
- Compress-Archive -Path tnn-miner-cpu.exe -DestinationPath ${WIN_AMD64_ZIP}
#- 7z.exe a ${WIN_AMD64_ZIP} tnn-miner-cpu.exe
after_script:
- echo "WIN_BUILD_JOB_ID=$CI_JOB_ID" >> win-job.env
artifacts:
name: ${WIN_AMD64_ZIP}
paths:
- ${WIN_AMD64_ZIP}
reports:
dotenv: win-job.env
build-linux-aarch64:
image: docker:24.0.5
stage: build
tags:
- linux
- aarch64
before_script:
- until docker info; do sleep 1; done
script:
- docker buildx ls
- docker buildx build --platform=linux/arm64 --build-arg PACKAGE_VERSION=${PACKAGE_VERSION} --build-arg TARGZ_FILE=${LINUX_ARM64_TGZ} --build-arg CMAKE_ARGS=${CMAKE_ARGS} -f docker/Dockerfile.ubu . --output ./
after_script:
- echo "LINUX_ARM64_BUILD_JOB_ID=$CI_JOB_ID" >> linux-arm64-job.env
artifacts:
name: ${LINUX_ARM64_TGZ}
paths:
- ${LINUX_ARM64_TGZ}
reports:
dotenv: linux-arm64-job.env
services:
- name: docker:24.0.5-dind
# run tests using the binary built before
test-linux-amd64:
#rules:
# - if: $CI_COMMIT_TAG # Run this job when a tag is created
stage: test
needs:
- job: build-linux-amd64
artifacts: true
tags:
- linux
- amd64
before_script:
- ls -la ./
script:
- tar -xvf ./${LINUX_AMD64_TGZ}
- ./tnn-miner-cpu --test-dero --quiet
- ./tnn-miner-cpu --test-spectre --quiet
- ./tnn-miner-cpu --test-xelis --quiet
# run tests using the binary built before
test-linux-aarch64:
#rules:
# - if: $CI_COMMIT_TAG # Run this job when a tag is created
stage: test
needs:
- job: build-linux-aarch64
artifacts: true
tags:
- linux
- aarch64
before_script:
- ls -la ./
script:
- tar -xvf ./${LINUX_ARM64_TGZ}
- ./tnn-miner-cpu --test-dero --quiet
- ./tnn-miner-cpu --test-spectre --quiet
- ./tnn-miner-cpu --test-xelis --quiet
# TODO install gdb instead of running prereqs
# test-windows:
# rules:
# - if: $CI_COMMIT_TAG && $TNN_BUILD_WIN == "true" # Run this job when a tag is created
# extends:
# - .windows_job
# stage: test
# needs:
# - job: build-windows
# artifacts: true
# script:
# - $PSVersionTable.PSVersion
# - .\scripts\prereqs.bat ci
# - 7z.exe x ${WIN_AMD64_ZIP}
# - gdb --return-child-result --batch -ex "run" -ex "bt" -ex "cont" -ex "exit" --args Tnn-miner --test-dero --quiet
# - gdb --return-child-result --batch -ex "run" -ex "bt" -ex "cont" -ex "exit" --args Tnn-miner --test-spectre --quiet
# - gdb --return-child-result --batch -ex "run" -ex "bt" -ex "cont" -ex "exit" --args Tnn-miner --test-xelis --quiet
#upload:
# stage: upload
# image: curlimages/curl:latest
# rules:
# - if: $CI_COMMIT_TAG
# script:
# - ls -la
# #- |
# # curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${DARWIN_AMD64_BINARY} "${PACKAGE_REGISTRY_URL}/${DARWIN_AMD64_BINARY}"
# - |
# curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${LINUX_AMD64_BINARY} "${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}"
# dependencies:
# - "build"
# https://stackoverflow.com/a/67583488
release_job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: build-linux-amd64
artifacts: true
- job: build-linux-aarch64
artifacts: true
- job: build-hiveos-mmpos
artifacts: true
- job: build-windows
artifacts: true
#- job: build-macos
# artifacts: true
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
script:
- ls -la
- echo $LINUX_AMD64_BUILD_JOB_ID
- echo $LINUX_ARM64_BUILD_JOB_ID
- echo $HIVEOS_MMPOS_BUILD_JOB_ID
- echo $MACOS_BUILD_JOB_ID
- echo $WIN_BUILD_JOB_ID
#- |
# release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
# --assets-link "{\"name\":\"${LINUX_AMD64_BINARY}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}\"}"
release:
name: 'Release $CI_COMMIT_TAG'
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
description: 'Release $CI_COMMIT_TAG'
assets:
links:
- name: "${LINUX_AMD64_TGZ}"
url: "https://gitlab.com/${CI_PROJECT_PATH}/-/jobs/${LINUX_AMD64_BUILD_JOB_ID}/artifacts/raw/${LINUX_AMD64_TGZ}"
filepath: "/${LINUX_AMD64_TGZ}"
- name: "${LINUX_ARM64_TGZ}"
url: "https://gitlab.com/${CI_PROJECT_PATH}/-/jobs/${LINUX_ARM64_BUILD_JOB_ID}/artifacts/raw/${LINUX_ARM64_TGZ}"
filepath: "/${LINUX_ARM64_TGZ}"
- name: "${HIVEOS_MMPOS_AMD64_TGZ}"
url: "https://gitlab.com/${CI_PROJECT_PATH}/-/jobs/${HIVEOS_MMPOS_BUILD_JOB_ID}/artifacts/raw/${HIVEOS_MMPOS_AMD64_TGZ}"
filepath: "/${HIVEOS_MMPOS_AMD64_TGZ}"
- name: "${WIN_AMD64_ZIP}"
url: "https://gitlab.com/${CI_PROJECT_PATH}/-/jobs/${WIN_BUILD_JOB_ID}/artifacts/raw/${WIN_AMD64_ZIP}"
filepath: "/${WIN_AMD64_ZIP}"
#- name: "${MACOS_ARM64_TGZ}"
# url: "https://gitlab.com/${CI_PROJECT_PATH}/-/jobs/${MACOS_BUILD_JOB_ID}/artifacts/raw/${MACOS_ARM64_TGZ}"
# filepath: "/${MACOS_ARM64_TGZ}"