Skip to content

Commit

Permalink
Add GH actions, remove travis, and fix Project.toml (#14)
Browse files Browse the repository at this point in the history
* Add GH actions, remove travis, and fix Project.toml

* Fix typo

* Relax test failure

* Update ci.yml
  • Loading branch information
odow authored Jan 29, 2021
1 parent b42183d commit 4fd0855
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened]
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version: ['1'] # Test against current minor release only since jll requres 1.3+
os: [ubuntu-latest, macOS-latest]
arch: [x64]
include:
# Also test against 32-bit Linux.
- version: '1'
os: ubuntu-latest
arch: x86
steps:
- uses: actions/checkout@v2
- 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/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ HiGHS_jll = "8fd58aa0-07eb-5a78-9b36-339c94fd15ea"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

[compat]
HiGHS_jll = "0.1"
MathOptInterface = "0.9"
julia = "1"
julia = "1.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
16 changes: 7 additions & 9 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ end
MOI.set(o, MOI.ObjectiveSense(), MOI.MAX_SENSE)
HiGHS.CWrapper.Highs_changeColCost(o.model.inner, Cint(x.value), 2.0)
MOI.optimize!(o)
# BUG in HiGHS
# see https://github.com/ERGO-Code/HiGHS/issues/316
@test_broken MOI.get(o, MOI.ObjectiveValue()) 2 * 6
@test MOI.get(o, MOI.ObjectiveValue()) 2 * 6
obj_func = MOI.get(o, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}())
@test obj_func MOI.ScalarAffineFunction([
MOI.ScalarAffineTerm(2.0, x),
Expand All @@ -69,7 +67,7 @@ end
@test F <: MOI.ScalarAffineFunction{Float64}
obj_func = MOI.get(o, MOI.ObjectiveFunction{F}())
@test MOI.supports(o, MOI.ObjectiveFunction{F}())
@test all(MOI.get(o, MOI.ListOfVariableIndices()) .== [x1, x2])
@test all(MOI.get(o, MOI.ListOfVariableIndices()) .== [x1, x2])
@test obj_func MOI.ScalarAffineFunction([
MOI.ScalarAffineTerm(2.0, x1),
MOI.ScalarAffineTerm(-1.0, x2),
Expand All @@ -91,7 +89,7 @@ end
], 0.0,
)
end

@testset "Constrained variable equivalent to add constraint" begin
MOI.empty!(o)
x = MOI.add_variable(o)
Expand All @@ -117,7 +115,7 @@ end
@test MOI.get(o, MOI.ResultCount()) == 1
@test MOI.get(o, MOI.ObjectiveValue()) 0
obj_func = MOI.get(o, MOI.ObjectiveFunction{typeof(obj_func)}())
@test MOI.constant(obj_func) 3
@test MOI.constant(obj_func) 3
MOI.set(o, MOI.ObjectiveSense(), MOI.FEASIBILITY_SENSE)
obj_func = MOI.get(o, MOI.ObjectiveFunction{typeof(obj_func)}())
@test MOI.constant(obj_func) 0
Expand All @@ -132,15 +130,15 @@ end
o = HiGHS.Optimizer()
(x1, _) = MOI.add_constrained_variable(o, MOI.Interval(0.0, 5.0))
(x2, _) = MOI.add_constrained_variable(o, MOI.Interval(0.0, 5.0))
MOI.set(o, MOI.ObjectiveSense(), MOI.MAX_SENSE)
MOI.set(o, MOI.ObjectiveSense(), MOI.MAX_SENSE)
func = MOI.ScalarAffineFunction(
[
MOI.ScalarAffineTerm(1.0, x1),
MOI.ScalarAffineTerm(2.0, x2),
], 0.0,
)
@test MOI.supports_constraint(o, func, MOI.Interval(0, 1))
MOI.set(o, MOI.ObjectiveFunction{typeof(func)}(), func)
MOI.set(o, MOI.ObjectiveFunction{typeof(func)}(), func)
@test MOI.get(o, MOI.NumberOfConstraints{MOI.ScalarAffineFunction{Float64}, MOI.Interval{Float64}}()) == 0
MOI.add_constraint(o,
MOI.ScalarAffineFunction(
Expand Down Expand Up @@ -212,4 +210,4 @@ end
MOI.ScalarAffineFunction{Float64}([MOI.ScalarAffineTerm(1.0, x)], 0.0)
)
@test_throws ErrorException MOI.optimize!(o)
end
end

0 comments on commit 4fd0855

Please sign in to comment.