From a1c8f15e90c97808dabfb321145e9d0735ed3298 Mon Sep 17 00:00:00 2001 From: Meeyi Zhao Date: Thu, 25 Jun 2026 17:31:10 +0800 Subject: [PATCH] scripts:add peripheral build --- .github/workflows/peripheral-build.yml | 143 +++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 .github/workflows/peripheral-build.yml diff --git a/.github/workflows/peripheral-build.yml b/.github/workflows/peripheral-build.yml new file mode 100644 index 0000000000000..59646609897de --- /dev/null +++ b/.github/workflows/peripheral-build.yml @@ -0,0 +1,143 @@ +name: Build peripheral +run-name: Build peripheral +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" +jobs: + Build-peripheral: + runs-on: ubuntu-latest + + env: + ZSDK_VERSION: "1.0.1" + HOSTTYPE: "x86_64_minimal" + + container: + image: ghcr.io/zephyrproject-rtos/ci-base:latest + options: '--entrypoint /bin/bash' + + steps: + - name: check size + run: | + df -h + ls -al /opt/ + du -h --max-depth=1 /opt + sudo rm -rf /opt/fvps + echo "-----------------------" + df -h + echo "-----------------------" + du -h --max-depth=1 /opt + + - name: set_env + run: | + if [ "${{ github.event_name }}" = "pull_request" -o "${{ github.event_name }}" = "pull_request_target" ];then + echo "This is pull request" + echo "EVENT_TRIGER_REF=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV + fi + if [ "${{ github.event_name }}" = "push" ];then + echo "This is push" + echo "EVENT_TRIGER_REF=${{ github.ref }}" >> $GITHUB_ENV + fi + + - name: print_env + run: | + echo "sdk-version -> ${ZSDK_VERSION}" + echo "event_triger_ref: ${EVENT_TRIGER_REF}" + echo "${{ github.event.pull_request.head.sha || github.ref }}" + + - name: setup sdk + shell: bash + run: | + mkdir -p /opt/toolchains + cd /opt/toolchains + wget -q --show-progress --progress=bar:force:noscroll https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz + wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/toolchain_gnu_linux-x86_64_arm-zephyr-eabi.tar.xz + tar xf zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz + mkdir -p /opt/toolchains/zephyr-sdk-${ZSDK_VERSION}/gnu + tar xf toolchain_gnu_linux-x86_64_arm-zephyr-eabi.tar.xz -C /opt/toolchains/zephyr-sdk-${ZSDK_VERSION}/gnu/ + zephyr-sdk-${ZSDK_VERSION}/setup.sh -c + rm zephyr-sdk-${ZSDK_VERSION}_linux-${HOSTTYPE}.tar.xz + echo "zephyr sdk -> zephyr-sdk-${ZSDK_VERSION}" + echo "-----------------------" + ls /opt/toolchains/zephyr-sdk-${ZSDK_VERSION} + echo "-----------------------" + du -sh /opt/toolchains/zephyr-sdk-${ZSDK_VERSION} + echo "-----------------------" + /opt/toolchains/zephyr-sdk-${ZSDK_VERSION}/setup.sh -c + echo "-----------------------" + df -h + + - name: checkout manifest + uses: actions/checkout@v4 + with: + repository: "rtkconnectivity/realtek-zephyr-project.git" + path: "realtek-zephyr-project" + ref: "rtl87x2j" + fetch-depth: 0 + persist-credentials: false + + - name: west update + shell: bash + run: | + cd realtek-zephyr-project + west init -m https://github.com/rtkconnectivity/realtek-zephyr-project --mr rtl87x2j + west update + echo "workspace: $(west topdir)" + echo "current: $(pwd)" + + - name: check zephyr path and manifest_rev + shell: bash + run: | + echo "GITHUB_REPOSITORY -> $GITHUB_REPOSITORY" + cd realtek-zephyr-project + readarray -t project_list <<< "$(west list)" + EVENT_PROJECT_PATH="" + for i in "${project_list[@]}" + do + project_detail=($i) + project_url=`echo ${project_detail[3]}` + repository_name=`echo "$GITHUB_REPOSITORY" | awk -F/ '{print $NF}'` + if [[ $project_url == *"${repository_name}" ]] + then + EVENT_PROJECT_PATH=`echo ${project_detail[1]}` + echo "EVENT_PROJECT_PATH=$EVENT_PROJECT_PATH" >> $GITHUB_ENV + echo "EVENT_PROJECT_PATH -> $EVENT_PROJECT_PATH" + echo "GITHUB_ENV -> $GITHUB_ENV" + break + fi + done + if [ -z "$EVENT_PROJECT_PATH" ] + then + echo "logic error, can not find local path for ${GITHUB_REPOSITY}" + exit 1 + fi + cd $EVENT_PROJECT_PATH + git log --reverse -1 + echo "need to checkout ${GITHUB_REPOSITORY} in realtek-zephyr-project/$EVENT_PROJECT_PATH" + echo "manifest_rev=$( git rev-parse manifest-rev )" >> $GITHUB_ENV + + - name: checkout event triggered ref + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + path: ${{ format('{0}/{1}','realtek-zephyr-project',env.EVENT_PROJECT_PATH) }} + ref: ${{ github.event.pull_request.head.sha || github.ref }} + fetch-depth: 0 + persist-credentials: false + clean: false + + - name: after check temp module + shell: bash + run: | + cd realtek-zephyr-project/$EVENT_PROJECT_PATH + echo "manifest_rev -> ${manifest_rev}" + git branch manifest-rev $manifest_rev + + - name: do build + shell: bash + run: | + cd realtek-zephyr-project/zephyr + echo "============= build rtl87x2j =============" + west build -b rtl87x2j_evb/rtl8762jth samples/bluetooth/peripheral -p + rm -rf build \ No newline at end of file