Skip to content

rust version, trying arm cross compilation #38

rust version, trying arm cross compilation

rust version, trying arm cross compilation #38

Workflow file for this run

name: Continuous integration
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
./target
key: test-cargo-registry
- name: Clippy
run: cargo clippy
- name: Format
run: cargo fmt --check
test:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
./target
key: test-cargo-registry
- name: Run tests
run: cargo test
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
./target
key: test-cargo-registry
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --lcov --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: false
# https://github.com/nicolas-van/rust-cross-compile-example/
build:
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: armv7-unknown-linux-gnueabihf # raspberry pi 2-3-4
os: ubuntu-latest
- target: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4
os: ubuntu-latest
- target: arm-unknown-linux-gnueabihf # raspberry pi 0-1
os: ubuntu-latest
- target: arm-unknown-linux-musleabihf # raspberry pi 0-1
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
env:
TARGET: ${{ matrix.target }}
OS: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
./target
key: build-cargo-registry-${{matrix.target}}
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf
- name: Add Linux targets configurations
if: runner.os == 'Linux'
run: |
# some additional configuration for cross-compilation on linux
cat >>~/.cargo/config <<EOF
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.armv7-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.arm-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-gcc"
EOF
- name: Install rust target
run: rustup target add $TARGET
- name: Build
run: cargo build --release --verbose --target $TARGET
- name: Compress binary
run: |
mkdir -p ./artifacts
mv ./target/$TARGET/release/cres ./cres
tar -czf ./artifacts/cres-$TARGET.tar.gz cres
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: cres-${{matrix.target}}.tar.gz
path: ./artifacts/cres-${{matrix.target}}.tar.gz