From 96165a5e99c533b660b42be115f83b696361017a Mon Sep 17 00:00:00 2001 From: Supper Thomas <78900636@qq.com> Date: Tue, 5 Nov 2024 11:01:30 +0800 Subject: [PATCH] [action] add the yml file support --- .github/workflows/bsp_buildings.yml | 2 +- .../.ci/attachconfig/ci.attachconfig.yml | 36 +++++++++++++++ .../.ci/attachconfig/devices/adc.attach | 1 - .../.ci/attachconfig/devices/flash.attach | 1 - .../.ci/attachconfig/devices/gpio.attach | 1 - .../.ci/attachconfig/devices/hwtimer.attach | 2 - .../.ci/attachconfig/devices/i2c.attach | 1 - .../.ci/attachconfig/devices/pwm.attach | 1 - .../attachconfig/devices/qspi_flash.attach | 1 - .../.ci/attachconfig/devices/rtc.attach | 1 - .../.ci/attachconfig/devices/spi.attach | 1 - .../.ci/attachconfig/devices/uart.attach | 1 - .../.ci/attachconfig/devices/wdt.attach | 1 - tools/ci/bsp_buildings.py | 45 +++++++++++++++++-- tools/ci/requirements.txt | 2 + 15 files changed, 80 insertions(+), 17 deletions(-) create mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/ci.attachconfig.yml delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/adc.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/flash.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/gpio.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/hwtimer.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/i2c.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/pwm.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/qspi_flash.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/rtc.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/spi.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/uart.attach delete mode 100644 bsp/nrf5x/nrf52840/.ci/attachconfig/devices/wdt.attach create mode 100644 tools/ci/requirements.txt diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index 6e13876ac9..f769bdf27d 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -390,7 +390,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@main with: python-version: 3.8 diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/ci.attachconfig.yml b/bsp/nrf5x/nrf52840/.ci/attachconfig/ci.attachconfig.yml new file mode 100644 index 0000000000..650a97c929 --- /dev/null +++ b/bsp/nrf5x/nrf52840/.ci/attachconfig/ci.attachconfig.yml @@ -0,0 +1,36 @@ +devices.gpio: + kconfig: + - CONFIG_BSP_USING_GPIO=y + scons_arg: + - '--strict' +devices.adc: + kconfig: + - CONFIG_BSP_USING_SAADC=y +devices.flash: + kconfig: + - CONFIG_BSP_USING_ON_CHIP_FLASH=y +devices.i2c: + kconfig: + - CONFIG_BSP_USING_I2C=y +devices.spi: + kconfig: + - CONFIG_BSP_USING_SPI=y +devices.uart: + kconfig: + - CONFIG_BSP_USING_UART=y +devices.watchdog: + kconfig: + - CONFIG_BSP_USING_WDT=y +devices.qspi_flash: + kconfig: + - CONFIG_BSP_USING_QSPI_FLASH=y +devices.pwm: + kconfig: + - CONFIG_BSP_USING_PWM=y +devices.rtc: + kconfig: + - CONFIG_BSP_USING_ONCHIP_RTC=y +devices.hwtimer: + kconfig: + - CONFIG_BSP_USING_TIM=y + - CONFIG_BSP_USING_TIM0=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/adc.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/adc.attach deleted file mode 100644 index fb17a1d885..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/adc.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_SAADC=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/flash.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/flash.attach deleted file mode 100644 index 5c49eb48fc..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/flash.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_ON_CHIP_FLASH=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/gpio.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/gpio.attach deleted file mode 100644 index 7b3294cc6f..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/gpio.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_GPIO=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/hwtimer.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/hwtimer.attach deleted file mode 100644 index 40b09d6155..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/hwtimer.attach +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_BSP_USING_TIM=y -CONFIG_BSP_USING_TIM0=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/i2c.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/i2c.attach deleted file mode 100644 index e7bf5c0635..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/i2c.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_I2C=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/pwm.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/pwm.attach deleted file mode 100644 index 1ef1911786..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/pwm.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_PWM=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/qspi_flash.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/qspi_flash.attach deleted file mode 100644 index 68c1ca98d3..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/qspi_flash.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_QSPI_FLASH=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/rtc.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/rtc.attach deleted file mode 100644 index fb6acc20cd..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/rtc.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_ONCHIP_RTC=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/spi.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/spi.attach deleted file mode 100644 index 5b37d16468..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/spi.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_SPI=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/uart.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/uart.attach deleted file mode 100644 index d8570f657d..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/uart.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_UART=y \ No newline at end of file diff --git a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/wdt.attach b/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/wdt.attach deleted file mode 100644 index f18527eda9..0000000000 --- a/bsp/nrf5x/nrf52840/.ci/attachconfig/devices/wdt.attach +++ /dev/null @@ -1 +0,0 @@ -CONFIG_BSP_USING_WDT=y \ No newline at end of file diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 48528196b1..74e4e1d934 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -2,7 +2,7 @@ import os import shutil import re import multiprocessing - +import yaml def add_summary(text): """ @@ -159,13 +159,50 @@ if __name__ == "__main__": add_summary(f'- ✅ build {bsp} success.') print("::endgroup::") + yml_files_content = [] + directory = os.path.join(rtt_root, 'bsp', bsp, '.ci/attachconfig') + if os.path.exists(directory): + for filename in os.listdir(directory): + if filename.endswith('attachconfig.yml'): + file_path = os.path.join(directory, filename) + if os.path.exists(file_path): + with open(file_path, 'r') as file: + content = yaml.safe_load(file) + yml_files_content.append(content) + + config_file = os.path.join(rtt_root, 'bsp', bsp, '.config') + + for projects in yml_files_content: + for name, details in projects.items(): + count += 1 + config_bacakup = config_file+'.origin' + shutil.copyfile(config_file, config_bacakup) + with open(config_file, 'a') as destination: + for line in details.get('kconfig'): + destination.write(line + '\n') + scons_arg = details.get('scons_arg') + scons_arg_str = scons_arg[0] if scons_arg else ' ' + print(f"::group::\tCompiling yml project: =={count}==={name}=scons_arg={scons_arg_str}==") + res = build_bsp(bsp, scons_arg_str) + if not res: + print(f"::error::build {bsp} {name} failed.") + add_summary(f'\t- ❌ build {bsp} {name} failed.') + failed += 1 + else: + add_summary(f'\t- ✅ build {bsp} {name} success.') + print("::endgroup::") + + shutil.copyfile(config_bacakup, config_file) + os.remove(config_bacakup) + attach_dir = os.path.join(rtt_root, 'bsp', bsp, '.ci/attachconfig') attach_list = [] for root, dirs, files in os.walk(attach_dir): for file in files: - file_path = os.path.join(root, file) - relative_path = os.path.relpath(file_path, attach_dir) - attach_list.append(relative_path) + if file.endswith('attach'): + file_path = os.path.join(root, file) + relative_path = os.path.relpath(file_path, attach_dir) + attach_list.append(relative_path) for attach_file in attach_list: count += 1 diff --git a/tools/ci/requirements.txt b/tools/ci/requirements.txt new file mode 100644 index 0000000000..e58259357e --- /dev/null +++ b/tools/ci/requirements.txt @@ -0,0 +1,2 @@ +pyyaml +pandas \ No newline at end of file