88 create :
99 workflow_dispatch :
1010
11- # Allow one concurrent deployment
1211concurrency :
1312 group : ${{ github.ref }}
1413 cancel-in-progress : true
1514
1615permissions : write-all
1716
17+ env :
18+ ZEPHYR_SDK_VERSION : " 0.17.4"
19+
1820jobs :
21+ setup :
22+ runs-on : ubuntu-latest
23+ outputs :
24+ sdk-hash : ${{ steps.generate-vars.outputs.sdk-hash }}
25+ sdk-revision : ${{ steps.generate-vars.outputs.sdk-revision }}
26+ repo : ${{ steps.generate-vars.outputs.repo }}
27+ repo-url : ${{ steps.generate-vars.outputs.repo-url }}
28+ branch : ${{ steps.generate-vars.outputs.branch }}
29+ repo-hash : ${{ steps.generate-vars.outputs.repo-hash }}
30+ steps :
31+ - name : 💻 Checkout Repository
32+ uses : actions/checkout@v6
33+ with :
34+ path : zephyr-workspace/SlimeNRF-CI
35+ submodules : recursive
36+
37+ - name : 📟 Generate CI Variables
38+ id : generate-vars
39+ run : |
40+ WEST_FILE="west.yml"
41+
42+ if [ -f "$WEST_FILE" ]; then
43+ echo "Found west.yml in the root directory"
44+ elif [ -f "zephyr-workspace/$WEST_FILE" ]; then
45+ WEST_FILE="zephyr-workspace/$WEST_FILE"
46+ echo "Found west.yml in zephyr-workspace"
47+ elif [ -f "zephyr-workspace/SlimeNRF-CI/$WEST_FILE" ]; then
48+ WEST_FILE="zephyr-workspace/SlimeNRF-CI/$WEST_FILE"
49+ echo "Found west.yml in zephyr-workspace/SlimeNRF-CI"
50+ else
51+ echo "Error: west.yml not found!" >&2
52+ exit 1
53+ fi
54+
55+ SDK_URL=$(yq -r '.manifest.projects[] | select(.name=="sdk-nrf") | .url' "$WEST_FILE")
56+ SDK_REVISION=$(yq -r '.manifest.projects[] | select(.name=="sdk-nrf") | .revision' "$WEST_FILE")
57+ SDK_COMMIT=$(git ls-remote "$SDK_URL" "$SDK_REVISION" | awk '{print $1}')
58+
59+ REPO="$GITHUB_REPOSITORY"
60+ REPO_URL="https://github.com/$GITHUB_REPOSITORY.git"
61+ BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
62+ REPO_COMMIT="$GITHUB_SHA"
63+
64+ echo "sdk-hash=$SDK_COMMIT" >> "$GITHUB_OUTPUT"
65+ echo "sdk-revision=$SDK_REVISION" >> "$GITHUB_OUTPUT"
66+ echo "repo=$REPO" >> "$GITHUB_OUTPUT"
67+ echo "repo-url=$REPO_URL" >> "$GITHUB_OUTPUT"
68+ echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
69+ echo "repo-hash=$REPO_COMMIT" >> "$GITHUB_OUTPUT"
70+
71+ - name : 🧰 Cache + Install Apt Dependencies
72+ id : cache-apt
73+ uses : awalsh128/cache-apt-pkgs-action@latest
74+ with :
75+ packages : >-
76+ git cmake ninja-build gperf dfu-util device-tree-compiler wget
77+ python3-dev python3-pip python3-setuptools python3-tk python3-wheel python3-venv
78+ xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
79+ version : 1.0
80+
81+ - name : 📦 Cache Zephyr SDK
82+ id : cache-sdk
83+ uses : actions/cache@v5
84+ with :
85+ path : ~/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
86+ key : zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
87+
88+ - name : 🪁 Install Zephyr SDK
89+ id : install-sdk
90+ if : steps.cache-sdk.outputs.cache-hit != 'true'
91+ run : |
92+ wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${{ env.ZEPHYR_SDK_VERSION }}/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}_linux-x86_64_minimal.tar.xz
93+ tar xf zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}_linux-x86_64_minimal.tar.xz -C ~/
94+ ~/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}/setup.sh -c -t arm-zephyr-eabi
95+
96+ - name : 📦 Cache West Workspace
97+ id : cache-west
98+ uses : actions/cache@v5
99+ with :
100+ path : |
101+ zephyr-workspace/.west
102+ zephyr-workspace/zephyr
103+ zephyr-workspace/nrf
104+ zephyr-workspace/modules
105+ zephyr-workspace/nrfxlib
106+ zephyr-workspace/bootloader
107+ zephyr-workspace/tools
108+ key : west-workspace-${{ steps.generate-vars.outputs.sdk-hash }}
109+
110+ - name : 📦 Cache Python venv
111+ id : cache-venv
112+ uses : actions/cache@v5
113+ with :
114+ path : ~/.venv
115+ key : venv-${{ env.ZEPHYR_SDK_VERSION }}
116+
117+ - name : 🐍 Setup Python venv + West
118+ id : setup-venv
119+ if : steps.cache-venv.outputs.cache-hit != 'true'
120+ run : |
121+ python3 -m venv ~/.venv
122+ ~/.venv/bin/pip install west ninja
123+
124+ - name : ♻️ Initialize Zephyr Workspace
125+ id : init-west
126+ run : |
127+ echo "$HOME/.venv/bin" >> $GITHUB_PATH
128+ export PATH="$HOME/.venv/bin:$PATH"
129+ cd zephyr-workspace
130+ if [ ! -d ".west" ]; then
131+ west init -l SlimeNRF-CI
132+ fi
133+ west update --narrow -o=--depth=1
134+ west zephyr-export
135+
136+ - name : 📦 Cache PIP Requirements
137+ id : cache-pip
138+ uses : actions/cache@v5
139+ with :
140+ path : ~/.venv
141+ key : venv-pip-${{ env.ZEPHYR_SDK_VERSION }}-${{ hashFiles('zephyr-workspace/zephyr/scripts/requirements.txt') }}
142+
143+ - name : 🐍 Install Zephyr Python Requirements
144+ id : install-pip
145+ if : steps.cache-pip.outputs.cache-hit != 'true'
146+ run : |
147+ cd zephyr-workspace
148+ ~/.venv/bin/pip install -r zephyr/scripts/requirements.txt
149+
150+ - name : 📦 Cache Repository
151+ id : cache-repository
152+ uses : actions/cache@v5
153+ with :
154+ path : zephyr-workspace/SlimeVR-Tracker-nRF
155+ key : firmware-${{ steps.generate-vars.outputs.repo-hash }}
156+
157+ - name : 📥 Clone Repository
158+ id : clone-repository
159+ if : steps.cache-repository.outputs.cache-hit != 'true'
160+ run : |
161+ cd zephyr-workspace
162+ rm -rf SlimeVR-Tracker-nRF
163+
164+ git clone --filter=blob:none --no-checkout "${{ steps.generate-vars.outputs.repo-url }}" SlimeVR-Tracker-nRF
165+ git -C SlimeVR-Tracker-nRF fetch origin "${{ steps.generate-vars.outputs.branch }}"
166+ git -C SlimeVR-Tracker-nRF checkout "${{ steps.generate-vars.outputs.repo-hash }}"
167+ git -C SlimeVR-Tracker-nRF submodule update --init --recursive --depth 1
168+
19169 build :
170+ needs : setup
20171 continue-on-error : true
21172 strategy :
22173 fail-fast : false
@@ -32,109 +183,103 @@ jobs:
32183 {boardname: "butterfly_p2_uf2/nrf52833", fileformat: "uf2", filename: "SlimeNRF_Butterfly_P2_Receiver"},
33184 {boardname: "butterfly_p3/nrf52820", fileformat: "hex", filename: "SlimeNRF_Butterfly_P3_Receiver"},
34185 ]
35- if : always()
36186 runs-on : ubuntu-latest
37187 steps :
38-
39- - name : 🧹 Clean Landing Site
40- run : |
41- sudo rm -rf zephyr-workspace/SlimeNRF-CI
42- - uses : actions/checkout@v5
188+ - name : 💻 Checkout Repository
189+ uses : actions/checkout@v6
43190 with :
44- # Clone the repo to a subdirectory, so we can initialize the Zephyr
45- # workspace in the parent directory.
46191 path : zephyr-workspace/SlimeNRF-CI
192+ submodules : recursive
47193
48- - name : 🧰 Install Dependencies + West
49- # Install the Zephyr host build dependencies, and the `west` Python tool. This list is from
50- # https://docs.zephyrproject.org/3.6.0/develop/getting_started/index.html#install-dependencies
51- run : |
52- sudo apt-get update && sudo apt install --no-install-recommends \
53- git \
54- cmake \
55- ninja-build \
56- gperf \
57- ccache \
58- dfu-util \
59- device-tree-compiler \
60- wget \
61- python3-dev \
62- python3-pip \
63- python3-setuptools \
64- python3-tk \
65- python3-wheel \
66- python3-venv \
67- xz-utils \
68- file \
69- make \
70- gcc \
71- gcc-multilib \
72- g++-multilib \
73- libsdl2-dev \
74- libmagic1
194+ - name : 🧰 Cache + Install Apt Dependencies
195+ id : restore-apt
196+ uses : awalsh128/cache-apt-pkgs-action@latest
197+ with :
198+ packages : >-
199+ git cmake ninja-build gperf dfu-util device-tree-compiler wget
200+ python3-dev python3-pip python3-setuptools python3-tk python3-wheel python3-venv
201+ xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
202+ version : 1.0
75203
76- python3 -m venv ~/.venv
77- source ~/.venv/bin/activate
78- # insert the PATH changes the venv activate made to be present for
79- # future steps
80- echo "PATH=$PATH" >> $GITHUB_ENV
81- pip3 install west ninja
204+ - name : 📦 Restore Zephyr SDK
205+ id : restore-sdk
206+ uses : actions/cache/restore@v5
207+ with :
208+ path : ~/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
209+ key : zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
210+ fail-on-cache-miss : true
82211
83- - name : 🪁 Install Zephyr SDK
84- # Fetch the Zephyr SDK from the GitHub Release artifact, unpack it and
85- # run the setup script, selecting the '-c' option to install cmake
86- # packages and the '-t arm-zephyr-eabi' option to install the toolchain
87- # only for the arm-zephyr-eabi (Cortex-M) architecture, since we don't
88- # need the other toolchains (xtensa, riscv, etc.)
212+ - name : 🪁 Register Zephyr SDK
213+ id : register-sdk
89214 run : |
90- wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/zephyr-sdk-0.17.4_linux-x86_64_minimal.tar.xz
91- tar xf zephyr-sdk-0.17.4_linux-x86_64_minimal.tar.xz -C ~/
92- ~/zephyr-sdk-0.17.4/setup.sh -c -t arm-zephyr-eabi
215+ ~/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}/setup.sh -c -t arm-zephyr-eabi
93216
94- - name : 📂 Cloning Triggered Repository/Branch
95- run : |
96- cd zephyr-workspace
97- git clone --single-branch --recurse-submodules -b $GITHUB_REF_NAME $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git
217+ - name : 📦 Restore West Workspace
218+ id : restore-west
219+ uses : actions/cache/restore@v5
220+ with :
221+ path : |
222+ zephyr-workspace/.west
223+ zephyr-workspace/zephyr
224+ zephyr-workspace/nrf
225+ zephyr-workspace/modules
226+ zephyr-workspace/nrfxlib
227+ zephyr-workspace/bootloader
228+ zephyr-workspace/tools
229+ key : west-workspace-${{ needs.setup.outputs.sdk-hash }}
230+ fail-on-cache-miss : true
98231
99- - name : ♻️ Initialize Zephyr Workspace
100- # Set up the Zephyr workspace and install the Python dependencies
232+ - name : 📦 Restore Python venv
233+ id : restore-venv
234+ uses : actions/cache/restore@v5
235+ with :
236+ path : ~/.venv
237+ key : venv-pip-${{ env.ZEPHYR_SDK_VERSION }}-${{ hashFiles('zephyr-workspace/zephyr/scripts/requirements.txt') }}
238+ restore-keys : |
239+ venv-pip-
240+ venv-
241+ fail-on-cache-miss : true
242+
243+ - name : ♻️ Register Zephyr Workspace
244+ id : register-west
101245 run : |
246+ echo "$HOME/.venv/bin" >> $GITHUB_PATH
247+ export PATH="$HOME/.venv/bin:$PATH"
102248 cd zephyr-workspace
103- sudo rm -rf .west
104- west init -l SlimeNRF-CI
105- west update --narrow -o=--depth=1
106249 west zephyr-export
107250
108- - name : 🐍 Install Python Dependencies
109- run : |
110- cd zephyr-workspace
111- pip3 install -r zephyr/scripts/requirements.txt
251+ - name : 📦 Restore Repository
252+ id : restore-repository
253+ uses : actions/cache/restore@v5
254+ with :
255+ path : zephyr-workspace/SlimeVR-Tracker-nRF
256+ key : firmware-${{ needs.setup.outputs.repo-hash }}
257+ fail-on-cache-miss : true
112258
113- - name : 🔨 Build SlimeVR-Tracker-nRF-Receiver - ${{ matrix.boards.boardname }}
114- # Receiver Firmware Build
259+ - name : 🔨 Build SlimeVR-Tracker-nRF - ${{ matrix.boards.boardname }}
260+ id : build-firmware
115261 if : always()
116262 run : |
117263 cd zephyr-workspace
264+ sed -i "/printk(FW_STRING);/a printk(\"Repo: ${{ needs.setup.outputs.repo }} | Branch: ${{ needs.setup.outputs.branch }} | SDK: ${{ needs.setup.outputs.sdk-revision }}\\\\n\");" SlimeVR-Tracker-nRF/src/console.c
118265 sudo rm -rf Releases
119- mkdir Releases
120- sudo rm -rf ${{ github.event.repository.name }}/build
121- mkdir ${{ github.event.repository.name }}/build
122-
266+ mkdir -p Releases
267+ rm -rf "SlimeVR-Tracker-nRF/build"
123268 west build \
124269 --board ${{ matrix.boards.boardname }} \
125- --pristine=always ${{ github.event.repository.name }} \
126- --build-dir ${{ github.event.repository.name }} /build \
270+ --pristine=always "SlimeVR-Tracker-nRF" \
271+ --build-dir "SlimeVR-Tracker-nRF /build" \
127272 -- \
128273 -DNCS_TOOLCHAIN_VERSION=NONE \
129- -DBOARD_ROOT=../${{ github.event.repository.name }}
274+ -DBOARD_ROOT=../"SlimeVR-Tracker-nRF"
130275
131- mv ${{ github.event.repository.name }} /build/${{ github.event.repository.name }} /zephyr/zephyr.${{ matrix.boards.fileformat }} Releases/${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
276+ mv SlimeVR-Tracker-nRF /build/SlimeVR-Tracker-nRF /zephyr/zephyr.${{ matrix.boards.fileformat }} Releases/${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
132277
133278 - name : 💾 Upload Artifact - ${{ matrix.boards.boardname }}
134- if : always()
135- uses : actions/upload-artifact@v5
279+ id : upload-artifact
280+ if : ${{ steps.build-firmware.outcome == 'success' }}
281+ uses : actions/upload-artifact@v7
136282 with :
137- # Artifact name
138- name : ${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
139- # A file, directory or wildcard pattern that describes what to upload
283+ name : ${{ matrix.boards.filename }}
284+ if-no-files-found : warn
140285 path : zephyr-workspace/Releases/${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
0 commit comments