From ff66f633af310c3f3605ec9dc17db28f130836c1 Mon Sep 17 00:00:00 2001 From: Florian Fontan Date: Fri, 5 Apr 2024 22:57:02 +0200 Subject: [PATCH] Add build.yml --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++++++++++ WORKSPACE | 46 +++++++++++++++++++++++++++++++ packingsolver/BUILD | 6 +++- packingsolver/variables.bzl | 3 ++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..901e7f44b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: Build + +on: [push] + +jobs: + + build: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.8"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Build Linux + run: bazel build -- //... + if: matrix.os != 'windows-latest' + - name: Build Windows + run: bazel build --cxxopt=/MT -- //... + if: matrix.os == 'windows-latest' + - name: Copy CLP libraries (Darwin) + run: | + mkdir -p "/Users/runner/work/Osi/Osi/dist/lib" + cp -rf "${GITHUB_WORKSPACE}/bazel-packingsolver/external/osi_darwin/lib/" "/Users/runner/work/Osi/Osi/dist/lib" + mkdir -p "/Users/runner/work/CoinUtils/CoinUtils/dist/lib" + cp -rf "${GITHUB_WORKSPACE}/bazel-packingsolver/external/coinutils_darwin/lib/" "/Users/runner/work/CoinUtils/CoinUtils/dist/lib" + mkdir -p "/Users/runner/work/Clp/Clp/dist/lib" + cp -rf "${GITHUB_WORKSPACE}/bazel-packingsolver/external/clp_darwin/lib/" "/Users/runner/work/Clp/Clp/dist/lib" + if: matrix.os == 'macos-latest' + - name: Run tests + run: python3 -u scripts/run_tests.py test_results + - name: Checkout main branch + run: | + git remote set-branches origin '*' + git fetch --depth 1 + git checkout main + - name: Build Linux + run: bazel build -- //... + if: matrix.os != 'windows-latest' + - name: Build Windows + run: bazel build --cxxopt=/MT -- //... + if: matrix.os == 'windows-latest' + - name: Run tests + run: python3 -u scripts/run_tests.py test_results_ref + - name: Process tests + run: python3 -u ./bazel-packingsolver/external/optimizationtools/scripts/process_tests.py --ref test_results_ref --new test_results diff --git a/WORKSPACE b/WORKSPACE index a93262ffd..dacc15f4a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -105,6 +105,21 @@ cc_library( """, ) +http_archive( + name = "osi_darwin", + urls = ["https://github.com/coin-or/Osi/releases/download/releases%2F0.108.8/Osi-releases.0.108.8-x86_64-macos106-clang140.tar.gz"], + sha256 = "4ddc1ee5cd5088aeb7795bfebc66beec8d7a0a3baec3dd3e8bbbdff17f93cd3f", + build_file_content = """ +cc_library( + name = "osi", + hdrs = glob(["include/coin/Osi*.h*"], exclude_directories = 0), + strip_include_prefix = "include/coin/", + srcs = ["lib/libOsi.dylib", "lib/libOsiCommonTests.dylib"], + visibility = ["//visibility:public"], +) +""", +) + http_archive( name = "coinutils_linux", urls = ["https://github.com/coin-or/CoinUtils/releases/download/releases%2F2.11.9/CoinUtils-releases.2.11.9-x86_64-ubuntu20-gcc940-static.tar.gz"], @@ -136,6 +151,21 @@ cc_library( """, ) +http_archive( + name = "coinutils_darwin", + urls = ["https://github.com/coin-or/CoinUtils/releases/download/releases%2F2.11.9/CoinUtils-releases.2.11.9-x86_64-macos106-clang140.tar.gz"], + sha256 = "3d0bdaf7bb748bfbec059fc8ff6ff17d2354c334710db3cd532af6a9c942f762", + build_file_content = """ +cc_library( + name = "coinutils", + hdrs = glob(["include/coin/Coin*.h*"], exclude_directories = 0), + strip_include_prefix = "include/coin/", + srcs = ["lib/libCoinUtils.dylib"], + visibility = ["//visibility:public"], +) +""", +) + http_archive( name = "clp_linux", urls = ["https://github.com/coin-or/Clp/releases/download/releases%2F1.17.8/Clp-releases.1.17.8-x86_64-ubuntu20-gcc940-static.tar.gz"], @@ -168,6 +198,22 @@ cc_library( """, ) +http_archive( + name = "clp_darwin", + urls = ["https://github.com/coin-or/Clp/releases/download/releases%2F1.17.8/Clp-releases.1.17.8-x86_64-macos106-clang140.tar.gz"], + sha256 = "fe9ce251cd3e0324d64f0e3956d722c73b7568685c25eb7559c327818b39b86b", + build_file_content = """ +cc_library( + name = "clp", + hdrs = glob(["include/coin/*Clp*.h*"], exclude_directories = 0), + strip_include_prefix = "include/coin", + srcs = ["lib/libClp.dylib", "lib/libOsiClp.dylib"], + deps = ["@osi_darwin//:osi", "@coinutils_darwin//:coinutils"], + visibility = ["//visibility:public"], +) +""", +) + new_local_repository( name = "cplex", path = "/opt/ibm/ILOG/CPLEX_Studio129/", diff --git a/packingsolver/BUILD b/packingsolver/BUILD index f20fdec74..ccb5ca392 100644 --- a/packingsolver/BUILD +++ b/packingsolver/BUILD @@ -16,6 +16,11 @@ selects.config_setting_group( match_all = [":clp_build", "@bazel_tools//src/conditions:windows"], ) +selects.config_setting_group( + name = "clp_darwin", + match_all = [":clp_build", "@bazel_tools//src/conditions:darwin"], +) + config_setting( name = "cplex_build", values = {"define": "cplex=true"}, @@ -45,4 +50,3 @@ load("//packingsolver:variables.bzl", "STDCPP", "CPLEX_COPTS", "CPLEX_DEP", "GUROBI_COPTS", "GUROBI_DEP", "XPRESS_COPTS", "XPRESS_DEP") - diff --git a/packingsolver/variables.bzl b/packingsolver/variables.bzl index 7912dbc19..fd01dfaa7 100644 --- a/packingsolver/variables.bzl +++ b/packingsolver/variables.bzl @@ -14,6 +14,9 @@ CLP_DEP = select({ "//conditions:default": [] }) + select({ "//packingsolver:clp_linux": ["@clp_linux//:clp"], + "//conditions:default": [] + }) + select({ + "//packingsolver:clp_darwin": ["@clp_darwin//:clp"], "//conditions:default": []}) CPLEX_COPTS = select({