Skip to content

Commit 02c59e9

Browse files
kartbenstephanosio
andcommitted
ci: .github: workflows: add IAR workflow
Similar to the clang workflow that runs against native_sim, but for IAR Arm on qemu_cortex_m3. Co-authored-by: Stephanos Ioannidis <[email protected]> Signed-off-by: Benjamin Cabé <[email protected]> Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 335e1c2 commit 02c59e9

File tree

1 file changed

+213
-0
lines changed

1 file changed

+213
-0
lines changed

.github/workflows/iar.yaml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
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: Install Python packages
115+
run: |
116+
pip install -r scripts/requirements-actions.txt --require-hashes
117+
west packages pip --install
118+
119+
- name: Set up ccache
120+
run: |
121+
mkdir -p ${CCACHE_DIR}
122+
ccache -M 10G
123+
ccache -p
124+
ccache -z -s -vv
125+
126+
- name: Update BabbleSim to manifest revision
127+
run: |
128+
export BSIM_VERSION=$( west list bsim -f {revision} )
129+
echo "Manifest points to bsim sha $BSIM_VERSION"
130+
cd /opt/bsim_west/bsim
131+
git fetch -n origin ${BSIM_VERSION}
132+
git -c advice.detachedHead=false checkout ${BSIM_VERSION}
133+
west update
134+
make everything -s -j 8
135+
136+
- name: Run Tests with Twister
137+
id: twister
138+
env:
139+
IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
140+
run: |
141+
export ZEPHYR_BASE=${PWD}
142+
export ZEPHYR_TOOLCHAIN_VARIANT=iar
143+
export IAR_TOOLCHAIN_PATH=${IAR_TOOLCHAIN_PATH}/arm
144+
145+
./scripts/twister -p qemu_cortex_m3 --no-detailed-test-id --force-color --inline-logs -M -N -v --retry-failed 2 \
146+
-T tests --subset ${{matrix.subset}}/2 -j 16 --force-toolchain
147+
148+
- name: Print ccache stats
149+
if: always()
150+
run: |
151+
ccache -s -vv
152+
153+
- name: Upload Unit Test Results
154+
if: always()
155+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
156+
with:
157+
name: Unit Test Results (Subset ${{ matrix.subset }})
158+
path: |
159+
twister-out/twister.xml
160+
twister-out/twister.json
161+
if-no-files-found: ignore
162+
163+
iar-build-results:
164+
name: "Publish Unit Tests Results"
165+
needs: iar-build
166+
runs-on: ubuntu-24.04
167+
permissions:
168+
checks: write # to create GitHub annotations
169+
if: (success() || failure())
170+
steps:
171+
- name: Checkout
172+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
173+
with:
174+
fetch-depth: 0
175+
persist-credentials: false
176+
177+
- name: Download Artifacts
178+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
179+
with:
180+
path: artifacts
181+
182+
- name: Set up Python
183+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
184+
with:
185+
python-version: 3.12
186+
cache: pip
187+
cache-dependency-path: scripts/requirements-actions.txt
188+
189+
- name: Install Python packages
190+
run: |
191+
pip install -r scripts/requirements-actions.txt --require-hashes
192+
193+
- name: Merge Test Results
194+
run: |
195+
junitparser merge artifacts/*/twister.xml junit.xml
196+
junit2html junit.xml junit-iar.html
197+
198+
- name: Upload Unit Test Results in HTML
199+
if: always()
200+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
201+
with:
202+
name: HTML Unit Test Results
203+
if-no-files-found: ignore
204+
path: |
205+
junit-iar.html
206+
207+
- name: Publish Unit Test Results
208+
uses: EnricoMi/publish-unit-test-result-action@3a74b2957438d0b6e2e61d67b05318aa25c9e6c6 # v2.20.0
209+
if: always()
210+
with:
211+
check_name: Unit Test Results
212+
files: "**/twister.xml"
213+
comment_mode: off

0 commit comments

Comments
 (0)