Skip to content

Commit f941d7a

Browse files
author
root
committed
ci: add GitHub Actions workflow for cross-platform build and test
1 parent 9a0c1af commit f941d7a

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: ["main"]
9+
workflow_dispatch:
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
RUST_BACKTRACE: 1
14+
15+
jobs:
16+
test:
17+
name: Build & Test
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- os: ubuntu-latest
24+
target: x86_64-unknown-linux-gnu
25+
cronet_ext: tar.xz
26+
- os: ubuntu-latest
27+
target: aarch64-unknown-linux-gnu
28+
cronet_ext: tar.xz
29+
- os: macos-latest
30+
target: x86_64-apple-darwin
31+
cronet_ext: tar.xz
32+
- os: macos-latest
33+
target: aarch64-apple-darwin
34+
cronet_ext: tar.xz
35+
- os: windows-latest
36+
target: x86_64-pc-windows-msvc
37+
cronet_ext: zip
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Setup Rust
43+
uses: dtolnay/rust-toolchain@stable
44+
with:
45+
targets: ${{ matrix.target }}
46+
47+
- name: Setup Rust Cache
48+
uses: Swatinem/rust-cache@v2
49+
with:
50+
key: ${{ matrix.target }}
51+
52+
- name: Install cross-compilation tools (Linux ARM64)
53+
if: matrix.target == 'aarch64-unknown-linux-gnu'
54+
run: |
55+
sudo apt-get update
56+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libclang-dev
57+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
58+
59+
- name: Install dependencies (Linux x86_64)
60+
if: matrix.target == 'x86_64-unknown-linux-gnu'
61+
run: |
62+
sudo apt-get update
63+
sudo apt-get install -y libclang-dev
64+
65+
- name: Check Formatting
66+
run: cargo fmt --all -- --check
67+
continue-on-error: true
68+
69+
- name: Build (Default Backend)
70+
run: cargo build --release --target ${{ matrix.target }}
71+
72+
- name: Build (Cronet Backend)
73+
run: cargo build --release --features cronet-backend --target ${{ matrix.target }}
74+
75+
- name: Run Tests (Default Backend)
76+
if: matrix.target == 'x86_64-unknown-linux-gnu' || matrix.target == 'x86_64-apple-darwin' || matrix.target == 'x86_64-pc-windows-msvc'
77+
run: cargo test --release --target ${{ matrix.target }}
78+
79+
- name: Run Tests (Cronet Backend)
80+
if: matrix.target == 'x86_64-unknown-linux-gnu' || matrix.target == 'x86_64-apple-darwin' || matrix.target == 'x86_64-pc-windows-msvc'
81+
run: cargo test --release --features cronet-backend --target ${{ matrix.target }}

0 commit comments

Comments
 (0)