Skip to content

Commit

Permalink
[Bouffalolab] Update CI workflow to build all BouffaloLab examples in…
Browse files Browse the repository at this point in the history
… one job (project-chip#23870)

* Update CI workflow to build all BouffaloLab examples in one job

* Fix restyle

* remove unnecessary code

* Fix restyle

Co-authored-by: Andrei Litvin <andy314@gmail.com>
  • Loading branch information
wy-hh and andy31415 authored Dec 9, 2022
1 parent bbc3840 commit f54f0f6
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 74 deletions.
115 changes: 50 additions & 65 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ name: Build example - BouffaloLab
on:
push:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
Expand All @@ -26,8 +27,8 @@ env:
CHIP_NO_LOG_TIMESTAMPS: true

jobs:
bl602:
name: BL602
bouffalolab:
name: Bouffalo Lab
timeout-minutes: 90

runs-on: ubuntu-latest
Expand All @@ -54,84 +55,68 @@ jobs:
env:
GH_CONTEXT: ${{ toJson(github) }}
run: scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}"


- name: Bootstrap
timeout-minutes: 25
run: scripts/build/gn_bootstrap.sh
- name: Uploading bootstrap logs
uses: actions/upload-artifact@v3
if: ${{ always() && !env.ACT }}
with:
name: bootstrap-logs
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
- name: Build example BL602 Lighting App
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light build"
- name: Get Lighting size stats
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl602 bl602 lighting-app \
out/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.out /tmp/bloat_reports/
- name: Build example BL602 Lighting App with RPCs
timeout-minutes: 30
"./scripts/build/build_examples.py \
--target bouffalolab-bl602-iot-matter-v1-light \
--target bouffalolab-bl602-iot-matter-v1-light-115200-rpc \
build \
--copy-artifacts-to out/artifacts \
"
- name: Prepare some bloat report from the previous builds
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light-115200-rpc build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl602 bl602+rpc lighting-app \
out/bouffalolab-bl602-iot-matter-v1-light-115200-rpc/chip-bl602-lighting-example.out /tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v3
if: ${{ !env.ACT }}
with:
name: Size,BL602-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
path: |
/tmp/bloat_reports/
bl702:
name: BL702
timeout-minutes: 90

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build-bouffalolab:0.6.18
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
- uses: Wandalen/wretry.action@v1.0.36
name: Checkout
with:
action: actions/checkout@v3
with: |
token: ${{ github.token }}
attempt_limit: 3
attempt_delay: 2000
- name: Checkout submodules
run: scripts/checkout_submodules.py --shallow --platform bouffalolab --recursive

- name: Set up environment for size reports
if: ${{ !env.ACT }}
env:
GH_CONTEXT: ${{ toJson(github) }}
run: scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}"

.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl602 bl602 lighting-app \
out/artifacts/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl602 bl602+rpc lighting-app \
out/artifacts/bouffalolab-bl602-iot-matter-v1-light-115200-rpc/chip-bl602-lighting-example.out \
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out

- name: Build example BL702 Lighting App
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702 lighting-app \
out/bouffalolab-xt-zb6-devkit-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
- name: Build example BL702 Lighting App with RPCs
timeout-minutes: 30
"./scripts/build/build_examples.py \
--target bouffalolab-xt-zb6-devkit-light \
--target bouffalolab-xt-zb6-devkit-light-115200-rpc \
build \
--copy-artifacts-to out/artifacts \
"
- name: Prepare some bloat report from the previous builds
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-115200-rpc build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702+rpc lighting-app \
out/bouffalolab-xt-zb6-devkit-light-115200-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl702 lighting-app \
out/artifacts/bouffalolab-xt-zb6-devkit-light/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl702+rpc lighting-app \
out/artifacts/bouffalolab-xt-zb6-devkit-light-115200-rpc/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out

- name: Uploading Size Reports
uses: actions/upload-artifact@v3
if: ${{ !env.ACT }}
with:
name: Size,BL702-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
name: Size,BouffaloLab-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
path: |
/tmp/bloat_reports/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[![Examples - QPG](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20QPG/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-qpg.yaml)
[![Examples - TI CC26X2X7](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20TI%20CC26X2X7/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-cc13x2x7_26x2x7.yaml)
[![Build example - Infineon](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-infineon.yaml/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-infineon.yaml)
[![Build example - BouffaloLab](https://github.com/project-chip/connectedhomeip/workflows/Build%20example%20-%20BouffaloLab/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/examples-bouffalolab.yaml)

[![Android](https://github.com/project-chip/connectedhomeip/workflows/Android/badge.svg)](https://github.com/project-chip/connectedhomeip/actions/workflows/android.yaml)

Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/bouffalolab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Mac OS.

```
cd third_party/bouffalolab/repo
sudo bash script/setup.sh
sudo bash scripts/setup.sh
```

Please execute following command export `BOUFFALOLAB_SDK_ROOT` before
Expand Down
27 changes: 19 additions & 8 deletions scripts/build/builders/bouffalolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import os
import platform
import logging
from enum import Enum, auto

from .gn import GnBuilder
Expand All @@ -28,9 +29,9 @@ def ExampleName(self):
else:
raise Exception('Unknown app type: %r' % self)

def AppNamePrefix(self):
def AppNamePrefix(self, chip_name):
if self == BouffalolabApp.LIGHT:
return 'chip-bl702-lighting-example'
return ('chip-%s-lighting-example' % chip_name)
else:
raise Exception('Unknown app type: %r' % self)

Expand Down Expand Up @@ -87,7 +88,7 @@ def __init__(self,
)

self.argsOpt = []

self.chip_name = bouffalo_chip
toolchain = os.path.join(root, '../../examples/platform/bouffalolab/common/toolchain')
toolchain = 'custom_toolchain="{}:riscv_gcc"'.format(toolchain)
if toolchain:
Expand All @@ -107,19 +108,29 @@ def __init__(self,
elif enable_shell:
self.argsOpt.append('chip_build_libshell=true')

self.argsOpt.append('bouffalolab_sdk_root="%s"' % os.environ['BOUFFALOLAB_SDK_ROOT'])
try:
self.argsOpt.append('bouffalolab_sdk_root="%s"' % os.environ['BOUFFALOLAB_SDK_ROOT'])
except KeyError as err:
logging.fatal('Please make sure Bouffalo Lab SDK installs as below:')
logging.fatal('\tcd third_party/bouffalolab/repo')
logging.fatal('\tsudo bash scripts/setup.sh')

logging.fatal('Please make sure BOUFFALOLAB_SDK_ROOT exports before building as below:')
logging.fatal('\texport BOUFFALOLAB_SDK_ROOT=/opt/bouffalolab_sdk')

raise err

def GnBuildArgs(self):
return self.argsOpt

def build_outputs(self):
items = {
'%s.out' % self.app.AppNamePrefix():
'%s.out' % self.app.AppNamePrefix(self.chip_name):
os.path.join(self.output_dir, '%s.out' %
self.app.AppNamePrefix()),
'%s.out.map' % self.app.AppNamePrefix():
self.app.AppNamePrefix(self.chip_name)),
'%s.out.map' % self.app.AppNamePrefix(self.chip_name):
os.path.join(self.output_dir,
'%s.out.map' % self.app.AppNamePrefix()),
'%s.out.map' % self.app.AppNamePrefix(self.chip_name)),
}

return items
11 changes: 11 additions & 0 deletions scripts/examples/gn_bouffalolab_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ else
exit 1
fi

if [[ "$BOUFFALOLAB_SDK_ROOT" == "" ]]; then

echo -e "\e[31mPlease make sure Bouffalo Lab SDK installs as below:\e[0m"
echo -e "\e[31m\tcd third_party/bouffalolab/repo\e[0m"
echo -e "\e[31m\tsudo bash scripts/setup.sh\e[0m"

echo -e "\e[31mPlease make sure BOUFFALOLAB_SDK_ROOT exports before building as below:\e[0m"
echo -e "\e[31m\texport BOUFFALOLAB_SDK_ROOT=/opt/bouffalolab_sdk\e[0m"

exit 1
fi
optArgs=$optArgs' bouffalolab_sdk_root="'$BOUFFALOLAB_SDK_ROOT'"'

example_dir=$MATTER_ROOT/examples/$example_name/bouffalolab/$bouffalo_chip
Expand Down

0 comments on commit f54f0f6

Please sign in to comment.