From 1b0127ddf45617fa9fa4b8c2236b315114a4a67a Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 7 Mar 2024 14:52:07 +1300 Subject: [PATCH] Use conda binaries on CI (#221) --- .github/workflows/ci.yml | 23 +++----- Project.toml | 1 + deps/build.jl | 112 +++++++++++++++------------------------ 3 files changed, 51 insertions(+), 85 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df632052..897bc794 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,10 @@ on: branches: [master] pull_request: types: [opened, synchronize, reopened] +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + contents: read jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} @@ -12,29 +16,16 @@ jobs: fail-fast: false matrix: version: ['1.6', '1'] # Test against LTS and current minor release - os: [windows-latest] + os: [ubuntu-latest, macOS-latest] arch: [x64] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 - env: - cache-name: cache-artifacts - with: - path: ~/.julia/artifacts - key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} - restore-keys: | - ${{ runner.os }}-test-${{ env.cache-name }}- - ${{ runner.os }}-test- - ${{ runner.os }}- + - uses: julia-actions/cache@v1 - uses: julia-actions/julia-buildpkg@v1 - env: - SECRET_XPRS_WIN: ${{ secrets.XPRS_WIN_900 }} - SECRET_XPRL_WIN: ${{ secrets.XPRL_WIN_900 }} - SECRET_XPRA_WIN: ${{ secrets.XPAUTH_XPR }} - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v1 diff --git a/Project.toml b/Project.toml index 12561de4..0feab9d2 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,7 @@ url = "https://github.com/jump-dev/Xpress.jl" version = "0.16.2" [deps] +Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" diff --git a/deps/build.jl b/deps/build.jl index 5a1a4c43..1723ee39 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -3,97 +3,71 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -using Libdl +import Downloads +import Libdl -depsfile = joinpath(dirname(@__FILE__),"deps.jl") +const DEPS_FILE = joinpath(dirname(@__FILE__),"deps.jl") -if isfile(depsfile) - rm(depsfile) -end - - -function my_download(url::AbstractString, filename::AbstractString) - if Sys.iswindows() && VERSION < v"1.1" - # from https://github.com/JuliaLang/julia/blob/788b2c77c10c2160f4794a4d4b6b81a95a90940c/base/download.jl#L26 - # otherwise files are not properly downloaded - check sizes - curl_exe = joinpath(get(ENV, "SYSTEMROOT", "C:\\Windows"), "System32\\curl.exe") - process = run(`$curl_exe -s -S -g -L -f -o $filename $url`)#, wait=false) - return filename - else - return download(url, filename) - end -end - -function write_depsfile(path) - f = open(depsfile,"w") - if Sys.iswindows() - path = replace(path, "\\" => "\\\\") +function write_deps_file(path) + open(DEPS_FILE,"w") do io + return print(io, "const xpressdlpath = \"$(escape_string(path))\"") end - print(f,""" - const xpressdlpath = \"$(path)\" - """) - close(f) + return end function local_installation() - - libname = string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext) - paths_to_try = String[] - - push!(paths_to_try, "") - push!(paths_to_try, @__DIR__) - + lib_name = string(Sys.iswindows() ? "" : "lib", "xprs", ".", Libdl.dlext) + paths_to_try = String["", @__DIR__] if haskey(ENV, "XPRESSDIR") - push!(paths_to_try, joinpath(ENV["XPRESSDIR"], Sys.iswindows() ? "bin" : "lib")) + push!( + paths_to_try, + joinpath(ENV["XPRESSDIR"], Sys.iswindows() ? "bin" : "lib"), + ) end - - global found = false - for l in paths_to_try - path = joinpath(l, libname) - d = Libdl.dlopen_e(path) - if d != C_NULL - global found = true + for dir in paths_to_try + path = joinpath(dir, lib_name) + if Libdl.dlopen_e(path) != C_NULL @info("Found $path") - write_depsfile(l) - break + write_deps_file(dir) + return end end + return error(""" + Unable to locate Xpress installation. - if !found - error(""" - Unable to locate Xpress installation. - Please check your enviroment variable XPRESSDIR. - Note that Xpress must be obtained separately from fico.com. - """) - end + Please check your enviroment variable `XPRESSDIR`. + + Note that Xpress must be obtained separately from fico.com. + """) end function ci_installation() - files = if Sys.iswindows() - [ - (ENV["SECRET_XPRS_WIN"], "xprs.dll") - (ENV["SECRET_XPRL_WIN"], "xprl.dll") - (ENV["SECRET_XPRA_WIN"], "xpauth.xpr") - ] - end - for (url, file) in files - local_filename = joinpath(@__DIR__, file) - my_download(url, local_filename) - end - path = joinpath(@__DIR__, files[1][2]) - d = Libdl.dlopen_e(path) - if d != C_NULL - write_depsfile(@__DIR__) + url = if Sys.islinux() + "https://anaconda.org/fico-xpress/xpress/9.3.0/download/linux-64/xpress-9.3.0-py310ha14b774_0.tar.bz2" else - error("Could not open xprs.dll") + @assert Sys.isapple() + "https://anaconda.org/fico-xpress/xpress/9.3.0/download/osx-64/xpress-9.3.0-py310h9b76c6a_0.tar.bz2" + end + Downloads.download(url, "xpress.tar.bz2") + run(`tar -xjf xpress.tar.bz2`) + root = "lib/python3.10/site-packages/xpress" + run(`cp $root/license/community-xpauth.xpr $root/lib/xpauth.xpr`) + if Sys.islinux() + run(`cp $root/lib/libxprs.so.42 $root/lib/libxprs.so`) end + write_deps_file(joinpath(@__DIR__, root, "lib")) + return +end + +if isfile(DEPS_FILE) + rm(DEPS_FILE) end if haskey(ENV, "XPRESS_JL_SKIP_LIB_CHECK") # Skip! elseif get(ENV, "JULIA_REGISTRYCI_AUTOMERGE", "false") == "true" - write_depsfile("julia_registryci_automerge") -elseif get(ENV, "SECRET_XPRS_WIN", "") != "" + write_deps_file("julia_registryci_automerge") +elseif get(ENV, "CI", "") == "true" ci_installation() else local_installation()