Skip to content

Commit 9c2974f

Browse files
authored
Add a CI job to test the local installation (#375)
1 parent 4f8b56e commit 9c2974f

File tree

4 files changed

+60
-23
lines changed

4 files changed

+60
-23
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,31 @@ jobs:
5151
with:
5252
file: lcov.info
5353
token: ${{ secrets.CODECOV_TOKEN }}
54+
test-local:
55+
name: Test-local-install
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
- uses: julia-actions/setup-julia@v2
60+
with:
61+
version: '1'
62+
arch: 'x64'
63+
- uses: julia-actions/cache@v1
64+
- shell: bash
65+
env:
66+
SECRET_KNITRO_LICENSE: ${{ secrets.KNITRO_LICENSE }}
67+
run: |
68+
echo "$SECRET_KNITRO_LICENSE" > ~/artelys_lic.txt
69+
cd deps
70+
curl -L https://github.com/jump-dev/KNITRO_jll.jl/releases/download/v15.0.1-binary/x86_64-linux-gnu.tar.bz2 -o x86_64-linux-gnu.tar.bz2
71+
tar -xjf x86_64-linux-gnu.tar.bz2
72+
- uses: julia-actions/julia-buildpkg@v1
73+
env:
74+
KNITRO_JL_USE_KNITRO_JLL: false
75+
KNITRODIR: "/home/runner/work/KNITRO.jl/KNITRO.jl/deps/knitro"
76+
- uses: julia-actions/julia-runtest@v1
77+
- uses: julia-actions/julia-processcoverage@v1
78+
- uses: codecov/codecov-action@v4
79+
with:
80+
file: lcov.info
81+
token: ${{ secrets.CODECOV_TOKEN }}

src/KNITRO.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,28 @@ else
2525
""")
2626
end
2727

28+
function __init__()
29+
libiomp5 = replace(libknitro, "libknitro" => "libiomp5")
30+
if isfile(libiomp5)
31+
Libdl.dlopen(libiomp5)
32+
end
33+
return
34+
end
35+
36+
has_knitro() = endswith(libknitro, Libdl.dlext)
37+
38+
function knitro_version()
39+
length = 15
40+
release = zeros(Cchar, length)
41+
@ccall libknitro.KN_get_release(length::Cint, release::Ptr{Cchar})::Cint
42+
version_string = GC.@preserve(release, unsafe_string(pointer(release)))
43+
return VersionNumber(split(version_string, " ")[2])
44+
end
45+
2846
@static if isdefined(@__MODULE__, :libknitro)
2947
# deps.jl must define a local installation.
3048
let version = has_knitro() ? knitro_version() : v"15.0.0"
31-
if v"13" <= version < v"16"
49+
if !(v"13" <= version < v"16")
3250
error(
3351
"You have installed version $version of Artelys Knitro, " *
3452
"which is not supported by KNITRO.jl. We require a version " *
@@ -49,24 +67,6 @@ else
4967
end
5068
end
5169

52-
function __init__()
53-
libiomp5 = replace(libknitro, "libknitro" => "libiomp5")
54-
if isfile(libiomp5)
55-
Libdl.dlopen(libiomp5)
56-
end
57-
return
58-
end
59-
60-
has_knitro() = endswith(libknitro, Libdl.dlext)
61-
62-
function knitro_version()
63-
length = 15
64-
release = zeros(Cchar, length)
65-
KN_get_release(length, release)
66-
version_string = GC.@preserve(release, unsafe_string(pointer(release)))
67-
return VersionNumber(split(version_string, " ")[2])
68-
end
69-
7070
include("libknitro.jl")
7171
include("C_wrapper.jl")
7272

test/C_wrapper.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,15 @@ end
10031003
end
10041004

10051005
@testset "knitroampl" begin
1006-
@test occursin(
1007-
"AMPL/Knitro",
1008-
sprint(io -> run(pipeline(`$(KNITRO.amplexe()) -v`; stdout=io))),
1009-
)
1006+
if KNITRO.amplexe isa String
1007+
@test occursin(
1008+
"AMPL/Knitro",
1009+
sprint(io -> run(pipeline(`$(KNITRO.amplexe) -v`; stdout=io))),
1010+
)
1011+
else
1012+
@test occursin(
1013+
"AMPL/Knitro",
1014+
sprint(io -> run(pipeline(`$(KNITRO.amplexe()) -v`; stdout=io))),
1015+
)
1016+
end
10101017
end

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using KNITRO
77
using Test
88

9+
@info "Running tests with $(KNITRO.libknitro)"
10+
911
const KN_VERBOSE = false
1012

1113
# Before proceeding, check that KNITRO is installed correctly.

0 commit comments

Comments
 (0)