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
@@ -41,109 +192,103 @@ jobs:
41192 {boardname: "nrf52dk/nrf52832", fileformat: "hex", filename: "SlimeNRF_nRF52dk_Tracker"},
42193 {boardname: "nrf52840dk/nrf52840", fileformat: "hex", filename: "SlimeNRF_nRF52840dk_Tracker"},
43194 ]
44- if : always()
45195 runs-on : ubuntu-latest
46196 steps :
47-
48- - name : 🧹 Clean Landing Site
49- run : |
50- sudo rm -rf zephyr-workspace/SlimeNRF-CI
51- - uses : actions/checkout@v5
197+ - name : 💻 Checkout Repository
198+ uses : actions/checkout@v6
52199 with :
53- # Clone the repo to a subdirectory, so we can initialize the Zephyr
54- # workspace in the parent directory.
55200 path : zephyr-workspace/SlimeNRF-CI
201+ submodules : recursive
56202
57- - name : 🧰 Install Dependencies + West
58- # Install the Zephyr host build dependencies, and the `west` Python tool. This list is from
59- # https://docs.zephyrproject.org/3.6.0/develop/getting_started/index.html#install-dependencies
60- run : |
61- sudo apt-get update && sudo apt install --no-install-recommends \
62- git \
63- cmake \
64- ninja-build \
65- gperf \
66- ccache \
67- dfu-util \
68- device-tree-compiler \
69- wget \
70- python3-dev \
71- python3-pip \
72- python3-setuptools \
73- python3-tk \
74- python3-wheel \
75- python3-venv \
76- xz-utils \
77- file \
78- make \
79- gcc \
80- gcc-multilib \
81- g++-multilib \
82- libsdl2-dev \
83- libmagic1
203+ - name : 🧰 Cache + Install Apt Dependencies
204+ id : restore-apt
205+ uses : awalsh128/cache-apt-pkgs-action@latest
206+ with :
207+ packages : >-
208+ git cmake ninja-build gperf dfu-util device-tree-compiler wget
209+ python3-dev python3-pip python3-setuptools python3-tk python3-wheel python3-venv
210+ xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
211+ version : 1.0
84212
85- python3 -m venv ~/.venv
86- source ~/.venv/bin/activate
87- # insert the PATH changes the venv activate made to be present for
88- # future steps
89- echo "PATH=$PATH" >> $GITHUB_ENV
90- pip3 install west ninja
213+ - name : 📦 Restore Zephyr SDK
214+ id : restore-sdk
215+ uses : actions/cache/restore@v5
216+ with :
217+ path : ~/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
218+ key : zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
219+ fail-on-cache-miss : true
91220
92- - name : 🪁 Install Zephyr SDK
93- # Fetch the Zephyr SDK from the GitHub Release artifact, unpack it and
94- # run the setup script, selecting the '-c' option to install cmake
95- # packages and the '-t arm-zephyr-eabi' option to install the toolchain
96- # only for the arm-zephyr-eabi (Cortex-M) architecture, since we don't
97- # need the other toolchains (xtensa, riscv, etc.)
221+ - name : 🪁 Register Zephyr SDK
222+ id : register-sdk
98223 run : |
99- 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
100- tar xf zephyr-sdk-0.17.4_linux-x86_64_minimal.tar.xz -C ~/
101- ~/zephyr-sdk-0.17.4/setup.sh -c -t arm-zephyr-eabi
224+ ~/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}/setup.sh -c -t arm-zephyr-eabi
102225
103- - name : 📂 Cloning Triggered Repository/Branch
104- run : |
105- cd zephyr-workspace
106- git clone --single-branch --recurse-submodules -b $GITHUB_REF_NAME $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git
226+ - name : 📦 Restore West Workspace
227+ id : restore-west
228+ uses : actions/cache/restore@v5
229+ with :
230+ path : |
231+ zephyr-workspace/.west
232+ zephyr-workspace/zephyr
233+ zephyr-workspace/nrf
234+ zephyr-workspace/modules
235+ zephyr-workspace/nrfxlib
236+ zephyr-workspace/bootloader
237+ zephyr-workspace/tools
238+ key : west-workspace-${{ needs.setup.outputs.sdk-hash }}
239+ fail-on-cache-miss : true
107240
108- - name : ♻️ Initialize Zephyr Workspace
109- # Set up the Zephyr workspace and install the Python dependencies
241+ - name : 📦 Restore Python venv
242+ id : restore-venv
243+ uses : actions/cache/restore@v5
244+ with :
245+ path : ~/.venv
246+ key : venv-pip-${{ env.ZEPHYR_SDK_VERSION }}-${{ hashFiles('zephyr-workspace/zephyr/scripts/requirements.txt') }}
247+ restore-keys : |
248+ venv-pip-
249+ venv-
250+ fail-on-cache-miss : true
251+
252+ - name : ♻️ Register Zephyr Workspace
253+ id : register-west
110254 run : |
255+ echo "$HOME/.venv/bin" >> $GITHUB_PATH
256+ export PATH="$HOME/.venv/bin:$PATH"
111257 cd zephyr-workspace
112- sudo rm -rf .west
113- west init -l SlimeNRF-CI
114- west update --narrow -o=--depth=1
115258 west zephyr-export
116259
117- - name : 🐍 Install Python Dependencies
118- run : |
119- cd zephyr-workspace
120- pip3 install -r zephyr/scripts/requirements.txt
260+ - name : 📦 Restore Repository
261+ id : restore-repository
262+ uses : actions/cache/restore@v5
263+ with :
264+ path : zephyr-workspace/SlimeVR-Tracker-nRF
265+ key : firmware-${{ needs.setup.outputs.repo-hash }}
266+ fail-on-cache-miss : true
121267
122268 - name : 🔨 Build SlimeVR-Tracker-nRF - ${{ matrix.boards.boardname }}
123- # Receiver Firmware Build
269+ id : build-firmware
124270 if : always()
125271 run : |
126272 cd zephyr-workspace
273+ 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
127274 sudo rm -rf Releases
128- mkdir Releases
129- sudo rm -rf ${{ github.event.repository.name }}/build
130- mkdir ${{ github.event.repository.name }}/build
131-
275+ mkdir -p Releases
276+ rm -rf "SlimeVR-Tracker-nRF/build"
132277 west build \
133278 --board ${{ matrix.boards.boardname }} \
134- --pristine=always ${{ github.event.repository.name }} \
135- --build-dir ${{ github.event.repository.name }} /build \
279+ --pristine=always "SlimeVR-Tracker-nRF" \
280+ --build-dir "SlimeVR-Tracker-nRF /build" \
136281 -- \
137282 -DNCS_TOOLCHAIN_VERSION=NONE \
138- -DBOARD_ROOT=../${{ github.event.repository.name }}
283+ -DBOARD_ROOT=../"SlimeVR-Tracker-nRF"
139284
140- mv ${{ github.event.repository.name }} /build/${{ github.event.repository.name }} /zephyr/zephyr.${{ matrix.boards.fileformat }} Releases/${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
285+ mv SlimeVR-Tracker-nRF /build/SlimeVR-Tracker-nRF /zephyr/zephyr.${{ matrix.boards.fileformat }} Releases/${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
141286
142287 - name : 💾 Upload Artifact - ${{ matrix.boards.boardname }}
143- if : always()
144- uses : actions/upload-artifact@v5
288+ id : upload-artifact
289+ if : ${{ steps.build-firmware.outcome == 'success' }}
290+ uses : actions/upload-artifact@v7
145291 with :
146- # Artifact name
147- name : ${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
148- # A file, directory or wildcard pattern that describes what to upload
292+ name : ${{ matrix.boards.filename }}
293+ if-no-files-found : warn
149294 path : zephyr-workspace/Releases/${{ matrix.boards.filename }}.${{ matrix.boards.fileformat }}
0 commit comments