|  | 
| 1 |  | -name: Package core | 
|  | 1 | +name: Package, test and upload core | 
| 2 | 2 | 
 | 
| 3 |  | -on: [push, pull_request] | 
|  | 3 | +on: | 
|  | 4 | +  push: | 
|  | 5 | +    branches: | 
|  | 6 | +      - arduino | 
|  | 7 | +  pull_request: | 
| 4 | 8 | 
 | 
| 5 | 9 | jobs: | 
| 6 |  | -  build: | 
|  | 10 | + | 
|  | 11 | +  package-core: | 
|  | 12 | +    name: Build and package core | 
| 7 | 13 |     runs-on: ubuntu-latest | 
| 8 | 14 |     env: | 
| 9 | 15 |       ZEPHYR_SDK_INSTALL_DIR: /opt/zephyr-sdk-0.16.8 | 
|  | 16 | +      CCACHE_IGNOREOPTIONS: -specs=* | 
|  | 17 | +    outputs: | 
|  | 18 | +      CORE_TAG: ${{ env.CORE_TAG }} | 
|  | 19 | +      CORE_ARTIFACT: ${{ env.CORE_ARTIFACT }} | 
|  | 20 | +      BOARD_NAMES: ${{ env.BOARD_NAMES }} | 
| 10 | 21 |     steps: | 
| 11 | 22 |       - name: Install toolchain | 
| 12 | 23 |         working-directory: /opt | 
| 13 | 24 |         run: | | 
| 14 | 25 |           sudo apt-get update | 
| 15 |  | -          sudo apt-get install -y --no-install-recommends git cmake wget python3-pip ninja-build | 
| 16 |  | -          wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz | 
|  | 26 | +          sudo apt-get install -y --no-install-recommends git cmake wget python3-pip ninja-build ccache | 
|  | 27 | +          wget -nv https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz | 
| 17 | 28 |           tar xf zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz && cd zephyr-sdk-0.16.8 && ./setup.sh -t arm-zephyr-eabi -c | 
| 18 | 29 | 
 | 
| 19 | 30 |       - uses: actions/checkout@v4 | 
|  | 31 | +        with: | 
|  | 32 | +          fetch-depth: 0 | 
|  | 33 | +          persist-credentials: false | 
| 20 | 34 | 
 | 
| 21 | 35 |       - name: Initialize | 
| 22 | 36 |         run: | | 
| 23 |  | -          ./extra/bootstrap.sh | 
| 24 |  | -          ./extra/build_all.sh | 
| 25 |  | -          ./extra/package.sh `git describe --always` | 
| 26 |  | -          mv ../arduino-core-zephyr-llext* . | 
|  | 37 | +          ./extra/bootstrap.sh -o=--filter=tree:0 | 
|  | 38 | +          echo "CORE_TAG=$(git describe --always)" >> "$GITHUB_ENV" | 
|  | 39 | +          echo "CORE_ARTIFACT=ArduinoCore-zephyr-$(git describe --always)" >> "$GITHUB_ENV" | 
|  | 40 | +          echo "BOARD_NAMES=[ $(cat boards.txt | grep '^[^#]*\.build\.variant' | cut -d '.' -f 1 | xargs printf '"%s",' | sed -e 's/,$//') ]" >> "$GITHUB_ENV" | 
|  | 41 | +
 | 
|  | 42 | +      - name: ccache | 
|  | 43 | +        uses: hendrikmuhs/[email protected] | 
|  | 44 | +        with: | 
|  | 45 | +          verbose: 1 | 
|  | 46 | + | 
|  | 47 | +      - name: Build variants | 
|  | 48 | +        run: | | 
|  | 49 | +          ./extra/build_all.sh -f | 
|  | 50 | +
 | 
|  | 51 | +      - name: Package | 
|  | 52 | +        run: | | 
|  | 53 | +          ./extra/package.sh ${{ env.CORE_TAG }} | 
|  | 54 | +          mv ../${{ env.CORE_ARTIFACT }}.tar.bz2 . | 
| 27 | 55 | 
 | 
| 28 | 56 |       - name: Archive core | 
| 29 | 57 |         uses: actions/upload-artifact@v4 | 
| 30 | 58 |         with: | 
| 31 |  | -          name: Core | 
| 32 |  | -          path: arduino-core-zephyr-llext* | 
|  | 59 | +          name: ${{ env.CORE_ARTIFACT }} | 
|  | 60 | +          path: ${{ env.CORE_ARTIFACT }}.tar.bz2 | 
|  | 61 | + | 
|  | 62 | +  test-core: | 
|  | 63 | +    name: Test arduino:zephyr:${{ matrix.board }} | 
|  | 64 | +    runs-on: ubuntu-latest | 
|  | 65 | +    needs: package-core | 
|  | 66 | +    strategy: | 
|  | 67 | +      matrix: | 
|  | 68 | +        board: ${{ fromJSON( needs.package-core.outputs.BOARD_NAMES ) }} | 
|  | 69 | +      fail-fast: false | 
|  | 70 | +    env: | 
|  | 71 | +      FQBN: arduino:zephyr:${{ matrix.board }} | 
|  | 72 | +    steps: | 
|  | 73 | +      - uses: actions/download-artifact@v4 | 
|  | 74 | +        with: | 
|  | 75 | +          name: ${{ needs.package-core.outputs.CORE_ARTIFACT }} | 
|  | 76 | + | 
|  | 77 | +      - name: Set up core | 
|  | 78 | +        run: | | 
|  | 79 | +          tar xf ${{ needs.package-core.outputs.CORE_ARTIFACT }}.tar.bz2 | 
| 33 | 80 | 
 | 
| 34 | 81 |       - name: Create Blink sketch | 
| 35 | 82 |         run: | | 
| 36 |  | -          mkdir extra/Blink/ | 
| 37 |  | -          wget https://raw.githubusercontent.com/arduino/arduino-examples/refs/heads/main/examples/01.Basics/Blink/Blink.ino | 
| 38 |  | -          mv Blink.ino extra/Blink/ | 
|  | 83 | +          mkdir Blink/ | 
|  | 84 | +          wget -nv https://raw.githubusercontent.com/arduino/arduino-examples/refs/heads/main/examples/01.Basics/Blink/Blink.ino -P Blink/ | 
| 39 | 85 | 
 | 
| 40 |  | -      - name: Compile Blink | 
| 41 |  | -        uses: arduino/compile-sketches@main | 
|  | 86 | +      - name: Compile Blink for ${{ env.FQBN }} | 
|  | 87 | +        uses: pillo79/compile-sketches@main | 
| 42 | 88 |         with: | 
| 43 |  | -          fqbn: arduino:zephyr:giga | 
|  | 89 | +          fqbn: ${{ env.FQBN }} | 
| 44 | 90 |           platforms: | | 
| 45 | 91 |             # Use Board Manager to install the latest release of Arduino Zephyr Boards to get the toolchain | 
| 46 | 92 |             - name: "arduino:zephyr" | 
| 47 | 93 |               source-url: "https://downloads.arduino.cc/packages/package_zephyr_index.json" | 
| 48 |  | -            - source-path: "./" | 
| 49 |  | -              name: "arduino:zephyr" | 
| 50 |  | -          sketch-paths: | | 
| 51 |  | -            extra/Blink | 
|  | 94 | +            - name: "arduino:zephyr" | 
|  | 95 | +              source-path: "ArduinoCore-zephyr" | 
|  | 96 | +          sketch-paths: Blink | 
| 52 | 97 |           verbose: 'false' | 
| 53 | 98 |           enable-deltas-report: 'false' | 
|  | 99 | +          enable-warnings-report: 'true' | 
|  | 100 | +          enable-warnings-log: 'true' | 
|  | 101 | + | 
|  | 102 | +      - name: Clean up log | 
|  | 103 | +        run: | | 
|  | 104 | +            sed -i -e 's!/home/runner/.arduino15/packages/arduino/hardware/zephyr/[^/]*/!!g' sketches-reports/* | 
|  | 105 | +
 | 
|  | 106 | +      - uses: actions/upload-artifact@v4 | 
|  | 107 | +        with: | 
|  | 108 | +          name: test-report-${{ needs.package-core.outputs.CORE_TAG }}-${{ matrix.board }} | 
|  | 109 | +          path: sketches-reports/* | 
|  | 110 | + | 
|  | 111 | +  collect-logs: | 
|  | 112 | +    name: Test summary | 
|  | 113 | +    runs-on: ubuntu-latest | 
|  | 114 | +    needs: | 
|  | 115 | +      - package-core | 
|  | 116 | +      - test-core | 
|  | 117 | +    if: ${{ !cancelled() && needs.package-core.result == 'success' }} | 
|  | 118 | +    env: | 
|  | 119 | +      BOARD_NAMES: ${{ needs.package-core.outputs.BOARD_NAMES }} | 
|  | 120 | +    steps: | 
|  | 121 | +      - uses: actions/download-artifact@v4 | 
|  | 122 | +        with: | 
|  | 123 | +          path: . | 
|  | 124 | +          pattern: test-report-* | 
|  | 125 | +          merge-multiple: true | 
|  | 126 | + | 
|  | 127 | +      - run: | | 
|  | 128 | +          echo "### Core test results" >> "$GITHUB_STEP_SUMMARY" | 
|  | 129 | +          for BOARD in $(echo $BOARD_NAMES | jq -cr '.[]'); do | 
|  | 130 | +            FQBN="arduino:zephyr:$BOARD" | 
|  | 131 | +            REPORT_FILE="arduino-zephyr-$BOARD.json" | 
|  | 132 | +            if [ ! -f $REPORT_FILE ]; then | 
|  | 133 | +              echo ":x: $BOARD - No report found?" >> "$GITHUB_STEP_SUMMARY" | 
|  | 134 | +            else | 
|  | 135 | +              REPORT=$(jq -cr '.boards[0].sketches[0]' $REPORT_FILE) | 
|  | 136 | +              if ! $(echo $REPORT | jq -cr '.compilation_success') ; then | 
|  | 137 | +                echo ":x: $BOARD - **Build failed**" >> "$GITHUB_STEP_SUMMARY" | 
|  | 138 | +              else | 
|  | 139 | +                WARNINGS=$(echo $REPORT | jq -cr '.warnings.current.absolute // 0') | 
|  | 140 | +                if [ $WARNINGS -eq 0 ]; then | 
|  | 141 | +                  echo ":white_check_mark: $BOARD - Build successful" >> "$GITHUB_STEP_SUMMARY" | 
|  | 142 | +                else | 
|  | 143 | +                  echo "<details><summary>:warning: $BOARD - $WARNINGS Warnings:</summary>" >> "$GITHUB_STEP_SUMMARY" | 
|  | 144 | +                  echo >> "$GITHUB_STEP_SUMMARY" | 
|  | 145 | +                  echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" | 
|  | 146 | +                  echo $REPORT | jq -cr '.warnings_log[]' >> "$GITHUB_STEP_SUMMARY" | 
|  | 147 | +                  echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" | 
|  | 148 | +                  echo >> "$GITHUB_STEP_SUMMARY" | 
|  | 149 | +                  echo "</details>" >> "$GITHUB_STEP_SUMMARY" | 
|  | 150 | +                fi | 
|  | 151 | +              fi | 
|  | 152 | +            fi | 
|  | 153 | +          done | 
|  | 154 | +
 | 
|  | 155 | +  publish-artifacts: | 
|  | 156 | +    name: Publish artifacts | 
|  | 157 | +    runs-on: ubuntu-latest | 
|  | 158 | +    if: ${{ github.event_name == 'push' && github.repository == 'arduino/ArduinoCore-zephyr' }} | 
|  | 159 | +    needs: | 
|  | 160 | +      - package-core | 
|  | 161 | +      - test-core | 
|  | 162 | +    env: | 
|  | 163 | +      CORE_ARTIFACT: ${{ needs.package-core.outputs.CORE_ARTIFACT }} | 
|  | 164 | +      CORE_TAG: ${{ needs.package-core.outputs.CORE_TAG }} | 
|  | 165 | +      PACKAGE_INDEX_JSON: zephyr-core-${{ needs.package-core.outputs.CORE_TAG }}.json | 
|  | 166 | +    steps: | 
|  | 167 | +      - uses: actions/download-artifact@v4 | 
|  | 168 | +        with: | 
|  | 169 | +          name: ${{ env.CORE_ARTIFACT }} | 
|  | 170 | + | 
|  | 171 | +      - name: Configure AWS credentials | 
|  | 172 | +        uses: aws-actions/configure-aws-credentials@v4 | 
|  | 173 | +        with: | 
|  | 174 | +          role-to-assume: ${{ secrets.IAM_ROLE }} | 
|  | 175 | +          aws-region: ${{ secrets.AWS_REGION }} | 
|  | 176 | + | 
|  | 177 | +      - name: Upload artifact | 
|  | 178 | +        run: aws s3 sync ${{ env.CORE_ARTIFACT }}.tar.bz2 s3://${{ secrets.S3_BUCKET }} | 
|  | 179 | + | 
|  | 180 | +      - name: Prepare package index snippet | 
|  | 181 | +        run: ./extra/gen_package_index_json.sh | 
|  | 182 | + | 
|  | 183 | +      - name: Archive package index snippet | 
|  | 184 | +        uses: actions/upload-artifact@v4 | 
|  | 185 | +        with: | 
|  | 186 | +          name: ${{ env.PACKAGE_INDEX_JSON }} | 
|  | 187 | +          path: ${{ env.PACKAGE_INDEX_JSON }} | 
0 commit comments