Skip to content

Commit

Permalink
Add more targets to CI tests (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 authored May 30, 2024
1 parent 42883a5 commit 16af91d
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 16 deletions.
71 changes: 61 additions & 10 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,82 @@ jobs:

test:
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cargo: cargo
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cargo: cross
# FIXME: SFML_* env variables don't seem to do anything, build can't
# find the libraries.
# - target: armv7-unknown-linux-musleabihf
# os: ubuntu-latest
# cargo: cross
# FIXME: figure out install location from vcpkg
# - target: x86_64-pc-windows-msvc
# os: windows-latest
# cargo: cargo
# - target: x86_64-pc-windows-gnu
# os: windows-latest
# cargo: cargo
# FIXME: libsfml linking errors
# - target: x86_64-apple-darwin
# os: macos-latest
# cargo: cargo
- target: aarch64-apple-darwin
os: macos-14
cargo: cargo
name: "test ${{ matrix.target }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@cross
if: matrix.cargo == 'cross'
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- if: matrix.cargo == 'cross'
# FIXME: just use this action once there is a new release with newer
# docker images
# uses: taiki-e/install-action@cross
run: >
cargo install \
--git https://github.com/cross-rs/cross.git \
--rev 19be83481fd3e50ea103d800d72e0f8eddb1c90c \
cross
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
- run: sudo ./ci/setup-debian.sh
if: matrix.os == 'ubuntu-latest'
- run: sudo apt-get install musl-tools
if: matrix.cargo == 'cargo' && contains(matrix.target, 'musl')
- run: |

- if: contains(matrix.os, 'ubuntu') && matrix.cargo == 'cargo'
run: sudo ./ci/setup-debian.sh
- if: contains(matrix.target, 'musl') && matrix.cargo == 'cargo'
run: sudo apt-get install musl-tools
- if: contains(matrix.os, 'macos') && matrix.cargo == 'cargo'
run: ./ci/setup-macos.sh
- if: contains(matrix.os, 'windows') && matrix.cargo == 'cargo'
run: vcpkg install sfml

- name: Test Rust and C packages
run: >
${{ matrix.cargo }} test \
--features _skip-hil-testing \
--target ${{ matrix.target }}
--target ${{ matrix.target }} \
--package mic2 -vv
${{ matrix.cargo }} test \
--target ${{ matrix.target }} \
--package libmic2 -vv
shell: bash
if: '!matrix.notest'
- name: Test python package (native only)
if: matrix.cargo == 'cargo'
run: >
${{ matrix.cargo }} test \
--target ${{ matrix.target }} \
--package mic2_python
fmt:
name: formatting
Expand Down
17 changes: 16 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ members = [
]
exclude = [
"examples/rust/find",
]
]
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
pre-build = "ci/setup-debian.sh"
32 changes: 29 additions & 3 deletions ci/setup-debian.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
#!/bin/sh
# Configure dependencies to build on Debian

set -eaux

# Set the target platform, if provided
if [ -n "${CROSS_DEB_ARCH:-}" ]; then
if [ "$CROSS_DEB_ARCH" = "musl-linux-armhf" ]; then
# Cross gives the wrong debian architecutre
arch="armhf"

# SFML can't find these for some reason. Set them globally
# (this is a docker container!)
echo "export SFML_INCLUDE_DIR=/usr/include" >> "/etc/profile.d/cfg-sfml.sh"
echo "export SFML_LIBS_DIR=/usr/lib/arm-linux-gnueabihf" >> "/etc/profile.d/cfg-sfml.sh"
chmod +x "/etc/profile.d/cfg-sfml.sh"
cat /etc/profile.d/cfg-sfml.sh
printenv
. /etc/profile.d/cfg-sfml.sh
printenv
else
arch="$CROSS_DEB_ARCH"
fi

dpkg --add-architecture "$arch"
sfx=":${arch}"
fi

apt-get update
apt-get install -y \
libsfml-dev \
libudev-dev \
libftdi1-dev
"libsfml-dev${sfx:-}" \
"libudev-dev${sfx:-}" \
"libftdi1-dev${sfx:-}"
11 changes: 11 additions & 0 deletions ci/setup-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -eaux

brew install libftdi sfml

if [ -n "$GITHUB_ENV" ]; then
# Configure environment for future steps
echo "SFML_INCLUDE_DIR=$(brew --prefix)/opt/sfml/include" >> "$GITHUB_ENV"
echo "SFML_LIBS_DIR=$(brew --prefix)/lib" >> "$GITHUB_ENV"
fi
8 changes: 7 additions & 1 deletion crates/mic2_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ _skip-hil-testing = []
[dependencies]
#libftd2xx = { version = "0.32.2", features=[], optional = true }
cfg-if = "1.0.0"
sfml = { version = "0.20.0", optional = true }
nmea-parser = { version = "0.10.0", optional = true }
serialport = { version = "4.3.0", optional = true }
rusb = "0.9.4"
Expand All @@ -36,3 +35,10 @@ enumflags2 = "0.7.9"
serde = { version = "1.0.203", features = ["derive"] }
nom = "7.1.3"

[target.'cfg(target_os = "linux")'.dependencies]
# Use an older version for compatibility with stable Debian (SFML 2.5)
sfml = { version = "0.20.0", optional = true }

[target.'cfg(not(target_os = "linux"))'.dependencies]
# Use a newer version for non-linux bugfixes. Requires SFML 2.6
sfml = { version = "0.21.0", optional = true }
2 changes: 2 additions & 0 deletions crates/mic2_rs/src/mic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ mod tests {
}

#[test]
// FIXME: this takes 8 minutes on aarch64-macos CI
#[cfg(target_os = "linux")]
fn test_audio() {
Audio::find_neovi_mic2_audio().unwrap();
}
Expand Down

0 comments on commit 16af91d

Please sign in to comment.