From 1ed292d4d6d9d3fc3c366e5fb4b50ff6793f4a3a Mon Sep 17 00:00:00 2001 From: nanase <1925792291@qq.com> Date: Fri, 24 Jul 2026 16:52:44 +0800 Subject: [PATCH 1/5] ci --- .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..882f41f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +# 触发条件:push 到主分支,或者向主分支发起 PR 时运行 +on: + push: + branches: ["main", "master"] + pull_request: + +# 取消同一分支上正在进行的旧任务,节省 CI 资源 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + # ---------- 代码格式检查 ---------- + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + # fmt 只检查格式,不需要系统依赖,跑得很快 + - name: Check formatting + run: cargo fmt --all -- --check + + # ---------- Clippy 静态检查 ---------- + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + # clippy 需要真正编译代码,因此要装 ffmpeg / slint 的系统依赖 + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + pkg-config \ + libavcodec-dev libavformat-dev libavutil-dev \ + libavfilter-dev libavdevice-dev libswscale-dev libswresample-dev \ + libfontconfig1-dev + + # 缓存依赖编译结果,加速后续 CI + - name: Cache cargo + uses: Swatinem/rust-cache@v2 + + - name: Run clippy + run: cargo clippy --all-targets -- -D warnings From 31b90853a39f77228e92a724eb140febbfa43805 Mon Sep 17 00:00:00 2001 From: nanase <1925792291@qq.com> Date: Fri, 24 Jul 2026 17:00:31 +0800 Subject: [PATCH 2/5] ci --- .github/workflows/ci.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 882f41f..623e089 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,15 +43,30 @@ jobs: with: components: clippy - # clippy 需要真正编译代码,因此要装 ffmpeg / slint 的系统依赖 + # clippy 需要真正编译代码,因此要装 slint / rodio 所需系统依赖 + # 注意:ffmpeg 不走 apt(版本太旧),改用下面的 setup-ffmpeg 提供 7.x - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y \ pkg-config \ - libavcodec-dev libavformat-dev libavutil-dev \ - libavfilter-dev libavdevice-dev libswscale-dev libswresample-dev \ - libfontconfig1-dev + libfontconfig1-dev \ + libasound2-dev + + # 安装 FFmpeg 7.x 的共享库(含头文件与 pkg-config 文件) + - name: Setup FFmpeg + id: ffmpeg + uses: FedericoCarboni/setup-ffmpeg@v3 + with: + ffmpeg-version: release + linking-type: shared + + # 让 ffmpeg-next 的 build.rs 能通过 pkg-config 找到 FFmpeg,并在链接期定位 .so + - name: Export FFmpeg env + run: | + FF_DIR="${{ steps.ffmpeg.outputs.ffmpeg-path }}" + echo "PKG_CONFIG_PATH=${FF_DIR}/lib/pkgconfig" >> "$GITHUB_ENV" + echo "LD_LIBRARY_PATH=${FF_DIR}/lib" >> "$GITHUB_ENV" # 缓存依赖编译结果,加速后续 CI - name: Cache cargo From a60a9476a046364b849fdef14f908e7dc8db9090 Mon Sep 17 00:00:00 2001 From: nanase <1925792291@qq.com> Date: Fri, 24 Jul 2026 17:06:07 +0800 Subject: [PATCH 3/5] ci --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 623e089..76c4098 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,11 +61,15 @@ jobs: ffmpeg-version: release linking-type: shared - # 让 ffmpeg-next 的 build.rs 能通过 pkg-config 找到 FFmpeg,并在链接期定位 .so + # setup-ffmpeg 的预编译包不含 pkg-config 的 .pc 文件, + # 因此改用 ffmpeg-sys-next 支持的 FFMPEG_DIR 变量,让它直接按目录链接。 - name: Export FFmpeg env run: | FF_DIR="${{ steps.ffmpeg.outputs.ffmpeg-path }}" - echo "PKG_CONFIG_PATH=${FF_DIR}/lib/pkgconfig" >> "$GITHUB_ENV" + echo "FFmpeg dir = ${FF_DIR}" + echo "----- 目录结构 (方便排查) -----" + ls -R "${FF_DIR}" | head -n 60 + echo "FFMPEG_DIR=${FF_DIR}" >> "$GITHUB_ENV" echo "LD_LIBRARY_PATH=${FF_DIR}/lib" >> "$GITHUB_ENV" # 缓存依赖编译结果,加速后续 CI From d4dd95b5f213943dd4872cbc46c6b5a06b099431 Mon Sep 17 00:00:00 2001 From: nanase <1925792291@qq.com> Date: Fri, 24 Jul 2026 17:09:54 +0800 Subject: [PATCH 4/5] ci --- .github/workflows/ci.yml | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76c4098..aab88ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,35 +43,17 @@ jobs: with: components: clippy - # clippy 需要真正编译代码,因此要装 slint / rodio 所需系统依赖 - # 注意:ffmpeg 不走 apt(版本太旧),改用下面的 setup-ffmpeg 提供 7.x + # clippy 需要真正编译代码,因此要装 ffmpeg / slint / rodio 所需系统依赖 - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y \ pkg-config \ + libavcodec-dev libavformat-dev libavutil-dev \ + libavfilter-dev libavdevice-dev libswscale-dev libswresample-dev \ libfontconfig1-dev \ libasound2-dev - # 安装 FFmpeg 7.x 的共享库(含头文件与 pkg-config 文件) - - name: Setup FFmpeg - id: ffmpeg - uses: FedericoCarboni/setup-ffmpeg@v3 - with: - ffmpeg-version: release - linking-type: shared - - # setup-ffmpeg 的预编译包不含 pkg-config 的 .pc 文件, - # 因此改用 ffmpeg-sys-next 支持的 FFMPEG_DIR 变量,让它直接按目录链接。 - - name: Export FFmpeg env - run: | - FF_DIR="${{ steps.ffmpeg.outputs.ffmpeg-path }}" - echo "FFmpeg dir = ${FF_DIR}" - echo "----- 目录结构 (方便排查) -----" - ls -R "${FF_DIR}" | head -n 60 - echo "FFMPEG_DIR=${FF_DIR}" >> "$GITHUB_ENV" - echo "LD_LIBRARY_PATH=${FF_DIR}/lib" >> "$GITHUB_ENV" - # 缓存依赖编译结果,加速后续 CI - name: Cache cargo uses: Swatinem/rust-cache@v2 From 085b9f67c4c57767acfac49634a6a0c0efe9f9c7 Mon Sep 17 00:00:00 2001 From: nanase <1925792291@qq.com> Date: Fri, 24 Jul 2026 17:16:02 +0800 Subject: [PATCH 5/5] ci --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aab88ed..993f3a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,5 +58,7 @@ jobs: - name: Cache cargo uses: Swatinem/rust-cache@v2 + # 不用 --all-targets:项目没有测试,且它会额外以 test 模式编译 bin, + # 导致仅被 main 使用的代码被误判为 dead_code。默认只编译 lib + bin 即可。 - name: Run clippy - run: cargo clippy --all-targets -- -D warnings + run: cargo clippy -- -D warnings