Skip to content

Commit 7c85a09

Browse files
committed
v2
1 parent b3d391c commit 7c85a09

3 files changed

Lines changed: 92 additions & 52 deletions

File tree

.github/workflows/update-image.yml

Lines changed: 80 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,8 @@ jobs:
7272
include:
7373
- arch: amd64
7474
runner: ubuntu-latest
75-
cross_target: arm64
76-
cross_triplet: aarch64-linux-gnu
77-
expected_machine: AArch64
7875
- arch: arm64
7976
runner: ubuntu-24.04-arm
80-
cross_target: amd64
81-
cross_triplet: x86_64-linux-gnu
82-
expected_machine: X86-64
8377
runs-on: ${{ matrix.runner }}
8478
steps:
8579
- name: Checkout repository
@@ -158,44 +152,6 @@ jobs:
158152
cache-from: type=gha,scope=docker-build-develop-full-${{ matrix.arch }}
159153
cache-to: type=gha,mode=max,scope=docker-build-develop-full-${{ matrix.arch }}
160154

161-
- name: Smoke test (cross build + readelf)
162-
env:
163-
IMAGE_DIGEST: ${{ steps.build_develop_full.outputs.digest }}
164-
CROSS_TARGET: ${{ matrix.cross_target }}
165-
CROSS_TRIPLET: ${{ matrix.cross_triplet }}
166-
EXPECTED_MACHINE: ${{ matrix.expected_machine }}
167-
run: |
168-
set -euo pipefail
169-
uid="$(id -u)"
170-
gid="$(id -g)"
171-
docker run --rm \
172-
--platform "linux/${{ matrix.arch }}" \
173-
--user "${uid}:${gid}" \
174-
-e HOME=/tmp/rmcs-home \
175-
-e RMCS_PATH=/workspaces/RMCS \
176-
-e CROSS_TARGET="${CROSS_TARGET}" \
177-
-e CROSS_TRIPLET="${CROSS_TRIPLET}" \
178-
-e EXPECTED_MACHINE="${EXPECTED_MACHINE}" \
179-
-v "$PWD:/workspaces/RMCS" \
180-
-w /workspaces/RMCS \
181-
"${{ env.REGISTRY_IMAGE_DEVELOP }}@${IMAGE_DIGEST}" \
182-
bash -lc '
183-
set -euo pipefail
184-
mkdir -p "${HOME}"
185-
test -d "/opt/sysroots/${CROSS_TARGET}"
186-
command -v "${CROSS_TRIPLET}-gcc"
187-
command -v "${CROSS_TRIPLET}-g++"
188-
./.script/build-rmcs-cross --target-arch "${CROSS_TARGET}" --packages-up-to rmcs_executor
189-
lib_dir="/workspaces/RMCS/rmcs_ws/install-cross-${CROSS_TARGET}/lib"
190-
for lib in librmcs_core.so librmcs_executor.so libserial.so; do
191-
if [[ ! -f "${lib_dir}/${lib}" ]]; then
192-
echo "Missing library: ${lib_dir}/${lib}" >&2
193-
exit 1
194-
fi
195-
readelf -h "${lib_dir}/${lib}" | grep -q "Machine:.*${EXPECTED_MACHINE}"
196-
done
197-
'
198-
199155
- name: Export digest (Develop Full)
200156
run: |
201157
mkdir -p "${{ runner.temp }}/digests-develop-full"
@@ -233,11 +189,90 @@ jobs:
233189
if-no-files-found: error
234190
retention-days: 1
235191

236-
merge:
192+
verify_images:
193+
needs: build_images
194+
strategy:
195+
fail-fast: false
196+
matrix:
197+
include:
198+
- arch: amd64
199+
runner: ubuntu-latest
200+
cross_target: arm64
201+
cross_triplet: aarch64-linux-gnu
202+
expected_machine: AArch64
203+
- arch: arm64
204+
runner: ubuntu-24.04-arm
205+
cross_target: amd64
206+
cross_triplet: x86_64-linux-gnu
207+
expected_machine: X86-64
208+
runs-on: ${{ matrix.runner }}
209+
steps:
210+
- name: Checkout repository
211+
uses: actions/checkout@v4
212+
213+
- name: Log in to Docker Hub
214+
uses: docker/login-action@v3
215+
with:
216+
username: ${{ secrets.DOCKERHUB_USERNAME }}
217+
password: ${{ secrets.DOCKERHUB_TOKEN }}
218+
219+
- name: Download digests (Develop Full)
220+
uses: actions/download-artifact@v7
221+
with:
222+
path: ${{ runner.temp }}/digests/develop-full
223+
pattern: digests-develop-full-*
224+
merge-multiple: true
225+
226+
- name: Resolve develop-full digest
227+
id: resolve
228+
run: |
229+
set -euo pipefail
230+
digest_file="${{ runner.temp }}/digests/develop-full/${{ matrix.arch }}.digest"
231+
image_digest="$(cat "${digest_file}")"
232+
echo "image_digest=${image_digest}" >> "$GITHUB_OUTPUT"
233+
234+
- name: Smoke test (cross build + readelf)
235+
env:
236+
IMAGE_DIGEST: ${{ steps.resolve.outputs.image_digest }}
237+
CROSS_TARGET: ${{ matrix.cross_target }}
238+
CROSS_TRIPLET: ${{ matrix.cross_triplet }}
239+
EXPECTED_MACHINE: ${{ matrix.expected_machine }}
240+
run: |
241+
set -euo pipefail
242+
uid="$(id -u)"
243+
gid="$(id -g)"
244+
docker run --rm \
245+
--platform "linux/${{ matrix.arch }}" \
246+
--user "${uid}:${gid}" \
247+
-e HOME=/tmp/rmcs-home \
248+
-e RMCS_PATH=/workspaces/RMCS \
249+
-e CROSS_TARGET="${CROSS_TARGET}" \
250+
-e CROSS_TRIPLET="${CROSS_TRIPLET}" \
251+
-e EXPECTED_MACHINE="${EXPECTED_MACHINE}" \
252+
-v "$PWD:/workspaces/RMCS" \
253+
-w /workspaces/RMCS \
254+
"${{ env.REGISTRY_IMAGE_DEVELOP }}@${IMAGE_DIGEST}" \
255+
bash -lc '
256+
set -euo pipefail
257+
mkdir -p "${HOME}"
258+
test -d "/opt/sysroots/${CROSS_TARGET}"
259+
command -v "${CROSS_TRIPLET}-gcc"
260+
command -v "${CROSS_TRIPLET}-g++"
261+
./.script/build-rmcs-cross --target-arch "${CROSS_TARGET}" --packages-up-to rmcs_executor
262+
lib_path="/workspaces/RMCS/rmcs_ws/install-cross-${CROSS_TARGET}/lib/librmcs_executor.so"
263+
if [[ ! -f "${lib_path}" ]]; then
264+
echo "Missing library: ${lib_path}" >&2
265+
exit 1
266+
fi
267+
readelf -h "${lib_path}" | grep -q "Machine:.*${EXPECTED_MACHINE}"
268+
'
269+
270+
promote:
237271
runs-on: ubuntu-latest
238272
needs:
239273
- build_base
240274
- build_images
275+
- verify_images
241276
steps:
242277
- name: Download digests (Base)
243278
uses: actions/download-artifact@v7

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,17 @@ build-rmcs
7272

7373
Note: 用于开发的所有脚本均位于 `.script` 中,参见 开发脚本手册(TODO)。
7474

75-
如需在 `latest-full` 中执行交叉编译,可使用
75+
如需在 `latest-full` 中执行交叉编译,请根据当前容器架构选择对向目标
7676
```bash
7777
build-rmcs-cross --target-arch arm64
7878
```
79-
或:
79+
适用于 `linux/amd64``latest-full` 变体。
80+
8081
```bash
8182
build-rmcs-cross --target-arch amd64
8283
```
84+
适用于 `linux/arm64``latest-full` 变体。
85+
8386
详见 [交叉编译使用说明](docs/zh-cn/cross_build.md)
8487

8588
### Step 5 (Optional):运行

docs/zh-cn/cross_build.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@
2525

2626
## 3. 使用方式
2727

28-
`latest-full` 容器里执行
28+
`latest-full` 容器里,根据当前容器架构执行对向架构的交叉编译
2929

3030
```bash
3131
build-rmcs-cross --target-arch arm64
3232
```
3333

34-
或:
34+
适用于 `linux/amd64``latest-full` 变体。
3535

3636
```bash
3737
build-rmcs-cross --target-arch amd64
3838
```
3939

40-
可追加常见 `colcon build` 参数,例如:
40+
适用于 `linux/arm64``latest-full` 变体。
41+
42+
例如,可追加常见 `colcon build` 参数:
4143

4244
```bash
4345
build-rmcs-cross --target-arch arm64 --packages-up-to rmcs_executor
@@ -65,7 +67,7 @@ build-rmcs-cross --target-arch arm64 --packages-up-to rmcs_executor
6567
test -d /opt/sysroots/arm64
6668
command -v aarch64-linux-gnu-gcc
6769
./.script/build-rmcs-cross --target-arch arm64 --packages-up-to rmcs_executor
68-
readelf -h rmcs_ws/install-cross-arm64/lib/librmcs_core.so
70+
readelf -h rmcs_ws/install-cross-arm64/lib/librmcs_executor.so
6971
```
7072

7173
若目标为 `amd64`,将上述 `arm64/aarch64-linux-gnu` 替换为 `amd64/x86_64-linux-gnu`
@@ -80,4 +82,4 @@ readelf -h rmcs_ws/install-cross-arm64/lib/librmcs_core.so
8082
- sysroot 目录存在
8183
- cross 编译器可执行
8284
- `build-rmcs-cross --target-arch <opposite>` 可完成构建
83-
- `readelf -h` 校验关键 so 架构
85+
- `readelf -h` 校验 `librmcs_executor.so` 架构

0 commit comments

Comments
 (0)