Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/package_compiler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Package Compiler
on:
push:
branches:
- master
- release-*
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 }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- version: '1' # The latest point-release (Linux)
os: ubuntu-latest
arch: x64
steps:
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v3
- uses: julia-actions/julia-buildpkg@v1
- shell: julia --color=yes --project=test/PackageCompiler/MyApp {0}
run: |
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
- shell: julia --color=yes --project=test/PackageCompiler {0}
run: |
using Pkg
Pkg.instantiate()
- run: julia --color=yes --project=test/PackageCompiler test/PackageCompiler/build_app.jl
1 change: 1 addition & 0 deletions test/PackageCompiler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
12 changes: 12 additions & 0 deletions test/PackageCompiler/MyApp/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name = "MyApp"
uuid = "4076af6c-e467-56ae-b986-b466b2749573"

[deps]
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"

[compat]
HiGHS = "1"
Ipopt = "1"
JuMP = "1"
53 changes: 53 additions & 0 deletions test/PackageCompiler/MyApp/src/MyApp.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2017, Iain Dunning, Joey Huchette, Miles Lubin, and contributors
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#############################################################################
# JuMP
# An algebraic modeling language for Julia
# See https://github.com/jump-dev/JuMP.jl
#############################################################################

module MyApp

using JuMP
import HiGHS
import Ipopt

function run_highs_example()
capacity = 10.0
profit = [5.0, 3.0, 2.0, 7.0, 4.0]
weight = [2.0, 8.0, 4.0, 2.0, 5.0]
model = Model(HiGHS.Optimizer)
@variable(model, x[1:length(weight)], Bin)
@constraint(model, weight' * x <= capacity)
@objective(model, Max, profit' * x)
optimize!(model)
assert_is_solved_and_feasible(model)
print(solution_summary(model))
return
end

function run_ipopt_example()
model = Model(Ipopt.Optimizer)
@variable(model, x)
@variable(model, y)
@objective(model, Min, (1 - x)^2 + 100 * (y - x^2)^2)
optimize!(model)
assert_is_solved_and_feasible(model)
print(solution_summary(model))
return
end

function julia_main()::Cint
solver = only(match(r"--solver=(.+)", only(ARGS)))
if solver == "ipopt"
run_ipopt_example()
else
@assert solver == "highs"
run_highs_example()
end
return 0
end

end
5 changes: 5 additions & 0 deletions test/PackageCompiler/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"

[compat]
PackageCompiler = "2"
33 changes: 33 additions & 0 deletions test/PackageCompiler/build_app.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2017, Iain Dunning, Joey Huchette, Miles Lubin, and contributors
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#############################################################################
# JuMP
# An algebraic modeling language for Julia
# See https://github.com/jump-dev/JuMP.jl
#############################################################################

using Test

import PackageCompiler

PackageCompiler.create_app(
joinpath(@__DIR__, "MyApp"),
joinpath(@__DIR__, "build");
force = true,
)

@testset "test --solver=ipopt" begin
app = joinpath(@__DIR__, "build", "bin", "MyApp")
output = sprint(io -> run(pipeline(`$app --solver=highs`; stdout = io)))
@test occursin("HiGHS", output)
@test occursin("OPTIMAL", output)
end

@testset "test --solver=ipopt" begin
app = joinpath(@__DIR__, "build", "bin", "MyApp")
output = sprint(io -> run(pipeline(`$app --solver=ipopt`; stdout = io)))
@test occursin("Ipopt", output)
@test occursin("LOCALLY_SOLVED", output)
end
Loading