fix(ci): override crate-type via --config instead of --crate-type #8
Workflow file for this run
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
| # CI for cronet-rs | |
| # | |
| # Downloads pre-built libcronet binaries from rust-proxy/cronet-binaries | |
| # releases and runs cargo build (and cargo test where feasible) across | |
| # Linux, Android, macOS (Darwin), and Windows. | |
| # | |
| # Reference: github.com/rust-proxy/cronet-binaries (mirror branch) | |
| name: Build | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [next] | |
| pull_request: | |
| branches: [next] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
| cancel-in-progress: true | |
| env: | |
| RELEASE_ORG: rust-proxy | |
| RELEASE_REPO: cronet-binaries | |
| RELEASE_TAG: latest | |
| # Default: the linker searches for `libcronet.a`. | |
| # We rename the downloaded asset to match. | |
| CRONET_STATIC_NAME: cronet | |
| jobs: | |
| ############################################################################# | |
| # Linux — dynamic mode (.so downloaded) | |
| ############################################################################# | |
| linux: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - rust_target: x86_64-unknown-linux-gnu | |
| release_arch: amd64 | |
| suffix: so | |
| - rust_target: aarch64-unknown-linux-gnu | |
| release_arch: arm64 | |
| suffix: so | |
| linker: aarch64-linux-gnu-gcc | |
| cc_pkg: gcc-aarch64-linux-gnu | |
| - rust_target: arm-unknown-linux-gnueabihf | |
| release_arch: arm | |
| suffix: so | |
| linker: arm-linux-gnueabihf-gcc | |
| cc_pkg: gcc-arm-linux-gnueabihf | |
| - rust_target: i686-unknown-linux-gnu | |
| release_arch: "386" | |
| suffix: so | |
| linker: i686-linux-gnu-gcc | |
| cc_pkg: gcc-i686-linux-gnu | |
| env: | |
| ASSET: libcronet-linux-${{ matrix.release_arch }}.${{ matrix.suffix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: ${{ matrix.rust_target }} | |
| - name: Install cross-linker (non-native) | |
| if: matrix.linker != '' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ${{ matrix.cc_pkg }} | |
| - name: Download libcronet.so | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| mkdir -p lib | |
| gh release download "${{ env.RELEASE_TAG }}" \ | |
| --repo "${{ env.RELEASE_ORG }}/${{ env.RELEASE_REPO }}" \ | |
| --pattern "${{ env.ASSET }}" \ | |
| --output "lib/${{ env.ASSET }}" | |
| chmod +x "lib/${{ env.ASSET }}" | |
| ls -la lib/ | |
| - name: Build (dynamic) | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: ${{ matrix.linker }} | |
| CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: ${{ matrix.linker }} | |
| CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: ${{ matrix.linker }} | |
| run: cargo build --target ${{ matrix.rust_target }} | |
| - name: Test (native only) | |
| if: matrix.rust_target == 'x86_64-unknown-linux-gnu' | |
| env: | |
| LD_LIBRARY_PATH: ${{ github.workspace }}/lib | |
| run: | | |
| cargo test --target ${{ matrix.rust_target }} | |
| ############################################################################# | |
| # Android — static-link mode (.a downloaded + NDK) | |
| ############################################################################# | |
| android: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - rust_target: aarch64-linux-android | |
| release_arch: arm64 | |
| ndk_cc: aarch64-linux-android23-clang | |
| ndk_ar: llvm-ar | |
| - rust_target: x86_64-linux-android | |
| release_arch: amd64 | |
| ndk_cc: x86_64-linux-android23-clang | |
| ndk_ar: llvm-ar | |
| - rust_target: armv7-linux-androideabi | |
| release_arch: arm | |
| ndk_cc: armv7a-linux-androideabi23-clang | |
| ndk_ar: llvm-ar | |
| - rust_target: i686-linux-android | |
| release_arch: "386" | |
| ndk_cc: i686-linux-android23-clang | |
| ndk_ar: llvm-ar | |
| env: | |
| ASSET: libcronet-android-${{ matrix.release_arch }}.a | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: ${{ matrix.rust_target }} | |
| - name: Setup Android NDK | |
| uses: nttld/setup-ndk@v1 | |
| id: setup-ndk | |
| with: | |
| ndk-version: r28 | |
| - name: Download libcronet.a | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| mkdir -p lib | |
| gh release download "${{ env.RELEASE_TAG }}" \ | |
| --repo "${{ env.RELEASE_ORG }}/${{ env.RELEASE_REPO }}" \ | |
| --pattern "${{ env.ASSET }}" \ | |
| --output "lib/${{ env.ASSET }}" | |
| # Rename to libcronet.a so the linker finds it | |
| cp "lib/${{ env.ASSET }}" "lib/libcronet.a" | |
| ls -la lib/ | |
| - name: Workaround NDK r28 broken libdl.a | |
| run: | | |
| # NDK r28 ships a broken libdl.a (Invalid record) that breaks | |
| # Rust's -ldl linking. Remove it so the linker picks up libdl.so instead. | |
| NDK_CXX_DIR="${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib" | |
| find "$NDK_CXX_DIR" -name 'libdl.a' -delete | |
| - name: Build (static-link) | |
| env: | |
| CRONET_LIB_DIR: ${{ github.workspace }}/lib | |
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
| CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android23-clang | |
| CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android23-clang | |
| CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi23-clang | |
| CARGO_TARGET_I686_LINUX_ANDROID_LINKER: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android23-clang | |
| run: | | |
| # Export NDK bin to PATH for ar and other tools | |
| export PATH="${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH" | |
| # Override crate-type to exclude cdylib: libcronet.a for | |
| # x86_64/i686/arm-android was not compiled with -fPIC, so | |
| # producing a cdylib (.so) fails with PIC relocation errors. | |
| cargo build --target ${{ matrix.rust_target }} \ | |
| --features static-link \ | |
| --config 'lib.crate-type = ["lib"]' | |
| ############################################################################# | |
| # macOS (Darwin) — static-link mode (.a downloaded) | |
| ############################################################################# | |
| darwin: | |
| runs-on: macos-15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - rust_target: aarch64-apple-darwin | |
| release_arch: arm64 | |
| # macOS arm64 runner is native, no extra config needed | |
| - rust_target: x86_64-apple-darwin | |
| release_arch: amd64 | |
| env: | |
| ASSET: libcronet-darwin-${{ matrix.release_arch }}.a | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: ${{ matrix.rust_target }} | |
| - name: Download libcronet.a | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| mkdir -p lib | |
| gh release download "${{ env.RELEASE_TAG }}" \ | |
| --repo "${{ env.RELEASE_ORG }}/${{ env.RELEASE_REPO }}" \ | |
| --pattern "${{ env.ASSET }}" \ | |
| --output "lib/${{ env.ASSET }}" | |
| # Rename to libcronet.a for the linker | |
| cp "lib/${{ env.ASSET }}" "lib/libcronet.a" | |
| ls -la lib/ | |
| - name: Build (static-link) | |
| env: | |
| CRONET_LIB_DIR: ${{ github.workspace }}/lib | |
| run: | | |
| cargo build --target ${{ matrix.rust_target }} \ | |
| --features static-link | |
| - name: Test (native arm64) | |
| if: matrix.rust_target == 'aarch64-apple-darwin' | |
| env: | |
| CRONET_LIB_DIR: ${{ github.workspace }}/lib | |
| run: | | |
| cargo test --target ${{ matrix.rust_target }} \ | |
| --features static-link | |
| ############################################################################# | |
| # Windows — dynamic mode (.dll downloaded) | |
| ############################################################################# | |
| windows: | |
| runs-on: windows-2022 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - rust_target: x86_64-pc-windows-msvc | |
| release_arch: amd64 | |
| - rust_target: aarch64-pc-windows-msvc | |
| release_arch: arm64 | |
| env: | |
| ASSET: libcronet-windows-${{ matrix.release_arch }}.dll | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: ${{ matrix.rust_target }} | |
| - name: Download libcronet.dll | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| shell: bash | |
| run: | | |
| mkdir -p lib | |
| gh release download "${{ env.RELEASE_TAG }}" \ | |
| --repo "${{ env.RELEASE_ORG }}/${{ env.RELEASE_REPO }}" \ | |
| --pattern "${{ env.ASSET }}" \ | |
| --output "lib/${{ env.ASSET }}" | |
| ls -la lib/ | |
| - name: Build (dynamic) | |
| run: cargo build --target ${{ matrix.rust_target }} | |
| # Test step — use pwsh instead of bash to keep cargo in PATH | |
| - name: Test (native amd64 only) | |
| if: matrix.rust_target == 'x86_64-pc-windows-msvc' | |
| env: | |
| CRONET_DLL_DIR: ${{ github.workspace }}\lib | |
| shell: pwsh | |
| run: | | |
| # Add lib dir to PATH so the .dll can be found at runtime | |
| $env:Path = "${{ github.workspace }}\lib;" + $env:Path | |
| cargo test --target ${{ matrix.rust_target }} |