Repository navigation
216 lines (199 loc) · 7.69 KB
/
Copy pathbluetooth.yml
File metadata and controls
216 lines (199 loc) · 7.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
name: Bluetooth
on:
pull_request:
paths-ignore:
- "**/*.md"
- "Documentation/**"
- "**/CODEOWNERS"
push:
branches:
- master
- "releases/*"
workflow_dispatch:
inputs:
companion_ref:
description: >-
Branch, tag, SHA or refs/pull/N/head in the companion repository
default: master
required: true
type: string
permissions:
contents: read
pull-requests: read
defaults:
run:
shell: bash
concurrency:
group: bluetooth-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BSWORLD_REVISION: bf94e2fcc0c876e244dafcea4fb0ea5ed3a1c157
NUTTX_REPOSITORY: ${{ github.repository }}
APPS_REPOSITORY: apache/nuttx-apps
BUILD_JOBS: 4
PYTHONDONTWRITEBYTECODE: 1
jobs:
bluetooth:
runs-on: ubuntu-24.04
timeout-minutes: 90
steps:
- name: Checkout NuttX
uses: actions/checkout@v7
with:
repository: ${{ env.NUTTX_REPOSITORY }}
ref: >-
${{ env.NUTTX_REPOSITORY == github.repository && github.sha
|| inputs.companion_ref || github.base_ref
|| (startsWith(github.ref, 'refs/heads/releases/')
&& github.ref_name)
|| 'master' }}
path: nuttx
persist-credentials: false
- name: Checkout applications
uses: actions/checkout@v7
with:
repository: ${{ env.APPS_REPOSITORY }}
ref: >-
${{ env.APPS_REPOSITORY == github.repository && github.sha
|| inputs.companion_ref || github.base_ref
|| (startsWith(github.ref, 'refs/heads/releases/')
&& github.ref_name)
|| 'master' }}
path: apps
persist-credentials: false
- name: Apply Depends-On changes
if: github.event_name == 'pull_request' && github.base_ref == 'master'
env:
GH_TOKEN: ${{ github.token }}
PR_BODY: ${{ github.event.pull_request.body }}
PR_NUMBER: ${{ github.event.pull_request.number }}
shell: bash
run: |
. nuttx/.github/scripts/gh_api_retry.sh
# Reuse the parser used by the main build workflow.
if body=$(gh_api_retry "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" \
--jq '.body // ""'); then
export PR_BODY="$body"
else
echo "::warning::Could not re-read the PR description;" \
"using the event payload."
fi
python3 nuttx/.github/scripts/depends_on.py --print-state \
> "$RUNNER_TEMP/bluetooth-dependencies"
read -r state < "$RUNNER_TEMP/bluetooth-dependencies"
if [ "$state" = invalid ]; then
echo "::warning::Invalid Depends-On declaration;" \
"using the normal source selection."
exit 0
fi
git config --global user.name github-actions
git config --global user.email github-actions@github.com
while read -r dependency; do
repo=${dependency%/pull/*}
number=${dependency##*/}
case "$repo" in
apache/nuttx) tree=nuttx ;;
apache/nuttx-apps) tree=apps ;;
*) exit 1 ;;
esac
query='[.state, .merged, (.merge_commit_sha // "-")] | @tsv'
if info=$(gh_api_retry "repos/$repo/pulls/$number" --jq "$query"); then
read -r status merged merge_sha <<< "$info"
else
echo "::warning::Could not read the state of $dependency;" \
"applying it."
status=unknown
merged=false
merge_sha=-
fi
if [ "$status" = closed ] && [ "$merged" != true ]; then
echo "::error::Dependency $dependency is closed without merging"
exit 1
fi
if [ -f "$tree/.git/shallow" ]; then
git -C "$tree" fetch --unshallow origin
fi
git -C "$tree" fetch "https://github.com/$repo.git" \
"pull/$number/head"
dependency_sha=$(git -C "$tree" rev-parse FETCH_HEAD)
if [ "$merged" = true ] &&
git -C "$tree" merge-base --is-ancestor "$merge_sha" HEAD; then
continue
fi
git -C "$tree" merge-base HEAD "$dependency_sha" > /dev/null
if ! commit_list=$(git -C "$tree" rev-list \
--reverse "HEAD..$dependency_sha"); then
echo "::error::Could not list commits for $dependency"
exit 1
fi
if [ -n "$commit_list" ]; then
mapfile -t commits <<< "$commit_list"
git -C "$tree" cherry-pick "${commits[@]}"
fi
done < <(tail -n +2 "$RUNNER_TEMP/bluetooth-dependencies")
- name: Checkout the validated BSWorld revision
uses: actions/checkout@v7
with:
repository: XiaoMi/bsworld
ref: ${{ env.BSWORLD_REVISION }}
path: bsworld
persist-credentials: false
- name: Install native build prerequisites
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential gcc-multilib g++-multilib lib32z1-dev \
python3.12-dev python3.12-venv repo rsync \
autoconf automake bison flex gettext texinfo gperf \
libtool pkg-config \
libncurses-dev xxd genromfs kconfig-frontends \
wget unzip xz-utils
- name: Cache the fixed simulation infrastructure
uses: actions/cache@v6
with:
path: .bluetooth-ci/dependencies
key: >-
bluetooth-v1-ubuntu24.04-python3.12-${{ runner.arch }}-${{
env.BSWORLD_REVISION }}-${{
hashFiles('apps/testing/bluetooth/bsworld/prepare.sh') }}
- name: Prepare BabbleSim and the Python Controller
run: |
mkdir -p bluetooth-results
bash apps/testing/bluetooth/bsworld/prepare.sh \
"$PWD/bsworld" "$PWD/.bluetooth-ci/dependencies" \
2>&1 | tee bluetooth-results/prepare.log
- name: Build the current NuttX and applications sources
run: |
bash apps/testing/bluetooth/bsworld/build.sh \
"$PWD/nuttx" "$PWD/apps" "$PWD/.bluetooth-ci/dependencies" \
"$RUNNER_TEMP/bluetooth-build" "$PWD/bluetooth-results"
- name: Run Bluetooth integration tests
run: |
source .bluetooth-ci/dependencies/env.sh
firmware="$PWD/bluetooth-results/firmware"
export BSWORLD_NUTTX_BTSAK_BIN="$firmware/btsak"
export BSWORLD_NUTTX_NIMBLE_BIN="$firmware/nimble"
python -m pytest -c apps/testing/bluetooth/bsworld/pytest.ini \
apps/testing/bluetooth/bsworld -v -n 2 -p no:cacheprovider \
--out-dir "$PWD/bluetooth-results/runtime" \
--junitxml="$PWD/bluetooth-results/bluetooth.xml" \
2>&1 | tee bluetooth-results/bluetooth.log
- name: Upload Bluetooth results
if: always()
uses: actions/upload-artifact@v7.0.2
with:
name: bluetooth-results
path: bluetooth-results/