Skip to content

Commit 833ccc2

Browse files
kartbenstephanosio
authored 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. Signed-off-by: Benjamin Cabé <[email protected]>
1 parent 335e1c2 commit 833ccc2

File tree

1 file changed

+214
-0
lines changed

1 file changed

+214
-0
lines changed

.github/workflows/iar.yaml

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

0 commit comments

Comments
 (0)