Skip to content

Commit 5b68378

Browse files
committed
github: optimize CI
- Pass filter:tree=0 to reduce download size - Initialize and use ccache - Run CI on PRs and on 'arduino' branch pushes only
1 parent bd3a17b commit 5b68378

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Build native Zephyr samples
22

33
on: [push, pull_request]
44

@@ -8,17 +8,20 @@ jobs:
88
container: zephyrprojectrtos/ci:latest
99
env:
1010
CMAKE_PREFIX_PATH: /opt/toolchains
11-
PR_NUMBER: ${{ github.event.number }}
11+
CCACHE_IGNOREOPTIONS: -specs=*
12+
HEAD_REF: ${{ github.event.pull_request && github.event.pull_request.head.ref || github.ref }}
13+
REPOSITORY: ${{ github.event.pull_request && github.event.pull_request.head.repo.full_name || github.repository }}
1214
steps:
1315
- name: Initialize
1416
run: |
1517
mkdir build && cd build
16-
west init -m https://github.com/${{ github.repository }}
17-
cd modules/lib/ArduinoCore-zephyr/
18-
git fetch origin ${{ github.ref }}
19-
git checkout FETCH_HEAD
20-
cd -
21-
west update
18+
west init -m https://github.com/${{ env.REPOSITORY }} --mr ${{ env.HEAD_REF }}
19+
west update -o=--filter=tree:0
20+
21+
- name: ccache
22+
uses: hendrikmuhs/ccache-action@v1.2
23+
with:
24+
verbose: 1
2225

2326
- name: Build fade
2427
working-directory: build
@@ -33,4 +36,4 @@ jobs:
3336
- name: Build adc
3437
working-directory: build
3538
run: |
36-
west build -p -b arduino_nano_33_ble/nrf52840/sense modules/lib/ArduinoCore-zephyr/samples/analog_input
39+
west build -p -b arduino_nano_33_ble/nrf52840/sense modules/lib/ArduinoCore-zephyr/samples/analog_input

.github/workflows/package_core.yml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,56 @@
1-
name: Package core
1+
name: Package, test and upload core
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- arduino
7+
pull_request:
48

59
jobs:
6-
build:
10+
11+
package-core:
12+
name: Build and package core
713
runs-on: ubuntu-latest
814
env:
915
ZEPHYR_SDK_INSTALL_DIR: /opt/zephyr-sdk-0.16.8
16+
CCACHE_IGNOREOPTIONS: -specs=*
1017
steps:
1118
- name: Install toolchain
1219
working-directory: /opt
1320
run: |
1421
sudo apt-get update
15-
sudo apt-get install -y --no-install-recommends git cmake wget python3-pip ninja-build
16-
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz
22+
sudo apt-get install -y --no-install-recommends git cmake wget python3-pip ninja-build ccache
23+
wget -nv https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz
1724
tar xf zephyr-sdk-0.16.8_linux-x86_64_minimal.tar.xz && cd zephyr-sdk-0.16.8 && ./setup.sh -t arm-zephyr-eabi -c
1825
1926
- uses: actions/checkout@v4
2027

2128
- name: Initialize
2229
run: |
23-
./extra/bootstrap.sh
24-
./extra/build_all.sh
25-
./extra/package.sh `git describe --always`
26-
mv ../arduino-core-zephyr-llext* .
30+
./extra/bootstrap.sh -o=--filter=tree:0
31+
echo "CORE_TAG=$(git describe --always)" >> "$GITHUB_ENV"
32+
echo "CORE_ARTIFACT=ArduinoCore-zephyr-$(git describe --always)" >> "$GITHUB_ENV"
33+
echo "BOARD_NAMES=[ $(cat boards.txt | grep '^[^#]*\.build\.variant' | cut -d '.' -f 1 | xargs printf '"%s",' | sed -e 's/,$//') ]" >> "$GITHUB_ENV"
34+
35+
- name: ccache
36+
uses: hendrikmuhs/ccache-action@v1.2
37+
with:
38+
verbose: 1
39+
40+
- name: Build variants
41+
run: |
42+
./extra/build_all.sh -f
43+
44+
- name: Package
45+
run: |
46+
./extra/package.sh ${{ env.CORE_TAG }}
47+
mv ../${{ env.CORE_ARTIFACT }}.tar.bz2 .
2748
2849
- name: Archive core
2950
uses: actions/upload-artifact@v4
3051
with:
31-
name: Core
32-
path: arduino-core-zephyr-llext*
52+
name: ${{ env.CORE_ARTIFACT }}
53+
path: ${{ env.CORE_ARTIFACT }}.tar.bz2
3354

3455
- name: Create Blink sketch
3556
run: |

extra/bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ python3 -m venv venv
99
source venv/bin/activate
1010
pip install west
1111
west init -l .
12-
west update
12+
west update "$@"
1313
west zephyr-export
1414
pip install -r ../zephyr/scripts/requirements-base.txt
1515
# download slim toolchain from https://github.com/zephyrproject-rtos/sdk-ng/releases/tag/v0.16.8

extra/package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ FOLDER=`basename $PWD`
1010
VERSION=$1
1111

1212
cd ..
13-
tar --exclude=extras/** --exclude=.git* --exclude=build --exclude=venv --exclude=samples -cjhf arduino-core-zephyr-llext-${VERSION}.tar.bz2 $FOLDER
13+
tar --exclude=extras/** --exclude=.git* --exclude=build --exclude=venv --exclude=samples -cjhf ArduinoCore-zephyr-${VERSION}.tar.bz2 $FOLDER

0 commit comments

Comments
 (0)