Windowsでのテスト, CIが通るよう修正 #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Linux Test | |
on: | |
push: | |
branches: [ master, main ] | |
pull_request: | |
branches: [ master, main ] | |
jobs: | |
# ────────────────────────────── | |
# 1. x86_64 と i686 用ジョブ | |
# ────────────────────────────── | |
cross: | |
name: Test on Linux (x86_64 & i686) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target_arch: x86_64-unknown-linux-gnu | |
needs_multilib: false | |
- target_arch: i686-unknown-linux-gnu | |
needs_multilib: true | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install build tools and cross-compilers | |
run: | | |
sudo apt-get update -qq | |
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
build-essential cmake git wget clang pkg-config | |
if [ "${{ matrix.needs_multilib }}" = "true" ]; then | |
sudo apt-get install -y gcc-multilib g++-multilib | |
fi | |
shell: bash | |
- name: Install target libraries and configure pkg-config | |
run: | | |
TARGET="${{ matrix.target_arch }}" | |
if [ "$TARGET" = "x86_64-unknown-linux-gnu" ]; then | |
sudo apt-get install -y libpcsclite-dev libdvbv5-dev libudev-dev | |
else | |
# マルチアーチ用 i386 を有効化 | |
sudo dpkg --add-architecture i386 | |
sudo apt-get update -qq | |
# i386 用 pkg-config とライブラリをインストール | |
sudo apt-get install -y \ | |
pkg-config:i386 \ | |
libpcsclite-dev:i386 \ | |
libdvbv5-dev:i386 \ | |
libudev-dev:i386 | |
# 以降の pkg-config 呼び出しを i386 用に向ける | |
echo "PKG_CONFIG=/usr/bin/pkg-config" >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: ${{ matrix.target_arch }} | |
override: true | |
default: true | |
- name: Cargo Check & Test | |
run: | | |
if [ "${{ matrix.target_arch }}" = "i686-unknown-linux-gnu" ]; then | |
cargo check -F dvb --target ${{ matrix.target_arch }} | |
cargo test -F dvb --target ${{ matrix.target_arch }} | |
else | |
cargo check -F dvb --target ${{ matrix.target_arch }} | |
cargo test -F dvb --target ${{ matrix.target_arch }} | |
fi | |
shell: bash | |
# ────────────────────────────── | |
# 2. aarch64 用ジョブ(QEMU → docker run) | |
# ────────────────────────────── | |
aarch64: | |
name: Test on Linux (ARM64 via Docker+QEMU) | |
runs-on: ubuntu-latest | |
needs: cross | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
# 1) ホスト上に QEMU の binfmt_misc 登録 | |
- name: Set up QEMU emulation | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/arm64 | |
# 2) ARM64 コンテナ内でビルド | |
- name: Run build inside ARM64 container | |
run: | | |
docker run --rm --privileged \ | |
--platform linux/arm64 \ | |
-v "${{ github.workspace }}:/work" \ | |
-w /work \ | |
ubuntu:22.04 \ | |
bash -lc "\ | |
apt-get update -qq && \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
build-essential cmake git wget clang pkg-config \ | |
libpcsclite-dev libdvbv5-dev libudev-dev gcc-aarch64-linux-gnu && \ | |
curl https://sh.rustup.rs -sSf | sh -s -- -y && \ | |
source \$HOME/.cargo/env && \ | |
rustup target add aarch64-unknown-linux-gnu && \ | |
# aarch64 用 pkg-config をインストールして切り替え | |
apt-get install -y pkg-config:aarch64 && \ | |
echo 'PKG_CONFIG=/usr/bin/pkg-config' | tee -a /etc/environment && \ | |
cargo check -F dvb --target aarch64-unknown-linux-gnu && \ | |
cargo test -F dvb --target aarch64-unknown-linux-gnu \ | |
" | |
shell: bash |