From 4c1f29ad56d3599ed8ee4eb43f5ea3c6f903dd39 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Tue, 19 Nov 2024 06:34:12 +0100 Subject: [PATCH] Use maturin to test cross compilation --- .github/workflows/node-hub-ci-cd.yml | 10 +++++--- .github/workflows/node_hub_test.sh | 36 ++++++++++++++++++---------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/node-hub-ci-cd.yml b/.github/workflows/node-hub-ci-cd.yml index 0f8c91a83..910bea0a5 100644 --- a/.github/workflows/node-hub-ci-cd.yml +++ b/.github/workflows/node-hub-ci-cd.yml @@ -38,6 +38,7 @@ jobs: fail-fast: false steps: - name: Checkout repository + if: runner.os == 'Linux' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')) uses: actions/checkout@v2 - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -57,17 +58,20 @@ jobs: swap-storage: true - name: Set up Python + if: runner.os == 'Linux' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')) uses: actions/setup-python@v2 with: python-version: "3.10" - name: Set up Poetry + if: runner.os == 'Linux' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')) run: | curl -sSL https://install.python-poetry.org | python3 - echo "$HOME/.local/bin" >> $GITHUB_PATH pip install black pylint pytest - name: Set up Rust + if: runner.os == 'Linux' || github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')) uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -148,15 +152,15 @@ jobs: ## The CI/CD is sequential to limit the number of workers used. # x86_64-unknown-linux-gnu - maturin publish --skip-existing --zig + maturin publish --skip-existing --zig # aarch64-unknown-linux-gnu rustup target add aarch64-unknown-linux-gnu - maturin publish --target aarch64-unknown-linux-gnu --zig + maturin publish --target aarch64-unknown-linux-gnu --zig --skip-existing # armv7-unknown-linux-musleabihf rustup target add armv7-unknown-linux-musleabihf - maturin publish --target armv7-unknown-linux-musleabihf --zig + maturin publish --target armv7-unknown-linux-musleabihf --zig --skip-existing else pip3 install maturin diff --git a/.github/workflows/node_hub_test.sh b/.github/workflows/node_hub_test.sh index 9bda798a2..a0172a448 100755 --- a/.github/workflows/node_hub_test.sh +++ b/.github/workflows/node_hub_test.sh @@ -14,27 +14,39 @@ base_dir=$(basename "$dir") if [[ " ${ignored_folders[@]} " =~ " ${base_dir} " ]]; then echo "Skipping $base_dir as we cannot test it on the CI..." else - if [ -f "$dir/Cargo.toml" ]; then + if [[ -f "Cargo.toml" && -f "pyproject.toml" ]]; then echo "Running build and tests for Rust project in $dir..." + cargo check cargo clippy cargo build cargo test - + + pip3 install "maturin[zig]" + maturin build --skip-existing --zig + # aarch64-unknown-linux-gnu rustup target add aarch64-unknown-linux-gnu - cargo check --target aarch64-unknown-linux-gnu + maturin build --target aarch64-unknown-linux-gnu --zig # armv7-unknown-linux-musleabihf rustup target add armv7-unknown-linux-musleabihf - cargo check --target armv7-unknown-linux-musleabihf + maturin build --target armv7-unknown-linux-musleabihf --zig else - if [ -f "$dir/pyproject.toml" ]; then - echo "Running linting and tests for Python project in $dir..." - pip install . - poetry run black --check . - poetry run pylint --disable=C,R --ignored-modules=cv2 **/*.py - poetry run pytest - fi - fi + if [ -f "$dir/Cargo.toml" ]; then + echo "Running build and tests for Rust project in $dir..." + cargo check + cargo clippy + cargo build + cargo test + else + if [ -f "$dir/pyproject.toml" ]; then + echo "Running linting and tests for Python project in $dir..." + pip install . + poetry run black --check . + poetry run pylint --disable=C,R --ignored-modules=cv2 **/*.py + poetry run pytest + fi + fi + fi fi \ No newline at end of file