Skip to content

Commit

Permalink
Use conda binaries on CI (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Mar 7, 2024
1 parent b5bc1e7 commit 1b0127d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 85 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
112 changes: 43 additions & 69 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1b0127d

Please sign in to comment.