Skip to content

Commit fbe79e5

Browse files
committed
ci: twister: use filter cache
Signed-off-by: Anas Nashif <[email protected]>
1 parent dd6929b commit fbe79e5

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

.github/workflows/twister.yaml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- v*-branch
88
- collab-*
9+
- topic/twister/filter_cache
910
pull_request_target:
1011
branches:
1112
- main
@@ -56,28 +57,28 @@ jobs:
5657
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
5758
5859
- name: Clone cached Zephyr repository
59-
if: github.event_name == 'pull_request_target'
60+
#if: github.event_name == 'pull_request_target'
6061
continue-on-error: true
6162
run: |
6263
git clone --shared /repo-cache/zephyrproject/zephyr .
6364
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
6465
6566
- name: Checkout
66-
if: github.event_name == 'pull_request_target'
67+
#if: github.event_name == 'pull_request_target'
6768
uses: actions/checkout@v4
6869
with:
6970
ref: ${{ github.event.pull_request.head.sha }}
7071
fetch-depth: 0
7172
persist-credentials: false
7273

7374
- name: Environment Setup
74-
if: github.event_name == 'pull_request_target'
75+
#if: github.event_name == 'pull_request_target'
7576
run: |
7677
git config --global user.email "[email protected]"
7778
git config --global user.name "Zephyr Bot"
78-
rm -fr ".git/rebase-apply"
79-
git rebase origin/${BASE_REF}
80-
git clean -f -d
79+
#rm -fr ".git/rebase-apply"
80+
#git rebase origin/${BASE_REF}
81+
#git clean -f -d
8182
git log --pretty=oneline | head -n 10
8283
west init -l . || true
8384
west config manifest.group-filter -- +ci,+optional
@@ -123,6 +124,29 @@ jobs:
123124
echo "subset=${subset}" >> $GITHUB_OUTPUT
124125
echo "size=${size}" >> $GITHUB_OUTPUT
125126
echo "fullrun=${TWISTER_FULL}" >> $GITHUB_OUTPUT
127+
- name: generate filter cache
128+
if: github.event_name == 'push'
129+
run: |
130+
export ZEPHYR_BASE=${PWD}
131+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
132+
python3 ./scripts/twister --cmake-only -T samples/synchronization/ --outdir filter_cache --force-color --inline-logs -v
133+
cd filter_cache
134+
for d in `ls -1`; do
135+
mkdir -p cache/${d};
136+
test -f $d/samples/synchronization/sample.kernel.synchronization/zephyr/.config && \
137+
cp $d/samples/synchronization/sample.kernel.synchronization/zephyr/.config cache/${d} && \
138+
cp $d/samples/synchronization/sample.kernel.synchronization/zephyr/edt.pickle cache/${d} && \
139+
cp $d/samples/synchronization/sample.kernel.synchronization/CMakeCache.txt cache/${d};
140+
done
141+
mv cache ../twister_cache
142+
- name: Upload Filter Cache
143+
if: always()
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: filter_cache
147+
if-no-files-found: ignore
148+
path: |
149+
twister_cache
126150
127151
twister-build:
128152
runs-on:
@@ -228,12 +252,18 @@ jobs:
228252
west update
229253
make everything -s -j 8
230254
255+
- if: github.event_name == 'push'
256+
name: Download Artifacts
257+
uses: actions/download-artifact@v4
258+
with:
259+
path: filter_cache
260+
231261
- if: github.event_name == 'push'
232262
name: Run Tests with Twister (Push)
233263
run: |
234264
export ZEPHYR_BASE=${PWD}
235265
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
236-
./scripts/twister --subset ${{matrix.subset}}/${{ strategy.job-total }} ${TWISTER_COMMON} ${PUSH_OPTIONS}
266+
./scripts/twister --subset ${{matrix.subset}}/${{ strategy.job-total }} ${TWISTER_COMMON} ${PUSH_OPTIONS} --filter-cache filter_cache/filter_cache
237267
if [ "${{matrix.subset}}" = "1" ]; then
238268
./scripts/zephyr_module.py --twister-out module_tests.args
239269
if [ -s module_tests.args ]; then

0 commit comments

Comments
 (0)