Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI and tag new version #46

Merged
merged 4 commits into from
May 30, 2024
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
37 changes: 32 additions & 5 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: "1"
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
13 changes: 13 additions & 0 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Spell Check

on: [pull_request]

jobs:
typos-check:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/[email protected]
16 changes: 16 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ on:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: "3"
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand Down
74 changes: 56 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,81 @@
name: CI
on:
pull_request:
branches:
- main
- dev
paths-ignore:
- "docs/**"
push:
branches:
- main
tags: '*'
pull_request:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
paths-ignore:
- "docs/**"
jobs:
formatter:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v4
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.50"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.10'
- 'nightly'
- "1.8"
- "1" # automatically expands to the latest stable 1.x release of Julia
- nightly
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
exclude:
include:
# test macOS and Windows with latest Julia only
- os: macOS-latest
arch: x86
arch: x64
version: 1
- os: windows-latest
arch: x64
version: 1
- os: windows-latest
arch: x86
version: 1
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -51,14 +88,14 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v4
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: "1"
Expand All @@ -69,8 +106,9 @@ jobs:
Pkg.instantiate()'
- run: |
julia --project=docs -e '
using Documenter: doctest
using Documenter: DocMeta, doctest
using ConstraintDomains
DocMeta.setdocmeta!(ConstraintDomains, :DocTestSetup, :(using ConstraintDomains); recursive=true)
doctest(ConstraintDomains)'
- run: julia --project=docs docs/make.jl
env:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/register.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Register Package
on:
workflow_dispatch:
inputs:
version:
description: Version to register or component to bump
required: true
jobs:
register:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: julia-actions/RegisterAction@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.jl.cov
*.jl.mem
/docs/build/
/docs/Manifest.toml

_git2_*
.gitignore
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ TestItems = "0.1"
julia = "1.8"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Aqua", "Test"]
23 changes: 12 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ using ConstraintDomains
using Documenter

makedocs(;
modules=[ConstraintDomains],
authors="Jean-François Baffier",
repo="https://github.com/JuliaConstraints/ConstraintDomains.jl/blob/{commit}{path}#L{line}",
sitename="ConstraintDomains.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", nothing) == "true",
canonical="https://JuliaConstraints.github.io/ConstraintDomains.jl",
modules = [ConstraintDomains],
authors = "Jean-François Baffier",
repo = "https://github.com/JuliaConstraints/ConstraintDomains.jl/blob/{commit}{path}#L{line}",
sitename = "ConstraintDomains.jl",
format = Documenter.HTML(;
prettyurls = get(ENV, "CI", nothing) == "true",
canonical = "https://JuliaConstraints.github.io/ConstraintDomains.jl",
assets = ["assets/favicon.ico"; "assets/github_buttons.js"; "assets/custom.css"],
),
pages=[
"Home" => "index.md",
],
pages = ["Home" => "index.md"],
)

deploydocs(; repo="github.com/JuliaConstraints/ConstraintDomains.jl.git", devbranch = "main")
deploydocs(;
repo = "github.com/JuliaConstraints/ConstraintDomains.jl.git",
devbranch = "main",
)
2 changes: 1 addition & 1 deletion src/ConstraintDomains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using TestItems
export AbstractDomain
export ContinuousDomain
export DiscreteDomain
export DiscreteSet
# export DiscreteSet # not defined
export ExploreSettings
export RangeDomain

Expand Down
11 changes: 5 additions & 6 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ An abstract super type for any domain type. A domain type `D <: AbstractDomain`
- `Base.∈(val, ::D)`
- `Base.rand(::D)`
- `Base.length(::D)` that is the number of elements in a discrete domain, and the distance between bounds or similar for a continuous domain
Addtionally, if the domain is used in a dynamic context, it can extend
Additionally, if the domain is used in a dynamic context, it can extend
- `add!(::D, args)`
- `delete!(::D, args)`
where `args` depends on `D`'s structure
Expand Down Expand Up @@ -78,7 +78,9 @@ Base.rand(d::AbstractDomain) = rand(get_domain(d))

Base.rand(d::Union{Vector{D},Set{D}}) where {D<:AbstractDomain} = map(rand, d)

function Base.rand(d::V) where {D<:AbstractDomain,U<:Union{Vector{D},Set{D}},V<:AbstractVector{U}}
function Base.rand(
d::V,
) where {D<:AbstractDomain,U<:Union{Vector{D},Set{D}},V<:AbstractVector{U}}
return map(rand, d)
end

Expand All @@ -89,10 +91,7 @@ end
Extends the `string` method to (a vector of) domains.
"""
function Base.string(D::Vector{<:AbstractDomain})
return replace(
"[$(prod(d -> string(d) * ',', D)[1:end-1])]",
" " => "",
)
return replace("[$(prod(d -> string(d) * ',', D)[1:end-1])]", " " => "")
end
Base.string(d::AbstractDomain) = replace(string(d.domain), " " => "")

Expand Down
28 changes: 12 additions & 16 deletions src/continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ domain(intervals::Vector{I}) where {I<:Interval} = Intervals(intervals)
Base.length(itv::Intervals)
Return the sum of the length of each interval in `itv`.
"""
Base.length(itv::Intervals) = sum(size, get_domain(itv); init=0)
Base.length(itv::Intervals) = sum(size, get_domain(itv); init = 0)

"""
Base.rand(itv::Intervals)
Expand Down Expand Up @@ -67,8 +67,7 @@ function domain_size(itv::Intervals)
end

# TODO - implement
function merge_domains(d1::D, d2::D) where {D<:ContinuousDomain}
end
function merge_domains(d1::D, d2::D) where {D<:ContinuousDomain} end

"""
intersect_domains(d₁, d₂)
Expand Down Expand Up @@ -104,7 +103,10 @@ function intersect_domains!(is::IS, i::I, new_itvls) where {IS<:Intervals,I<:Int
end
end

function intersect_domains(d₁::D1, d₂::D2) where {T<:Real,D1<:ContinuousDomain{T}, D2<:ContinuousDomain{T}}
function intersect_domains(
d₁::D1,
d₂::D2,
) where {T<:Real,D1<:ContinuousDomain{T},D2<:ContinuousDomain{T}}
new_itvls = Vector{Interval{T}}()
for i in get_domain(d₂)
intersect_domains!(d₁, i, new_itvls)
Expand All @@ -118,26 +120,20 @@ end

Defines the size of an interval as its `span`.
"""
size(i::I) where {I <: Interval} = PatternFolds.span(i)
size(i::I) where {I<:Interval} = PatternFolds.span(i)

function Base.string(d::Intervals)
return replace(
"[$(prod(i -> "$(string(i)[2:end-1]),", d.domain)[1:end-1])]",
" " => "",
)
return replace("[$(prod(i -> "$(string(i)[2:end-1]),", d.domain)[1:end-1])]", " " => "")
end

@testitem "ContinuousDomain" tags = [:domains, :continuous] default_imports=false begin
@testitem "ContinuousDomain" tags = [:domains, :continuous] default_imports = false begin
using ConstraintDomains, Intervals, Test
# import Base:size

d1 = domain(1.0..3.15)
d2 = domain(Interval{Open, Open}(-42.42, 5.0))
d1 = domain(1.0 .. 3.15)
d2 = domain(Interval{Open,Open}(-42.42, 5.0))

domains = [
d1,
d2,
]
domains = [d1, d2]

for d in domains
for x in [1, 2.3, π]
Expand Down
Loading
Loading