Skip to content

Commit 336eba4

Browse files
bergwolferyugey
authored andcommitted
action: add cross arch build tests
Signed-off-by: Peng Tao <[email protected]>
1 parent 8369300 commit 336eba4

File tree

2 files changed

+52
-30
lines changed

2 files changed

+52
-30
lines changed

.github/workflows/rust.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ env:
1414
jobs:
1515
CI:
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
arch: [amd64, arm64, ppc64le, riscv64, s390x]
1720
steps:
1821
- uses: actions/checkout@v3
22+
- name: Cache cargo
23+
uses: Swatinem/[email protected]
24+
with:
25+
cache-on-failure: true
26+
key: ${{ runner.os }}-cargo-${{ matrix.arch }}
1927

2028
- name: Install Rust
2129
uses: actions-rs/toolchain@v1
@@ -25,9 +33,16 @@ jobs:
2533
override: true
2634

2735
- name: build and check
28-
run: make check
36+
run: |
37+
declare -A rust_target_map=( ["amd64"]="x86_64-unknown-linux-musl" ["arm64"]="aarch64-unknown-linux-musl" ["ppc64le"]="powerpc64le-unknown-linux-gnu" ["riscv64"]="riscv64gc-unknown-linux-gnu" ["s390x"]="s390x-unknown-linux-gnu")
38+
RUST_TARGET=${rust_target_map[${{ matrix.arch }}]}
39+
cargo install --version 0.2.4 cross
40+
rustup component add rustfmt clippy
41+
make -e RUST_TARGET=$RUST_TARGET -e CARGO=cross check
2942
- name: smoke
43+
if: ${{ matrix.arch == 'amd64' }}
3044
run: |
45+
make test
3146
echo user_allow_other | sudo tee --append /etc/fuse.conf
3247
make smoke-all
3348

Makefile

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
current_dir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
2+
CARGO ?= $(shell which cargo)
3+
4+
ifdef RUST_TARGET
5+
TARGET = --target ${RUST_TARGET}
6+
endif
27

38
build:
4-
cargo build --features="fusedev"
5-
cargo build --features="virtiofs"
6-
cargo build --features="vhost-user-fs"
7-
cargo build --features="fusedev,async-io"
8-
cargo build --features="virtiofs,async-io"
9-
cargo build --features="vhost-user-fs,async-io"
9+
${CARGO} build ${TARGET} --features="fusedev"
10+
${CARGO} build ${TARGET} --features="virtiofs"
11+
${CARGO} build ${TARGET} --features="vhost-user-fs"
12+
${CARGO} build ${TARGET} --features="fusedev,async-io"
13+
${CARGO} build ${TARGET} --features="virtiofs,async-io"
14+
${CARGO} build ${TARGET} --features="vhost-user-fs,async-io"
15+
16+
check: build
17+
${CARGO} fmt -- --check
18+
${CARGO} clippy ${TARGET} --features="fusedev" --no-default-features -- -Dwarnings
19+
${CARGO} clippy ${TARGET} --features="virtiofs" --no-default-features -- -Dwarnings
20+
${CARGO} clippy ${TARGET} --features="vhost-user-fs" --no-default-features -- -Dwarnings
21+
${CARGO} clippy ${TARGET} --features="fusedev,virtiofs" --no-default-features -- -Dwarnings
22+
23+
test:
24+
cargo test ${TARGET} --features="fusedev" --no-default-features -- --nocapture --skip integration
25+
cargo test ${TARGET} --features="virtiofs" --no-default-features -- --nocapture --skip integration
26+
cargo test ${TARGET} --features="vhost-user-fs" --no-default-features -- --nocapture --skip integration
27+
cargo test ${TARGET} --features="fusedev,virtiofs" --no-default-features -- --nocapture --skip integration
28+
cargo test ${TARGET} --features="fusedev,async-io" --no-default-features -- --nocapture --skip integration
29+
cargo test ${TARGET} --features="virtiofs,async-io" --no-default-features -- --nocapture --skip integration
30+
cargo test ${TARGET} --features="vhost-user-fs,async-io" --no-default-features -- --nocapture --skip integration
31+
cargo test ${TARGET} --features="fusedev,virtiofs,async-io" --no-default-features -- --nocapture --skip integration
32+
cargo test ${TARGET} --features="fusedev,persist" --no-default-features -- --nocapture --skip integration
33+
cargo test ${TARGET} --all-features -- --nocapture --skip integration
34+
35+
smoke:
36+
cargo test ${TARGET} --features="fusedev,persist" -- --nocapture
37+
38+
smoke-all: smoke
39+
cargo test ${TARGET} --features="fusedev,persist" -- --nocapture --ignored
1040

1141
build-macos:
1242
cargo build --features="fusedev"
@@ -19,29 +49,6 @@ check-macos: build-macos
1949
cargo clippy --features="fusedev,fuse-t" -- -Dwarnings
2050
cargo test --features="fusedev,fuse-t" -- --nocapture --skip integration
2151

22-
check: build
23-
cargo fmt -- --check
24-
cargo clippy --features="fusedev" --no-default-features -- -Dwarnings
25-
cargo clippy --features="virtiofs" --no-default-features -- -Dwarnings
26-
cargo clippy --features="vhost-user-fs" --no-default-features -- -Dwarnings
27-
cargo clippy --features="fusedev,virtiofs" --no-default-features -- -Dwarnings
28-
cargo test --features="fusedev" --no-default-features -- --nocapture --skip integration
29-
cargo test --features="virtiofs" --no-default-features -- --nocapture --skip integration
30-
cargo test --features="vhost-user-fs" --no-default-features -- --nocapture --skip integration
31-
cargo test --features="fusedev,virtiofs" --no-default-features -- --nocapture --skip integration
32-
cargo test --features="fusedev,async-io" --no-default-features -- --nocapture --skip integration
33-
cargo test --features="virtiofs,async-io" --no-default-features -- --nocapture --skip integration
34-
cargo test --features="vhost-user-fs,async-io" --no-default-features -- --nocapture --skip integration
35-
cargo test --features="fusedev,virtiofs,async-io" --no-default-features -- --nocapture --skip integration
36-
cargo test --features="fusedev,persist" --no-default-features -- --nocapture --skip integration
37-
cargo test --all-features -- --nocapture --skip integration
38-
39-
smoke: check
40-
cargo test --features="fusedev,persist" -- --nocapture
41-
42-
smoke-all: smoke
43-
cargo test --features="fusedev,persist" -- --nocapture --ignored
44-
4552
smoke-macos: check-macos
4653
cargo test --features="fusedev,fuse-t" -- --nocapture
4754

0 commit comments

Comments
 (0)