Skip to content

Commit

Permalink
Use maturin to test cross compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
haixuanTao committed Nov 19, 2024
1 parent b5ad879 commit 4c1f29a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/node-hub-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 24 additions & 12 deletions .github/workflows/node_hub_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4c1f29a

Please sign in to comment.