Skip to content

Commit

Permalink
Run cplex tests on CI
Browse files Browse the repository at this point in the history
Add CPLEX tests to the CI. Note that 'lpsolve' and 'cplex-rs' features
are incompatible, as both imply linking statically to blas/lapack
libraries and therefore lead to problems with duplicate symbols
definition at compile time. That's why a compile-time check was added to
ensure these two features are not present at the same time
  • Loading branch information
Matteo Biggio authored and lovasoa committed Apr 2, 2024
1 parent 9ea105f commit 5a14f34
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/cplex/response.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSTALLER_UI=silent
LICENSE_ACCEPTED=TRUE
INSTALLER_LOCALE=en
28 changes: 22 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ on:

env:
CARGO_TERM_COLOR: always
# 'lpsolve' and 'cplex-rs' features are incompatible
ALL_FEATURES_EXCEPT_CPLEX: "scip,singlethread-cbc,coin_cbc,highs,lp-solvers,minilp,russcip,lpsolve"
ALL_FEATURES_EXCEPT_LPSOLVE: "scip,singlethread-cbc,coin_cbc,highs,lp-solvers,minilp,russcip,cplex-rs"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt -- --check
Expand All @@ -26,17 +31,26 @@ jobs:
- name: install deps
run: |
sudo apt-get install coinor-cbc coinor-libcbc-dev libgsl-dev
rustup component add rustfmt
# Install SCIP
conda install -y --prefix $CONDA/envs/test --channel conda-forge scip
echo "LD_LIBRARY_PATH=$CONDA/envs/test/lib" >> "${GITHUB_ENV}"
echo "DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:$CONDA/envs/test/lib" >> "${GITHUB_ENV}"
echo "PATH=$CONDA/envs/test/bin:$PATH" >> "${GITHUB_ENV}"
echo "CONDA_PREFIX=$CONDA/envs/test" >> "${GITHUB_ENV}"
- name: Build
run: cargo build --all-features --tests
- name: Run tests # test on a single thread. See: https://github.com/KardinalAI/coin_cbc/issues/9
run: cargo test --all-features -- --test-threads=1
# install CPLEX
curl -LO https://github.com/rust-or/good_lp/releases/download/cplex/cplex.bin
chmod u+x cplex.bin
./cplex.bin -f ./.github/cplex/response.properties
- name: Build with all features except cplex-rs
run: cargo build --features ${{ env.ALL_FEATURES_EXCEPT_CPLEX }} --tests
- name: Run tests with all features except cplex-rs
# test on a single thread. See: https://github.com/KardinalAI/coin_cbc/issues/9
run: cargo test --features ${{ env.ALL_FEATURES_EXCEPT_CPLEX }} -- --test-threads=1
- name: Build with all features except lpsolve
run: cargo build --features ${{ env.ALL_FEATURES_EXCEPT_LPSOLVE }} --tests
- name: Run tests with all features except lpsolve
# test on a single thread. See: https://github.com/KardinalAI/coin_cbc/issues/9
run: cargo test --features ${{ env.ALL_FEATURES_EXCEPT_LPSOLVE }} -- --test-threads=1
- name: Run tests with minilp
run: cargo test --no-default-features --features minilp
- name: Run tests with lpsolve
Expand All @@ -47,4 +61,6 @@ jobs:
run: cargo test --no-default-features --features lp-solvers
- name: Run tests with SCIP
run: cargo test --no-default-features --features scip
- name: Run tests with CPLEX
run: cargo test --no-default-features --features cplex-rs
- run: cargo bench
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ good_lp = { version = \"*\", features = [\"minilp\"] }
"
);

/// The "lpsolve" and "cplex-rs" cargo feature are incompatible,
/// since the above crates link statically to c libraries defining some
/// common symbols
#[cfg(all(feature = "lpsolve", feature = "cplex-rs",))]
compile_error!(
"'lpsolve' and 'cplex-rs' features are incompatible. \
Please select just one of the two.
"
);

mod expression;
#[macro_use]
pub mod variable;
Expand Down

0 comments on commit 5a14f34

Please sign in to comment.