Skip to content

Commit 123db4b

Browse files
committed
Add Julia tests to GitHub actions
1 parent 1aecfe7 commit 123db4b

File tree

4 files changed

+170
-18
lines changed

4 files changed

+170
-18
lines changed

.github/julia/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Don't check Julia's Manifest.toml file into Git
2+
Manifest.toml

.github/julia/Project.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[deps]
2+
AmplNLWriter = "7c4d4715-977e-5154-bfe0-e096adeac482"
3+
MINLPTests = "ee0a3090-8ee9-5cdb-b8cb-8eeba3165522"
4+
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
5+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6+
7+
[compat]
8+
AmplNLWriter = "1"
9+
MINLPTests = "0.6.1"
10+
MathOptInterface = "1.33"
11+
Test = "1.10"
12+
julia = "1.10"

.github/julia/runtests.jl

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Copyright (c) 2018-2024: Charlie Vanaret and contributors
2+
#
3+
# Use of this source code is governed by an MIT-style license that can be found
4+
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
5+
6+
# For help with this file, please contact `@odow` on GitHub.
7+
8+
using Test
9+
10+
import AmplNLWriter
11+
import MathOptInterface as MOI
12+
import MINLPTests
13+
import Uno_jll
14+
15+
"""
16+
Optimizer()
17+
18+
Create a new `AmplNLWriter.Optimizer` object that uses Uno as the backing
19+
solver.
20+
"""
21+
function Optimizer()
22+
options = String["logger=SILENT"]
23+
return AmplNLWriter.Optimizer(Uno_jll.amplexe, options)
24+
end
25+
26+
# This testset runs https://github.com/jump-dev/MINLPTests.jl
27+
@testset "MINLPTests" begin
28+
primal_target = Dict(
29+
MINLPTests.FEASIBLE_PROBLEM => MOI.FEASIBLE_POINT,
30+
# If Uno starts writing a .sol file with an infeasible point, change
31+
# this to `=> MOI.INFEASIBLE_POINT`
32+
MINLPTests.INFEASIBLE_PROBLEM => MOI.NO_SOLUTION,
33+
)
34+
# This function tests (potentially) non-convex nonlinear programs. The tests
35+
# are meant to be "easy" in the sense that most NLP solvers can find the
36+
# same global minimum, but a test failure can sometimes be allowed.
37+
MINLPTests.test_nlp_expr(;
38+
exclude = [
39+
# Remove once https://github.com/cvanaret/Uno/issues/39 is fixed
40+
"005_010",
41+
# Okay to exclude forever: AmplNLWriter does not support
42+
# user-defined functions.
43+
"006_010",
44+
# Remove once https://github.com/cvanaret/Uno/issues/38 is fixed
45+
"007_010",
46+
],
47+
primal_target = primal_target,
48+
) do
49+
return
50+
end
51+
# This function tests convex nonlinear programs. Test failures here should
52+
# never be allowed, because even local NLP solvers should find the global
53+
# optimum.
54+
MINLPTests.test_nlp_cvx_expr(; primal_target) do
55+
return AmplNLWriter.Optimizer(Uno_jll.amplexe, ["logger=SILENT"])
56+
end
57+
end
58+
59+
# This testset runs the full gamut of MOI.Test.runtests. There are a number of
60+
# tests in here with weird edge cases, so a variety of exclusions are expected.
61+
@testset "MathOptInterface.test" begin
62+
optimizer = MOI.instantiate(
63+
Optimizer;
64+
with_cache_type = Float64,
65+
with_bridge_type = Float64,
66+
)
67+
MOI.Test.runtests(
68+
optimizer,
69+
MOI.Test.Config(
70+
# These are pretty loose tolerances so that all tests pass. There
71+
# are few tests with weird numerics. If tests fail because of
72+
# tolerances, it might be okay to make these looser, or you could
73+
# tighten the tolerances used by Uno.
74+
atol = 1e-4,
75+
rtol = 1e-4,
76+
optimal_status = MOI.LOCALLY_SOLVED,
77+
infeasible_status = MOI.LOCALLY_INFEASIBLE,
78+
exclude = Any[
79+
# It's okay to exclude BasisStatus, since AmplNLWriter doesn't
80+
# support this information, so too with ObjectiveBound, since
81+
# Uno is a local NLP solver.
82+
MOI.VariableBasisStatus,
83+
MOI.ConstraintBasisStatus,
84+
MOI.ObjectiveBound,
85+
],
86+
);
87+
exclude = [
88+
# ==================================================================
89+
# The following tests are bugs.
90+
#
91+
# We should fix issues in Uno, and then try removing these lines.
92+
#
93+
# These tests return OTHER_LIMIT or OTHER_ERROR instead of
94+
# LOCALLY_SOLVED.
95+
r"^test_conic_linear_VectorOfVariables_2$",
96+
r"^test_linear_integration$",
97+
r"^test_linear_transform$",
98+
r"^test_nonlinear_expression_hs109$",
99+
r"^test_quadratic_constraint_GreaterThan$",
100+
r"^test_quadratic_constraint_LessThan$",
101+
r"^test_solve_VariableIndex_ConstraintDual_MAX_SENSE$",
102+
r"^test_solve_VariableIndex_ConstraintDual_MIN_SENSE$",
103+
# These tests return OTHER_LIMIT instead of DUAL_INFEASIBLE. It
104+
# might be acceptable to leave this as-is, but it would be better to
105+
# fix.
106+
r"^test_solve_TerminationStatus_DUAL_INFEASIBLE$",
107+
# These tests return OTHER_LIMIT instead of LOCALLY_INFEASIBLE. It
108+
# might be acceptable to leave this as-is, but it would be better to
109+
# fix.
110+
r"^test_conic_NormInfinityCone_INFEASIBLE$",
111+
r"^test_conic_NormOneCone_INFEASIBLE$",
112+
r"^test_conic_linear_INFEASIBLE$",
113+
r"^test_conic_linear_INFEASIBLE_2$",
114+
r"^test_linear_INFEASIBLE$",
115+
r"^test_linear_INFEASIBLE_2$",
116+
r"^test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_",
117+
# ==================================================================
118+
# The following tests are okay to exclude forever.
119+
#
120+
# Uno does not support integrality, and AmplNLWriter has no way of
121+
# telling if a particular binary supports integers or not (it
122+
# defaults to assuming yes).
123+
"Indicator",
124+
r"[Ii]nteger",
125+
"Semicontinuous",
126+
"Semiinteger",
127+
"SOS1",
128+
"SOS2",
129+
"ZeroOne",
130+
r"^test_cpsat_",
131+
r"^test_attribute_SolverVersion$",
132+
r"^test_nonlinear_invalid$",
133+
r"^test_basic_VectorNonlinearFunction_",
134+
],
135+
)
136+
end
+20-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: JuliaCI
22
on:
33
push:
44
branches: [main]
@@ -19,17 +19,17 @@ jobs:
1919
name: Julia - ${{ github.event_name }}
2020
runs-on: ubuntu-latest
2121
steps:
22-
- name: Checkout Uno
23-
uses: actions/checkout@v4
24-
- name: Install Julia 1.7
25-
uses: julia-actions/setup-julia@v2
22+
- uses: actions/checkout@v4
23+
# Install Julia 1.7 for BinaryBuilder. Note that this is an old version of
24+
# Julia, but it is required for compatibility with BinaryBuilder.
25+
- uses: julia-actions/setup-julia@v2
2626
with:
2727
version: "1.7"
2828
arch: x64
29-
- name: Set the environment variables BINARYBUILDER_AUTOMATIC_APPLE, UNO_RELEASE, UNO_COMMIT
30-
shell: bash
29+
# Set environment variables required by BinaryBuilder. The specific
30+
# version of UNO_RELEASE is unimportant, since Uno_jll doesn't depend on it
31+
- name: Set the environment variables
3132
run: |
32-
echo "BINARYBUILDER_AUTOMATIC_APPLE=true" >> $GITHUB_ENV
3333
echo "UNO_RELEASE=1.1.1" >> $GITHUB_ENV
3434
if [ "${{ github.event_name }}" = "pull_request" ]; then
3535
echo "UNO_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
@@ -38,19 +38,21 @@ jobs:
3838
echo "UNO_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
3939
echo "UNO_URL=https://github.com/${{ github.repository }}.git" >> $GITHUB_ENV
4040
fi
41-
- name: Generate Uno_jll.jl
41+
- name: Compile Uno_jll
4242
run: |
4343
julia --color=yes -e 'using Pkg; Pkg.add("BinaryBuilder")'
44-
julia --color=yes .github/julia/build_tarballs_yggdrasil.jl x86_64-linux-gnu-libgfortran5 --verbose --deploy="local"
45-
- name: Install Julia LTS
46-
uses: julia-actions/setup-julia@v2
44+
julia --color=yes .github/julia/build_tarballs_yggdrasil.jl x86_64-linux-gnu-cxx11 --verbose --deploy="local"
45+
# Now install a newer version of Julia to actually test Uno_jll. We choose
46+
# v1.10 because it is the current Long-Term Support (LTS).
47+
- uses: julia-actions/setup-julia@v2
4748
with:
4849
version: "1.10"
4950
arch: x64
50-
51-
- name: Test AmplNLWriter.jl
52-
shell: bash
51+
- uses: julia-actions/cache@v1
52+
- name: Test .github/julia/runtests.jl
53+
shell: julia --color=yes --project=.github/julia {0}
5354
run: |
54-
git clone https://github.com/jump-dev/AmplNLWriter.jl
55-
cd AmplNLWriter.jl/test/MINLPTests/
56-
julia --project --color=yes -e 'using Pkg; Pkg.develop(path="/home/runner/.julia/dev/Uno_jll"); Pkg.develop(path="../.."); Pkg.instantiate(); include("run_minlptests.jl")'
55+
using Pkg
56+
Pkg.instantiate()
57+
Pkg.develop(path="/home/runner/.julia/dev/Uno_jll")
58+
include("/home/runner/work/Uno/Uno/.github/julia/runtests.jl")

0 commit comments

Comments
 (0)