diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba541799..7ea17b70 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,35 +6,58 @@ jobs: build: name: Build native Zephyr samples runs-on: ubuntu-latest - container: zephyrprojectrtos/ci:latest + container: zephyrprojectrtos/ci-base:latest env: CMAKE_PREFIX_PATH: /opt/toolchains CCACHE_IGNOREOPTIONS: -specs=* - REPOSITORY: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }} + MODULE_PATH: ../modules/lib/ArduinoCore-zephyr + + # action-setup-zephyr will initialize the repo in $GITHUB_WORKSPACE/.., + # so we need to put the module in $GITHUB_WORKSPACE's parent, but + # actions/checkout would not be able to checkout the module there + # directly, so we use "subfolder" and move it later. + # + # using action-setup-zephyr also requires a local west.yml and so the + # folder must be manually added to Zephyr as a module via + # EXTRA_ZEPHYR_MODULES. + steps: - - name: Initialize + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + path: subfolder + + - name: Fix module path, list needed HALs run: | - mkdir build && cd build - west init -m https://github.com/${{ env.REPOSITORY }} --mr ${{ env.BRANCH }} - west update -o=--filter=tree:0 + mkdir -p $(dirname $MODULE_PATH) && mv subfolder $MODULE_PATH + NEEDED_HALS=$(grep 'build.zephyr_hals=' $MODULE_PATH/boards.txt | cut -d '=' -f 2 | xargs -n 1 echo | sort -u) + HAL_FILTER="-hal_.*" + for hal in $NEEDED_HALS; do + HAL_FILTER="$HAL_FILTER,+$hal" + done + echo "HAL_FILTER=$HAL_FILTER" | tee -a $GITHUB_ENV - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + - name: Setup Zephyr project + uses: zephyrproject-rtos/action-zephyr-setup@v1 with: - verbose: 1 + toolchains: arm-zephyr-eabi + manifest-file-name: ${{ env.MODULE_PATH }}/west.yml + west-project-filter: ${{ env.HAL_FILTER }} + enable-ccache: false + + - name: Add manifest path as module + run: | + echo EXTRA_ZEPHYR_MODULES="$(pwd)/$MODULE_PATH" >> $GITHUB_ENV - name: Build fade - working-directory: build run: | - west build -p -b arduino_nano_33_ble//sense modules/lib/ArduinoCore-zephyr/samples/fade + west build -p -b arduino_nano_33_ble//sense $MODULE_PATH/samples/fade - name: Build i2cdemo - working-directory: build run: | - west build -p -b ek_ra8d1 modules/lib/ArduinoCore-zephyr/samples/i2cdemo + west build -p -b ek_ra8d1 $MODULE_PATH/samples/i2cdemo - name: Build adc - working-directory: build run: | - west build -p -b arduino_nano_33_ble/nrf52840/sense modules/lib/ArduinoCore-zephyr/samples/analog_input + west build -p -b arduino_nano_33_ble/nrf52840/sense $MODULE_PATH/samples/analog_input