Skip to content

Commit

Permalink
Add JuliaFormatter (#115)
Browse files Browse the repository at this point in the history
* Add JuliaFormatter

* Fix style

* Update format_check.yml
  • Loading branch information
odow authored May 6, 2021
1 parent d097421 commit 932bb56
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 103 deletions.
8 changes: 8 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Configuration file for JuliaFormatter.jl
# For more information, see: https://domluna.github.io/JuliaFormatter.jl/stable/config/

always_for_in = true
always_use_return = true
margin = 80
remove_extra_newlines = true
short_to_long_function_def = true
32 changes: 32 additions & 0 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: format-check
on:
push:
branches:
- master
- release-*
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: '1'
- uses: actions/checkout@v1
- name: Format check
shell: julia --color=yes {0}
run: |
using Pkg
Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.2"))
using JuliaFormatter
format("src/MOI_wrapper", verbose=true)
format_file("src/Clp.jl")
format("test", verbose=true)
out = String(read(Cmd(`git diff`)))
if isempty(out)
exit(0)
end
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
13 changes: 6 additions & 7 deletions src/Clp.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Clp

if haskey(ENV,"JULIA_CLP_LIBRARY_PATH") || VERSION < v"1.3"
if haskey(ENV, "JULIA_CLP_LIBRARY_PATH") || VERSION < v"1.3"
deps_file = joinpath(dirname(@__DIR__), "deps", "deps.jl")
if isfile(deps_file)
include(deps_file)
Expand All @@ -17,16 +17,15 @@ include("gen/ctypes.jl")
include("gen/libclp_common.jl")
include("gen/libclp_api.jl")

const _CLP_VERSION = VersionNumber(
"$(Clp_VersionMajor()).$(Clp_VersionMinor()).$(Clp_VersionRelease())"
)
const _CLP_VERSION =
VersionNumber("$(Clp_VersionMajor()).$(Clp_VersionMinor()).$(Clp_VersionRelease())")

if !(v"1.17.2" <= _CLP_VERSION <= v"1.17.6")
error(
"You have installed version $_CLP_VERSION of Clp, which is not " *
"supported by Clp.jl. If the version change was breaking, changes " *
"will need to be made to the Julia code. Please open an issue at " *
"https://github.com/jump-dev/Clp.jl."
"https://github.com/jump-dev/Clp.jl.",
)
end

Expand All @@ -38,15 +37,15 @@ function ClpSolver(args...; kwargs...)
"`ClpSolver` is no longer supported. If you are using JuMP, upgrade " *
"to the latest version and use `Clp.Optimizer` instead. If you are " *
"using MathProgBase (e.g., via `lingprog`), you will need to upgrade " *
"to MathOptInterface (https://github.com/jump-dev/MathOptInterface.jl)."
"to MathOptInterface (https://github.com/jump-dev/MathOptInterface.jl).",
)
end
export ClpSolver

# Clp exports all `Clp_xxx` symbols. If you don't want all of these symbols in
# your environment, then use `import Clp` instead of `using Clp`.

for sym in names(@__MODULE__, all=true)
for sym in names(@__MODULE__, all = true)
sym_string = string(sym)
if startswith(sym_string, "Clp_")
@eval export $sym
Expand Down
Loading

2 comments on commit 932bb56

@odow
Copy link
Member Author

@odow odow commented on 932bb56 May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/36235

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.4 -m "<description of version>" 932bb56e426a5a8fe5b0149c51f1d5675c5fe9e9
git push origin v0.8.4

Please sign in to comment.