|
| 1 | +name: Build with IAR |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + - v*-branch |
| 7 | + - collab-* |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + iar-build: |
| 18 | + if: github.repository_owner == 'zephyrproject-rtos' |
| 19 | + runs-on: |
| 20 | + group: zephyr-runner-v2-linux-x64-4xlarge |
| 21 | + container: |
| 22 | + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.28.4.20250818 |
| 23 | + options: '--entrypoint /bin/bash' |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + subset: [1, 2] |
| 28 | + env: |
| 29 | + CCACHE_DIR: /node-cache/ccache-zephyr |
| 30 | + CCACHE_REMOTE_STORAGE: "redis://cache-*.keydb-cache.svc.cluster.local|shards=1,2,3" |
| 31 | + CCACHE_REMOTE_ONLY: "true" |
| 32 | + CCACHE_IGNOREOPTIONS: '-specs=* --specs=*' |
| 33 | + IAR_VERSION: "9.70.1" |
| 34 | + IAR_TOOLCHAIN_PATH: /opt/iar |
| 35 | + BASE_REF: ${{ github.base_ref }} |
| 36 | + steps: |
| 37 | + - name: Apply container owner mismatch workaround |
| 38 | + run: | |
| 39 | + # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not |
| 40 | + # match the container user UID because of the way GitHub |
| 41 | + # Actions runner is implemented. Remove this workaround when |
| 42 | + # GitHub comes up with a fundamental fix for this problem. |
| 43 | + git config --global --add safe.directory ${GITHUB_WORKSPACE} |
| 44 | +
|
| 45 | + - name: Print cloud service information |
| 46 | + run: | |
| 47 | + echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}" |
| 48 | + echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}" |
| 49 | + echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}" |
| 50 | +
|
| 51 | + - name: Clone cached Zephyr repository |
| 52 | + continue-on-error: true |
| 53 | + run: | |
| 54 | + git clone --shared /repo-cache/zephyrproject/zephyr . |
| 55 | + git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} |
| 56 | +
|
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + persist-credentials: false |
| 62 | + |
| 63 | + - name: Install IAR Toolchain |
| 64 | + run: | |
| 65 | + # Create installation directory |
| 66 | + sudo mkdir -p ${IAR_TOOLCHAIN_PATH} |
| 67 | + cd /tmp |
| 68 | +
|
| 69 | + # Download IAR toolchain |
| 70 | + IAR_BASE_FILE_NAME="cxarm-${IAR_VERSION}-linux-x86_64-base.tar.bz2" |
| 71 | + IAR_URL="https://github.com/iarsystems/arm/releases/download/${IAR_VERSION}/${IAR_BASE_FILE_NAME}" |
| 72 | + IAR_SHA_URL="https://github.com/iarsystems/arm/releases/download/${IAR_VERSION}/${IAR_BASE_FILE_NAME}.sha256" |
| 73 | +
|
| 74 | + echo "Downloading IAR toolchain version ${IAR_VERSION}..." |
| 75 | + wget "${IAR_URL}" |
| 76 | + wget "${IAR_SHA_URL}" |
| 77 | +
|
| 78 | + # Validate the hash |
| 79 | + echo "Validating checksum..." |
| 80 | + sha256sum --check "${IAR_BASE_FILE_NAME}.sha256" |
| 81 | +
|
| 82 | + # Extract the archive |
| 83 | + echo "Extracting IAR toolchain..." |
| 84 | + sudo tar -xf "${IAR_BASE_FILE_NAME}" -C ${IAR_TOOLCHAIN_PATH} --strip-components=1 |
| 85 | +
|
| 86 | + - name: Environment Setup |
| 87 | + run: | |
| 88 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 89 | + git config --global user.email "[email protected]" |
| 90 | + git config --global user.name "Zephyr Bot" |
| 91 | + rm -fr ".git/rebase-apply" |
| 92 | + rm -fr ".git/rebase-merge" |
| 93 | + git clean -f -d |
| 94 | + git log --pretty=oneline | head -n 10 |
| 95 | + west init -l . || true |
| 96 | + west config --global update.narrow true |
| 97 | + west config manifest.group-filter -- +ci,+optional |
| 98 | + # In some cases modules are left in a state where they can't be |
| 99 | + # updated (i.e. when we cancel a job and the builder is killed), |
| 100 | + # So first retry to update, if that does not work, remove all modules |
| 101 | + # and start over. (Workaround until we implement more robust module |
| 102 | + # west caching). |
| 103 | + west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west2.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject) |
| 104 | +
|
| 105 | + echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV |
| 106 | +
|
| 107 | + - name: Check Environment |
| 108 | + run: | |
| 109 | + cmake --version |
| 110 | + ${IAR_TOOLCHAIN_PATH}/arm/bin/iccarm --version |
| 111 | + gcc --version |
| 112 | + ls -la |
| 113 | +
|
| 114 | + - name: Set up ccache |
| 115 | + run: | |
| 116 | + mkdir -p ${CCACHE_DIR} |
| 117 | + ccache -M 10G |
| 118 | + ccache -p |
| 119 | + ccache -z -s -vv |
| 120 | +
|
| 121 | + - name: Update BabbleSim to manifest revision |
| 122 | + run: | |
| 123 | + export BSIM_VERSION=$( west list bsim -f {revision} ) |
| 124 | + echo "Manifest points to bsim sha $BSIM_VERSION" |
| 125 | + cd /opt/bsim_west/bsim |
| 126 | + git fetch -n origin ${BSIM_VERSION} |
| 127 | + git -c advice.detachedHead=false checkout ${BSIM_VERSION} |
| 128 | + west update |
| 129 | + make everything -s -j 8 |
| 130 | +
|
| 131 | + - name: Run Tests with Twister |
| 132 | + id: twister |
| 133 | + env: |
| 134 | + IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }} |
| 135 | + run: | |
| 136 | + export ZEPHYR_BASE=${PWD} |
| 137 | + export ZEPHYR_TOOLCHAIN_VARIANT=iar |
| 138 | + export IAR_TOOLCHAIN_PATH=${IAR_TOOLCHAIN_PATH}/arm |
| 139 | +
|
| 140 | + ./scripts/twister -p qemu_cortex_m3 --no-detailed-test-id --force-color --inline-logs -M -N -v --retry-failed 2 \ |
| 141 | + -T tests --subset ${{matrix.subset}}/2 -j 16 --force-toolchain |
| 142 | +
|
| 143 | + - name: Print ccache stats |
| 144 | + if: always() |
| 145 | + run: | |
| 146 | + ccache -s -vv |
| 147 | +
|
| 148 | + - name: Upload Unit Test Results |
| 149 | + if: always() |
| 150 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 151 | + with: |
| 152 | + name: Unit Test Results (Subset ${{ matrix.subset }}) |
| 153 | + path: | |
| 154 | + twister-out/twister.xml |
| 155 | + twister-out/twister.json |
| 156 | + if-no-files-found: ignore |
| 157 | + |
| 158 | + iar-build-results: |
| 159 | + name: "Publish Unit Tests Results" |
| 160 | + needs: iar-build |
| 161 | + runs-on: ubuntu-24.04 |
| 162 | + permissions: |
| 163 | + checks: write # to create GitHub annotations |
| 164 | + if: (success() || failure()) |
| 165 | + steps: |
| 166 | + - name: Checkout |
| 167 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 168 | + with: |
| 169 | + fetch-depth: 0 |
| 170 | + persist-credentials: false |
| 171 | + |
| 172 | + - name: Download Artifacts |
| 173 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 |
| 174 | + with: |
| 175 | + path: artifacts |
| 176 | + |
| 177 | + - name: Set up Python |
| 178 | + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
| 179 | + with: |
| 180 | + python-version: 3.12 |
| 181 | + cache: pip |
| 182 | + cache-dependency-path: scripts/requirements-actions.txt |
| 183 | + |
| 184 | + - name: Install Python packages |
| 185 | + run: | |
| 186 | + pip install -r scripts/requirements-actions.txt --require-hashes |
| 187 | +
|
| 188 | + - name: Merge Test Results |
| 189 | + run: | |
| 190 | + junitparser merge artifacts/*/twister.xml junit.xml |
| 191 | + junit2html junit.xml junit-iar.html |
| 192 | +
|
| 193 | + - name: Upload Unit Test Results in HTML |
| 194 | + if: always() |
| 195 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 196 | + with: |
| 197 | + name: HTML Unit Test Results |
| 198 | + if-no-files-found: ignore |
| 199 | + path: | |
| 200 | + junit-iar.html |
| 201 | +
|
| 202 | + - name: Publish Unit Test Results |
| 203 | + uses: EnricoMi/publish-unit-test-result-action@3a74b2957438d0b6e2e61d67b05318aa25c9e6c6 # v2.20.0 |
| 204 | + if: always() |
| 205 | + with: |
| 206 | + check_name: Unit Test Results |
| 207 | + files: "**/twister.xml" |
| 208 | + comment_mode: off |
0 commit comments