Skip to content

Commit 41ebd5e

Browse files
authored
[action/ci] 把每次编译结果上传到github
1 parent cdb5ce8 commit 41ebd5e

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

.github/workflows/bsp_buildings.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
#
2+
# Copyright (c) 2025, RT-Thread Development Team
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Change Logs:
7+
# Date Author Notes
8+
# 2025-03-22 Supperthomas 添加upload 上传编译固件
9+
#
110
name: RT-Thread BSP Static Build Check
211

312
# Controls when the action will run. Triggers the workflow on push or pull request
@@ -536,6 +545,14 @@ jobs:
536545
source ~/.env/env.sh
537546
python tools/ci/bsp_buildings.py
538547
548+
- name: Upload output as artifact
549+
if: ${{ success() }}
550+
uses: actions/upload-artifact@main
551+
with:
552+
name: ${{ matrix.legs.RTT_BSP }}
553+
if-no-files-found: ignore
554+
path: output/
555+
539556
- name: Post failure comment
540557
if: failure()
541558
run: |

tools/ci/bsp_buildings.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run_cmd(cmd, output_info=True):
3636
return output_str_list, res
3737

3838

39-
def build_bsp(bsp, scons_args=''):
39+
def build_bsp(bsp, scons_args='',name='default'):
4040
"""
4141
build bsp.
4242
@@ -72,13 +72,17 @@ def build_bsp(bsp, scons_args=''):
7272

7373
if res != 0:
7474
success = False
75+
#拷贝当前的文件夹下面的所有以elf结尾的文件拷贝到rt-thread/output文件夹下
76+
import glob
77+
# 拷贝编译生成的文件到output目录,文件拓展为 elf,bin,hex
78+
for file_type in ['*.elf', '*.bin', '*.hex']:
79+
files = glob.glob(f'{rtt_root}/bsp/{bsp}/{file_type}')
80+
for file in files:
81+
shutil.copy(file, f'{rtt_root}/output/bsp/{bsp}/{name}.{file_type[2:]}')
7582

7683
os.chdir(f'{rtt_root}/bsp/{bsp}')
7784
run_cmd('scons -c', output_info=False)
7885

79-
#pkg_dir = os.path.join(rtt_root, 'bsp', bsp, 'packages')
80-
#shutil.rmtree(pkg_dir, ignore_errors=True)
81-
8286
return success
8387

8488

@@ -145,7 +149,7 @@ def build_bsp_attachconfig(bsp, attach_file):
145149

146150
scons_args = check_scons_args(attach_path)
147151

148-
res = build_bsp(bsp, scons_args)
152+
res = build_bsp(bsp, scons_args,name=attach_file.tostring())
149153

150154
shutil.copyfile(config_bacakup, config_file)
151155
os.remove(config_bacakup)
@@ -220,7 +224,7 @@ def build_bsp_attachconfig(bsp, attach_file):
220224
scons_arg.append(line)
221225
scons_arg_str=' '.join(scons_arg) if scons_arg else ' '
222226
print(f"::group::\tCompiling yml project: =={count}==={name}=scons_arg={scons_arg_str}==")
223-
res = build_bsp(bsp, scons_arg_str)
227+
res = build_bsp(bsp, scons_arg_str,name=name)
224228
if not res:
225229
print(f"::error::build {bsp} {name} failed.")
226230
add_summary(f'\t- ❌ build {bsp} {name} failed.')

0 commit comments

Comments
 (0)