-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0083-ci-add-.gitlab-ci.yml-to-support-CI-CD.patch
214 lines (211 loc) · 6.61 KB
/
0083-ci-add-.gitlab-ci.yml-to-support-CI-CD.patch
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
From d3a27ac35c1ef111b9e91ee86a7647c7e8c5d72c Mon Sep 17 00:00:00 2001
From: Andrei Safronov <safronov@espressif.com>
Date: Wed, 5 Apr 2023 00:59:20 +0300
Subject: [PATCH 083/158] ci: add .gitlab-ci.yml to support CI/CD
---
.gitlab-ci.yml | 195 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 195 insertions(+)
create mode 100644 .gitlab-ci.yml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 000000000000..94f59533db5a
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,195 @@
+stages:
+ - build
+ - private_deploy
+ - test
+ - public_deploy
+
+image: ${CI_DOCKER_REGISTRY}/llvm-build:3
+
+variables:
+
+ CONF_TARGET: "xtensa-esp32-elf"
+ XTENSA_CLANG_TOOLCHAIN: "${CONF_TARGET}-clang"
+ PLATFORM_NAME_LINUX: "linux-amd64"
+ PLATFORM_NAME_WIN: "win64"
+ PLATFORM_NAME_MACOS: "macos"
+
+ XTENSA_CLANG_TOOLCHAIN_BRANCH: "esp-20220415-r14.0.0"
+ GCC_REL_NAME: "gcc8_4_0-esp-2021r2-patch3"
+
+ ARCHIVE_TOOL_LINUX: "tar -cJf"
+ UNARCHIVE_TOOL_LINUX: "tar -xf"
+ ARCHIVE_EXT_LINUX: "tar.xz"
+
+ ARCHIVE_TOOL_WIN: "zip -9 -r"
+ UNARCHIVE_TOOL_WIN: "unzip"
+ ARCHIVE_EXT_WIN: "zip"
+
+ ARCHIVE_TOOL_MACOS: "tar -cJf"
+ UNARCHIVE_TOOL_MACOS: "tar -xf"
+ ARCHIVE_EXT_MACOS: "tar.xz"
+
+ DIST_DIR: "dist"
+
+.use_ci_tools: &use_ci_tools |
+ curl -sSL ${CIT_LOADER_URL} -o cit_loader.sh && sh cit_loader.sh
+ source citools/import_functions
+
+.add_gitlab_key: &add_gitlab_key |
+ cit_add_ssh_key "${GITLAB_KEY}"
+
+before_script:
+ - *use_ci_tools
+ - *add_gitlab_key
+
+# Prepare release name/number
+.get_release_name: &get_release_name |
+ # using annotated tags
+ REL_NUM=$(git describe --abbrev=7)
+ REL_SFX="llvm14_0_0"
+ REL_NAME=${CONF_TARGET}-${REL_SFX}-${REL_NUM}-${PLATFORM_NAME}
+ ARCHIVE_NAME=${REL_NAME}.${ARCHIVE_EXT}
+ echo "CONF_TARGET: $CONF_TARGET"
+ echo "PLATFORM_NAME: $PLATFORM_NAME"
+ echo "REL_NUM: $REL_NUM"
+ echo "REL_NAME: $REL_NAME"
+ echo "ARCHIVE_NAME: $ARCHIVE_NAME"
+
+# Get an existing crosstool-ng build for esp32
+.get_gcc_toolchain: &get_gcc_toolchain |
+ wget --no-verbose https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/esp-2021r2-patch3/${XTENSA_GCC_TOOLCHAIN}
+ ${UNARCHIVE_TOOL} ${XTENSA_GCC_TOOLCHAIN}
+ mv xtensa-esp32-elf ${XTENSA_CLANG_TOOLCHAIN}
+
+.get_clang_toolchain_build_scripts: &get_clang_toolchain_build_scripts |
+ git clone -b ${XTENSA_CLANG_TOOLCHAIN_BRANCH} ${GITLAB_SSH_SERVER}/${XTENSA_CLANG_TOOLCHAIN_REPO}
+ cp -r xtensa-clang-toolchain/* .
+
+# LLVM Build System used the remote address to show detailed version info, we'll change it to the public repository
+.fix_origin_remote_for_public: &fix_origin_remote_for_public |
+ git remote set-url origin "${GH_REPO_HTTPS}"
+
+ # Pack the toolchain
+.package_toolchain: &package_toolchain |
+ ${ARCHIVE_TOOL} ${ARCHIVE_NAME} ${XTENSA_CLANG_TOOLCHAIN}/
+ mkdir -p ${DIST_DIR}
+ mv ${ARCHIVE_NAME} ${DIST_DIR}/
+ echo "${ARCHIVE_NAME}" > ${DIST_DIR}/file_${PLATFORM_NAME}_${CONF_TARGET}
+
+.build_template:
+ stage: build
+ tags: [ "amd64", "build" ]
+ artifacts:
+ paths:
+ - ${DIST_DIR}/
+ when: always
+ expire_in: 10 day
+ script:
+ - *get_release_name
+ - *get_gcc_toolchain
+ - *fix_origin_remote_for_public
+ - *get_clang_toolchain_build_scripts
+ - ${BUILD_TOOLCHAIN_CMD} "${XTENSA_CLANG_TOOLCHAIN}"
+ - *package_toolchain
+
+linux_amd64_build:
+ extends: .build_template
+ variables:
+ PLATFORM_NAME: "${PLATFORM_NAME_LINUX}"
+ ARCHIVE_TOOL: "${ARCHIVE_TOOL_LINUX}"
+ UNARCHIVE_TOOL: "${UNARCHIVE_TOOL_LINUX}"
+ ARCHIVE_EXT: "${ARCHIVE_EXT_LINUX}"
+ # a filename was moved here from the global 'variables:' because of GCC_REL_NAME value couldn't be expanded and substituted there
+ XTENSA_GCC_TOOLCHAIN: "xtensa-esp32-elf-${GCC_REL_NAME}-linux-amd64.tar.gz"
+ BUILD_TOOLCHAIN_CMD: "./build-toolchain-linux.sh"
+
+win64_build:
+ extends: .build_template
+ variables:
+ PLATFORM_NAME: "${PLATFORM_NAME_WIN}"
+ ARCHIVE_TOOL: "${ARCHIVE_TOOL_WIN}"
+ UNARCHIVE_TOOL: "${UNARCHIVE_TOOL_WIN}"
+ ARCHIVE_EXT: "${ARCHIVE_EXT_WIN}"
+ XTENSA_GCC_TOOLCHAIN: "xtensa-esp32-elf-${GCC_REL_NAME}-win64.zip"
+ BUILD_TOOLCHAIN_CMD: "./build-toolchain-win.sh"
+
+macos_amd64_build:
+ extends: .build_template
+ variables:
+ PLATFORM_NAME: "${PLATFORM_NAME_MACOS}"
+ ARCHIVE_TOOL: "${ARCHIVE_TOOL_MACOS}"
+ UNARCHIVE_TOOL: "${UNARCHIVE_TOOL_MACOS}"
+ ARCHIVE_EXT: "${ARCHIVE_EXT_MACOS}"
+ XTENSA_GCC_TOOLCHAIN: "xtensa-esp32-elf-${GCC_REL_NAME}-macos.tar.gz"
+ BUILD_TOOLCHAIN_CMD: "./build-toolchain-macos.sh"
+
+linux_amd64_testsuite:
+ stage: test
+ tags: [ "amd64", "build" ]
+ dependencies:
+ - linux_amd64_build
+ variables:
+ PLATFORM_NAME: "${PLATFORM_NAME_LINUX}"
+ ARCHIVE_TOOL: "${ARCHIVE_TOOL_LINUX}"
+ UNARCHIVE_TOOL: "${UNARCHIVE_TOOL_LINUX}"
+ ARCHIVE_EXT: "${ARCHIVE_EXT_LINUX}"
+ script:
+ - *get_release_name
+ - ${UNARCHIVE_TOOL} ${DIST_DIR}/${ARCHIVE_NAME}
+
+ # getting testsuit
+ - git clone -b feature/ci_llvm_multitarget --depth 1 $GITLAB_SSH_SERVER/idf/llvm-xtensa-testsuite.git
+
+ # preparing testsuit
+ - export PATH=$PATH:${PWD}/${XTENSA_CLANG_TOOLCHAIN}/bin/
+ - cd llvm-xtensa-testsuite
+
+ # qemu
+ - ./qemu_esp32_install.sh
+
+ # run testsuite for esp32
+ - ./run_esp32_tests.sh
+
+upload_to_http:
+ stage: private_deploy
+ when: manual
+ allow_failure: true
+ tags: [ "deploy", "shiny" ]
+ variables:
+ # force the fetch strategy to clean old archives up in dist/ dir
+ GIT_STRATEGY: fetch
+ before_script:
+ - *use_ci_tools
+ script:
+ - cit_add_ssh_key "${HTTP_UPLOAD_KEY}"
+ # List of archives
+ - FILES=$(find ${DIST_DIR} -name file_\* -exec cat {} \+)
+ - cd ${DIST_DIR}
+ - scp ${FILES} ${HTTP_UPLOAD_DIR}/ct-ng/llvm-builds
+ # Show info
+ - echo -e "\nArchives were published there:\n\n$(for n in ${FILES}; do echo "${HTTP_PUBLIC_DIR}/ct-ng/llvm-builds/${n}"; done)\n"
+
+upload_to_github:
+ stage: public_deploy
+ when: manual
+ allow_failure: true
+ only:
+ - tags
+ tags: [ "amd64", "internet" ]
+ image: espressif/github-hub:2
+ variables:
+ GIT_STRATEGY: fetch
+ GITHUB_TOKEN: "${GH_TOKEN}"
+ GITHUB_REPO: "${GH_REPO_HTTPS}"
+ TAG: "${CI_COMMIT_TAG}"
+ before_script: []
+ script:
+ - ls -l dist*/
+ - git remote add github ${GH_REPO_HTTPS}
+ - hub release show ${TAG} || { echo "Please create a release on GitHub with ${TAG} tag at first"; exit 1; }
+ # List of archives
+ - FILES=$(find ${DIST_DIR} -name file_\* -exec cat {} \+)
+ - cd ${DIST_DIR}
+ - ls -l $FILES
+ # Upload archives
+ - for n in ${FILES}; do hub release edit -m "" -a "${n}" "${TAG}"; done
--
2.40.1