-
Notifications
You must be signed in to change notification settings - Fork 1.2k
336 lines (295 loc) · 12.9 KB
/
linux_arm64.yml
File metadata and controls
336 lines (295 loc) · 12.9 KB
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
name: Linux (Arm64)
on:
release:
types: [created]
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "tools/**"
- ".vscode/**"
- ".devcontainer/**"
- ".github/**"
- "!.github/workflows/linux_arm64.yml"
- "core/src/ten_manager/designer_frontend/**"
- "**.md"
- "ai_agents/**"
permissions:
contents: write
discussions: write
security-events: write
concurrency:
group: linux-arm64-${{ github.head_ref }}
cancel-in-progress: true
jobs:
call-check-pr-status:
uses: ./.github/workflows/_check_pr_status.yml
build:
needs: call-check-pr-status
if: ${{ needs.call-check-pr-status.outputs.should_continue == 'true' }}
runs-on: ubuntu-24.04-arm
strategy:
matrix:
compiler: [gcc]
build_type: [release]
steps:
- name: Check PR status before matrix execution
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log('Event name:', context.eventName);
console.log('Matrix:', ${{ toJson(matrix) }});
// Only check for PR events
if (context.eventName !== 'pull_request') {
console.log('Not a PR event, continuing...');
return;
}
// Ensure we have PR data
if (!context.payload.pull_request) {
console.log('No pull_request data in payload, continuing...');
return;
}
const { owner, repo } = context.repo;
const prNumber = context.payload.pull_request.number;
try {
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: prNumber,
});
console.log(`PR #${prNumber} state: ${pr.data.state}, merged: ${pr.data.merged}`);
if (pr.data.state === 'closed') {
if (pr.data.merged) {
console.log(`PR #${prNumber} has been merged. Stopping matrix execution.`);
core.setFailed('PR has been merged, stopping execution to save resources.');
} else {
console.log(`PR #${prNumber} has been closed. Stopping matrix execution.`);
core.setFailed('PR has been closed, stopping execution to save resources.');
}
} else {
console.log(`PR #${prNumber} is still open. Continuing matrix execution.`);
}
} catch (error) {
console.error(`Error checking PR status: ${error.message}`);
console.log('Error details:', error);
console.log('Continuing matrix execution due to error...');
}
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
- name: Trust working directory
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Initialize and update submodules except portal/
run: |
# Retrieve all submodule paths, excluding `portal/`.
submodules=$(git config --file .gitmodules --get-regexp path | awk '$2 != "portal" { print $2 }')
git submodule init
for submodule in $submodules; do
echo "Initializing submodule: $submodule"
git submodule update --init --recursive --depth 1 "$submodule"
done
- name: Update version
run: |
python3 tools/version/update_version_in_ten_framework.py
python3 tools/version/check_version_in_ten_framework.py
- name: Build
run: |
export PATH=$(pwd)/core/ten_gn:/usr/local/go/bin:/root/go/bin:/root/.cargo/bin:$PATH
echo $PATH
go env -w GOFLAGS="-buildvcs=false"
go install golang.org/dl/go1.24.3@latest
export PATH=$PATH:$(go env GOPATH)/bin
go1.24.3 download
go1.24.3 version
sudo apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_23.x -o nodesource_setup.sh
bash nodesource_setup.sh
sudo apt-get install -y nodejs
rustup default nightly-2025-09-18
pip3 install --use-pep517 python-dotenv jinja2
df -h .
tgn gen linux arm64 ${{ matrix.build_type }} -- is_clang=${{ matrix.compiler == 'gcc' && 'false' || 'true' }} log_level=1 enable_serialized_actions=true ten_enable_tests=false ten_rust_enable_tests=false ten_manager_enable_tests=false ten_enable_libwebsockets=false ten_enable_cargo_clean=true ten_enable_rust_incremental_build=false ten_manager_enable_frontend=false
tgn build linux arm64 ${{ matrix.build_type }}
df -h .
tree -I 'gen|obj' out
- name: Fix permissions for build outputs
run: |
sudo chown -R "$(id -u)":"$(id -g)" out/linux/arm64
shell: bash
- name: Update supports before upload or publish
continue-on-error: true
run: |
UPDATE_SUPPORTS_SCRIPT=$(pwd)/tools/supports/update_supports_in_manifest_json.py
cd out/linux/arm64/ten_packages
ARRAY=(
"system/ten_runtime"
"system/ten_runtime_go"
"system/ten_runtime_python"
"system/ten_runtime_nodejs"
"addon_loader/python_addon_loader"
"addon_loader/nodejs_addon_loader"
)
for item in "${ARRAY[@]}"; do
echo "Processing item: $item"
if python3 ${UPDATE_SUPPORTS_SCRIPT} --os-arch-pairs linux:arm64 --input-file ${item}/manifest.json --output-file ${item}/manifest.json --log-level 1; then
echo "✓ Successfully updated supports for $item"
cat ${item}/manifest.json
else
echo "✗ Failed to update supports for $item, continuing with next item..."
fi
done
df -h .
shell: bash
- name: Upload tman
uses: actions/upload-artifact@v4
with:
name: tman-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}
path: out/linux/arm64/ten_manager/bin/tman
- name: Upload ten_packages
uses: actions/upload-artifact@v4
with:
name: ten_packages-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}
path: |
out/linux/arm64/ten_packages/system/ten_runtime
out/linux/arm64/ten_packages/system/ten_runtime_go
out/linux/arm64/ten_packages/system/ten_runtime_python
out/linux/arm64/ten_packages/extension/default_extension_cpp
out/linux/arm64/ten_packages/extension/default_extension_go
out/linux/arm64/ten_packages/extension/default_extension_python
out/linux/arm64/ten_packages/extension/default_async_extension_python
out/linux/arm64/ten_packages/addon_loader/python_addon_loader
- name: Package assets
if: github.event_name == 'release' || (github.ref != '' && startsWith(github.ref, 'refs/tags/'))
continue-on-error: true
run: |
cd out/linux/arm64
# Define array of platform-specific packages to package
# (apps and extensions are platform-independent and handled in linux_ubuntu2204.yml)
FILES_TO_PACKAGE=(
"ten_packages/system/ten_runtime"
"ten_packages/system/ten_runtime_go"
"ten_packages/system/ten_runtime_python"
"ten_packages/system/ten_runtime_nodejs"
"ten_packages/addon_loader/python_addon_loader"
"ten_packages/addon_loader/nodejs_addon_loader"
)
# Create zip archive with existing files only
EXISTING_FILES=()
for file in "${FILES_TO_PACKAGE[@]}"; do
if [ -e "$file" ]; then
EXISTING_FILES+=("$file")
echo "✓ Found: $file"
else
echo "✗ Missing: $file (will be skipped)"
fi
done
if [ ${#EXISTING_FILES[@]} -gt 0 ]; then
echo "Creating zip archive with ${#EXISTING_FILES[@]} items..."
zip -vr ten_packages-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}.zip "${EXISTING_FILES[@]}" || {
echo "Warning: zip command failed, but continuing..."
}
else
echo "Warning: No files found to package"
fi
df -h .
shell: bash
- name: Publish to release assets
uses: softprops/action-gh-release@v2
if: github.event_name == 'release' || (github.ref != '' && startsWith(github.ref, 'refs/tags/'))
with:
tag_name: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
files: |
out/linux/arm64/ten_packages-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}.zip
- name: Clean up
if: github.event_name == 'release' || (github.ref != '' && startsWith(github.ref, 'refs/tags/'))
continue-on-error: true
run: |
rm -rf out/linux/arm64/ten_packages-linux-arm64-${{ matrix.compiler }}-${{ matrix.build_type }}.zip
df -h .
- name: Publish release to TEN cloud store
if: ${{ (github.event_name == 'release' || (github.ref != '' && startsWith(github.ref, 'refs/tags/'))) && matrix.compiler == 'gcc' && matrix.build_type == 'release' }}
continue-on-error: true
run: |
set -x
TMAN_BIN=$(pwd)/out/linux/arm64/ten_manager/bin/tman
cd out/linux/arm64
ARRAY=(
"ten_packages/system/ten_runtime"
"ten_packages/system/ten_runtime_go"
"ten_packages/system/ten_runtime_python"
"ten_packages/system/ten_runtime_nodejs"
"ten_packages/addon_loader/python_addon_loader"
"ten_packages/addon_loader/nodejs_addon_loader"
)
SUCCESSFUL_PUBLISHES=0
FAILED_PUBLISHES=0
for item in "${ARRAY[@]}"; do
echo "Processing: $item"
if [ ! -d "$item" ]; then
echo "✗ Directory not found: $item, skipping..."
FAILED_PUBLISHES=$((FAILED_PUBLISHES + 1))
continue
fi
cd "$item" || {
echo "✗ Failed to enter directory: $item, skipping..."
FAILED_PUBLISHES=$((FAILED_PUBLISHES + 1))
continue
}
if identity=$("$TMAN_BIN" package --get-identity 2>/dev/null); then
echo "Identity: $identity"
echo "Attempting to delete existing package..."
read -r pkg_type pkg_name pkg_version pkg_hash <<< "$identity"
"$TMAN_BIN" --verbose --admin-token '${{ secrets.TEN_CLOUD_STORE_ADMIN_TOKEN }}' delete "$pkg_type" "$pkg_name" "$pkg_version" "$pkg_hash" || {
echo "Warning: Failed to delete existing package (this is normal if package doesn't exist)"
}
echo "Attempting to publish package..."
if "$TMAN_BIN" --verbose --user-token '${{ secrets.TEN_CLOUD_STORE }}' publish; then
echo "✓ Successfully published: $item"
SUCCESSFUL_PUBLISHES=$((SUCCESSFUL_PUBLISHES + 1))
else
echo "✗ Failed to publish: $item"
FAILED_PUBLISHES=$((FAILED_PUBLISHES + 1))
fi
else
echo "✗ Failed to get identity for: $item"
FAILED_PUBLISHES=$((FAILED_PUBLISHES + 1))
fi
cd - >/dev/null
done
echo "Publication summary: $SUCCESSFUL_PUBLISHES successful, $FAILED_PUBLISHES failed"
df -h .
shell: bash
- name: Clean up
if: ${{ (github.event_name == 'release' || (github.ref != '' && startsWith(github.ref, 'refs/tags/'))) && matrix.compiler == 'gcc' && matrix.build_type == 'release' }}
continue-on-error: true
run: |
cd out/linux/arm64
ARRAY=(
"ten_packages/system/ten_runtime"
"ten_packages/system/ten_runtime_go"
"ten_packages/system/ten_runtime_python"
"ten_packages/system/ten_runtime_nodejs"
"ten_packages/addon_loader/python_addon_loader"
"ten_packages/addon_loader/nodejs_addon_loader"
)
SUCCESSFUL_CLEANUPS=0
FAILED_CLEANUPS=0
for item in "${ARRAY[@]}"; do
echo "Cleaning up: $item"
if [ -e "$item" ]; then
if rm -rf "$item"; then
echo "✓ Successfully removed: $item"
SUCCESSFUL_CLEANUPS=$((SUCCESSFUL_CLEANUPS + 1))
else
echo "✗ Failed to remove: $item"
FAILED_CLEANUPS=$((FAILED_CLEANUPS + 1))
fi
else
echo "• Already absent: $item"
SUCCESSFUL_CLEANUPS=$((SUCCESSFUL_CLEANUPS + 1))
fi
done
echo "Cleanup summary: $SUCCESSFUL_CLEANUPS successful, $FAILED_CLEANUPS failed"
df -h .
shell: bash