From 0e417e4bdc1dd8e9169914df168c04836433ac56 Mon Sep 17 00:00:00 2001 From: Azzaare Date: Tue, 14 May 2024 03:36:58 +0000 Subject: [PATCH 1/4] Improve CI, format, tests --- .JuliaFormatter.toml | 1 + .github/workflows/CI.yml | 82 ++++++++++++++++++++++++------ .github/workflows/CompatHelper.yml | 37 ++++++++++++-- .github/workflows/SpellCheck.yml | 13 +++++ .github/workflows/TagBot.yml | 16 ++++++ Project.toml | 9 ++-- docs/make.jl | 28 +++++----- ext/BenchmarkToolsExt/benchmark.jl | 13 +++-- ext/ChairmarksExt/ChairmarksExt.jl | 1 - ext/ChairmarksExt/b.jl | 2 +- perf/GLM/allocs.jl | 12 ++--- perf/GLM/bench.jl | 14 ++--- perf/PatternFolds/allocs.jl | 8 +-- perf/PatternFolds/bench.jl | 4 +- perf/PatternFolds/chair.jl | 6 +-- src/PerfChecker.jl | 8 +-- src/alloc.jl | 11 ++-- src/check.jl | 65 +++++++++++++---------- src/versions.jl | 54 +++++++++++--------- test/Aqua.jl | 28 ++++++++++ test/Project.toml | 16 ------ test/pattern_folds.jl | 11 ++-- test/runtests.jl | 18 ++++--- 23 files changed, 300 insertions(+), 157 deletions(-) create mode 100644 .JuliaFormatter.toml create mode 100644 .github/workflows/SpellCheck.yml create mode 100644 test/Aqua.jl delete mode 100644 test/Project.toml diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..453925c --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "sciml" \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0cee6db..54cdccc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,7 +1,48 @@ name: CI on: - - push + pull_request: + branches: + - main + - dev + paths-ignore: + - "docs/**" + push: + branches: + - main + 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 }} @@ -9,27 +50,32 @@ jobs: fail-fast: false matrix: version: - - "1.10" - - 'nightly' + - "1.9" # Minimal version of Julia for PerfChecker.jl + - "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@v2 + - 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: @@ -42,25 +88,29 @@ 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@v2 + - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: version: '1' - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-docdeploy@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} + - run: | + julia --project=docs -e ' + using Pkg + Pkg.develop(PackageSpec(path=pwd())) + Pkg.instantiate()' - run: | julia --project=docs -e ' using Documenter: DocMeta, doctest using PerfChecker DocMeta.setdocmeta!(PerfChecker, :DocTestSetup, :(using PerfChecker); recursive=true) doctest(PerfChecker)' + - run: julia --project=docs docs/make.jl + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index cba9134..5577817 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -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()' diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 0000000..ed4fe17 --- /dev/null +++ b/.github/workflows/SpellCheck.yml @@ -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/typos@v1.18.0 diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index f49313b..0cd3114 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -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' diff --git a/Project.toml b/Project.toml index d9a02f2..aee9457 100644 --- a/Project.toml +++ b/Project.toml @@ -4,8 +4,6 @@ authors = ["Azzaare "] version = "0.2.0" [deps] -BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de" CoverageTools = "c36e975a-824b-4404-a568-ef97ca766997" CpuId = "adafc99b-e345-5852-983c-f28acb93d879" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" @@ -28,10 +26,13 @@ Chairmarks = "1.2" CoverageTools = "1" CpuId = "0.3.1" TypedTables = "1" -julia = "1" +julia = "1.9" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +PatternFolds = "c18a7f1d-76ad-4ce4-950d-5419b888513b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Aqua", "BenchmarkTools", "PatternFolds","Test"] diff --git a/docs/make.jl b/docs/make.jl index 598b9a7..f46c882 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,24 +1,24 @@ using PerfChecker using Documenter -DocMeta.setdocmeta!(PerfChecker, :DocTestSetup, :(using PerfChecker); recursive=true) +DocMeta.setdocmeta!(PerfChecker, :DocTestSetup, :(using PerfChecker); recursive = true) makedocs(; - modules=[PerfChecker], - authors="Azzaare ", - repo="https://github.com/JuliaConstraints/PerfChecker.jl/blob/{commit}{path}#{line}", - sitename="PerfChecker.jl", - format=Documenter.HTML(; - prettyurls=get(ENV, "CI", "false") == "true", - canonical="https://JuliaConstraints.github.io/PerfChecker.jl", - assets=String[], + modules = [PerfChecker], + authors = "Azzaare ", + repo = "https://github.com/JuliaConstraints/PerfChecker.jl/blob/{commit}{path}#{line}", + sitename = "PerfChecker.jl", + format = Documenter.HTML(; + prettyurls = get(ENV, "CI", "false") == "true", + canonical = "https://JuliaConstraints.github.io/PerfChecker.jl", + assets = String[] ), - pages=[ - "Home" => "index.md", - ], + pages = [ + "Home" => "index.md" + ] ) deploydocs(; - repo="github.com/JuliaConstraints/PerfChecker.jl", - devbranch="main", + repo = "github.com/JuliaConstraints/PerfChecker.jl", + devbranch = "main" ) diff --git a/ext/BenchmarkToolsExt/benchmark.jl b/ext/BenchmarkToolsExt/benchmark.jl index a8a60bf..ea95daa 100644 --- a/ext/BenchmarkToolsExt/benchmark.jl +++ b/ext/BenchmarkToolsExt/benchmark.jl @@ -13,10 +13,12 @@ function PerfChecker.default_options(::Val{:benchmark}) ) end -PerfChecker.check(d::Dict, block::Expr, ::Val{:benchmark}) = quote - d = $d - using BenchmarkTools - return @benchmark $block samples=d[:samples] seconds=d[:seconds] evals=d[:evals] overhead=d[:overhead] gctrial=d[:gctrial] gcsample=d[:gcsample] time_tolerance=d[:time_tolerance] memory_tolerance=d[:memory_tolerance] +function PerfChecker.check(d::Dict, block::Expr, ::Val{:benchmark}) + quote + d = $d + using BenchmarkTools + return @benchmark $block samples=d[:samples] seconds=d[:seconds] evals=d[:evals] overhead=d[:overhead] gctrial=d[:gctrial] gcsample=d[:gcsample] time_tolerance=d[:time_tolerance] memory_tolerance=d[:memory_tolerance] + end end PerfChecker.prep(::Dict, block::Expr, ::Val{:benchmark}) = quote @@ -29,5 +31,6 @@ PerfChecker.post(d::Dict, ::Val{:benchmark}) = d[:check_result] function PerfChecker.to_table(bench::BenchmarkTools.Trial) ti = bench.times l = length(ti) - return Table(times=ti, gctimes=bench.gctimes, memory=fill(bench.memory, l), allocs=fill(bench.allocs, l)) + return Table(times = ti, gctimes = bench.gctimes, + memory = fill(bench.memory, l), allocs = fill(bench.allocs, l)) end diff --git a/ext/ChairmarksExt/ChairmarksExt.jl b/ext/ChairmarksExt/ChairmarksExt.jl index fa089da..dcc02bd 100644 --- a/ext/ChairmarksExt/ChairmarksExt.jl +++ b/ext/ChairmarksExt/ChairmarksExt.jl @@ -8,4 +8,3 @@ include("b.jl") #include("be.jl") #include("chairmark.jl") end - diff --git a/ext/ChairmarksExt/b.jl b/ext/ChairmarksExt/b.jl index 4d92213..d6770f6 100644 --- a/ext/ChairmarksExt/b.jl +++ b/ext/ChairmarksExt/b.jl @@ -30,5 +30,5 @@ function PerfChecker.to_table(chair::Chairmarks.Benchmark) gctimes = [chair.samples[i].gc_fraction for i in 1:l] bytes = [chair.samples[i].bytes for i in 1:l] allocs = [chair.samples[i].allocs for i in 1:l] - return Table(times=times, gctimes=gctimes, bytes=bytes, allocs=allocs) + return Table(times = times, gctimes = gctimes, bytes = bytes, allocs = allocs) end diff --git a/perf/GLM/allocs.jl b/perf/GLM/allocs.jl index 902687d..1e0de3c 100644 --- a/perf/GLM/allocs.jl +++ b/perf/GLM/allocs.jl @@ -2,16 +2,16 @@ using PerfChecker result = @check :alloc Dict(:targets => ["GLM"], :path => @__DIR__) begin using GLM, Random, StatsModels - end begin +end begin n = 2_500_000 rng = Random.MersenneTwister(1234321) tbl = ( - x1=randn(rng, n), - x2=Random.randexp(rng, n), - ss=rand(rng, string.(50:99), n), - y=zeros(n), + x1 = randn(rng, n), + x2 = Random.randexp(rng, n), + ss = rand(rng, string.(50:99), n), + y = zeros(n) ) - f = @formula(y ~ 1 + x1 + x2 + ss) + f = @formula(y~1 + x1 + x2 + ss) f = apply_schema(f, schema(f, tbl)) resp, pred = modelcols(f, tbl) B = randn(rng, size(pred, 2)) diff --git a/perf/GLM/bench.jl b/perf/GLM/bench.jl index 05db130..faf4daf 100644 --- a/perf/GLM/bench.jl +++ b/perf/GLM/bench.jl @@ -2,16 +2,16 @@ using PerfChecker, BenchmarkTools t = @check :benchmark Dict(:path => @__DIR__, :evals => 1, :samples => 100, :seconds => 100) begin using GLM, Random, StatsModels - end begin +end begin n = 2_500_000 rng = Random.MersenneTwister(1234321) tbl = ( - x1 = randn(rng, n), - x2 = Random.randexp(rng, n), - ss = rand(rng, string.(50:99), n), - y = zeros(n), - ) - f = @formula(y ~ 1 + x1 + x2 + ss) + x1 = randn(rng, n), + x2 = Random.randexp(rng, n), + ss = rand(rng, string.(50:99), n), + y = zeros(n) + ) + f = @formula(y~1 + x1 + x2 + ss) f = apply_schema(f, schema(f, tbl)) resp, pred = modelcols(f, tbl) B = randn(rng, size(pred, 2)) diff --git a/perf/PatternFolds/allocs.jl b/perf/PatternFolds/allocs.jl index 27bc7c7..abf6d4d 100644 --- a/perf/PatternFolds/allocs.jl +++ b/perf/PatternFolds/allocs.jl @@ -1,12 +1,12 @@ using PerfChecker -d = Dict(:targets => ["PatternFolds"], :path => @__DIR__, :tags => [:patterns, :intervals], :pkgs => ("PatternFolds", :custom, [v"0.2.3", v"0.2.2"], true)) +d = Dict(:targets => ["PatternFolds"], :path => @__DIR__, :tags => [:patterns, :intervals], + :pkgs => ("PatternFolds", :custom, [v"0.2.3", v"0.2.2"], true)) x = @check :alloc d begin - using PatternFolds - end begin - itv = Interval{Open,Closed}(0.0, 1.0) +end begin + itv = Interval{Open, Closed}(0.0, 1.0) i = IntervalsFold(itv, 2.0, 1000) @info "Checking IntervalsFold" i pattern(i) gap(i) folds(i) size(i) length(i) diff --git a/perf/PatternFolds/bench.jl b/perf/PatternFolds/bench.jl index f622f8f..c26eea8 100644 --- a/perf/PatternFolds/bench.jl +++ b/perf/PatternFolds/bench.jl @@ -2,9 +2,9 @@ using PerfChecker, BenchmarkTools t = @check :benchmark Dict(:path => @__DIR__, :evals => 1, :samples => 100, :seconds => 100) begin using PatternFolds - end begin +end begin # Intervals - itv = Interval{Open,Closed}(0.0, 1.0) + itv = Interval{Open, Closed}(0.0, 1.0) i = IntervalsFold(itv, 2.0, 1000) unfold(i) diff --git a/perf/PatternFolds/chair.jl b/perf/PatternFolds/chair.jl index 9eb8511..a35b359 100644 --- a/perf/PatternFolds/chair.jl +++ b/perf/PatternFolds/chair.jl @@ -1,12 +1,12 @@ using PerfChecker, Chairmarks import Pkg -Pkg.status(;extensions=true) +Pkg.status(; extensions = true) t = @check :chairmark Dict(:path => @__DIR__, :evals => 1) begin using PatternFolds - end begin +end begin # Intervals - itv = Interval{Open,Closed}(0.0, 1.0) + itv = Interval{Open, Closed}(0.0, 1.0) i = IntervalsFold(itv, 2.0, 1000) unfold(i) diff --git a/src/PerfChecker.jl b/src/PerfChecker.jl index 744f7f1..b8d7be0 100644 --- a/src/PerfChecker.jl +++ b/src/PerfChecker.jl @@ -21,8 +21,8 @@ end struct CheckerResult tables::Vector{Table} - hwinfo::Union{HwInfo,Nothing} - tags::Union{Nothing,Vector{Symbol}} + hwinfo::Union{HwInfo, Nothing} + tags::Union{Nothing, Vector{Symbol}} pkgs::Vector{PackageSpec} end @@ -46,7 +46,9 @@ function Base.show(io::IO, v::PerfChecker.CheckerResult) println(io, Base.display(v.pkgs)) end -find_by_tags(tags::Vector{Symbol}, results::CheckerResult; exact_match = true) = findall(x -> exact_match ? (tags == x.tags) : (!isempty(x.tags ∩ tags)), results) +function find_by_tags(tags::Vector{Symbol}, results::CheckerResult; exact_match = true) + findall(x -> exact_match ? (tags == x.tags) : (!isempty(x.tags ∩ tags)), results) +end # SECTION - Exports export @check diff --git a/src/alloc.jl b/src/alloc.jl index 4a8e41e..a9b103c 100644 --- a/src/alloc.jl +++ b/src/alloc.jl @@ -9,7 +9,6 @@ function default_options(::Val{:alloc}) end function check(d::Dict, block::Expr, ::Val{:alloc}) - j = haskey(d, :repeat) && d[:repeat] ? block : nothing quote @@ -21,7 +20,8 @@ function check(d::Dict, block::Expr, ::Val{:alloc}) if isempty(targets) targets = Base.loaded_modules_array() end - return dirname.(filter(!isnothing, pathof.(targets))), dirname.(filter(!isnothing, pathof.(rmstuff))) + return dirname.(filter(!isnothing, pathof.(targets))), + dirname.(filter(!isnothing, pathof.(rmstuff))) end end @@ -40,8 +40,9 @@ end function to_table(myallocs::Vector{MallocInfo}) b = map(a -> a.bytes, Iterators.reverse(myallocs)) - r = round.(b / sum(b) * 100; digits=2) - f = map(first ∘ splitext ∘ first ∘ splitext, map(a -> a.filename, Iterators.reverse(myallocs))) + r = round.(b / sum(b) * 100; digits = 2) + f = map(first ∘ splitext ∘ first ∘ splitext, + map(a -> a.filename, Iterators.reverse(myallocs))) l = map(a -> a.linenumber, Iterators.reverse(myallocs)) - Table(bytes=b, percentage=r, filenames=f, linenumbers=l) + Table(bytes = b, percentage = r, filenames = f, linenumbers = l) end diff --git a/src/check.jl b/src/check.jl index 1f24687..29720bf 100644 --- a/src/check.jl +++ b/src/check.jl @@ -1,5 +1,9 @@ -prep(d, b, v) = quote nothing end -check(d, b, v) = quote nothing end +prep(d, b, v) = quote + nothing +end +check(d, b, v) = quote + nothing +end post(d, v) = nothing default_options(v) = Dict() @@ -8,8 +12,8 @@ check(d::Dict, b::Expr, v::Symbol) = check(d, b, Val(v)) post(d::Dict, v::Symbol) = post(d, Val(v)) function default_options(d::Dict, v::Symbol) - di = default_options(Val(v)) - return merge(di, d) + di = default_options(Val(v)) + return merge(di, d) end macro check(x, d, block1, block2) @@ -33,47 +37,55 @@ macro check(x, d, block1, block2) ) pkgs = if haskey(di, :pkgs) - [PackageSpec(name=di[:pkgs][1], version=i) for i in get_versions(di[:pkgs])[2]] - else + [PackageSpec(name = di[:pkgs][1], version = i) + for i in get_versions(di[:pkgs])[2]] + else PackageSpec[PackageSpec()] end devop = haskey(di, :devops) len = length(pkgs) + devop - - for i in 1:len - p = remotecall_fetch(Core.eval, 1, Main, - Expr(:toplevel, quote - import Distributed - d = $di - t = tempname() - cp(d[:path], t) - Distributed.addprocs(1; exeflags=["--track-allocation=$(d[:track])", "--project=$t", "-t $(d[:threads])"]) - end).args...) |> first + for i in 1:len + p = remotecall_fetch(Core.eval, + 1, + Main, + Expr(:toplevel, + quote + import Distributed + d = $di + t = tempname() + cp(d[:path], t) + Distributed.addprocs(1; + exeflags = ["--track-allocation=$(d[:track])", + "--project=$t", "-t $(d[:threads])"]) + end).args...) |> first remotecall_fetch(Core.eval, p, Main, - Expr(:toplevel, quote - import Pkg; - Pkg.instantiate(); + Expr(:toplevel, + quote + import Pkg + Pkg.instantiate() import PerfChecker d = $di pkgs = if haskey(d, :pkgs) - [Pkg.PackageSpec(name=d[:pkgs][1], version=i) for i in PerfChecker.get_versions(d[:pkgs])[2]] - else + [Pkg.PackageSpec(name = d[:pkgs][1], version = i) + for i in PerfChecker.get_versions(d[:pkgs])[2]] + else Pkg.PackageSpec[Pkg.PackageSpec()] end - + if !($i == $len && $devop) pkgs != [Pkg.PackageSpec()] && Pkg.add(getindex(pkgs, $i)) else pkg = d[:devops] - pkg isa Tuple ? Pkg.develop(pkg[1]; pkg[2]...) : Pkg.develop(pkg) - end + pkg isa Tuple ? Pkg.develop(pkg[1]; pkg[2]...) : + Pkg.develop(pkg) + end haskey(d, :extra_pkgs) && Pkg.add(d[:extra_pkgs]) - end).args...) + end).args...) di[:prep_result] = remotecall_fetch(Core.eval, p, Main, Expr(:toplevel, g.args...)) @@ -88,10 +100,9 @@ macro check(x, d, block1, block2) end).args...) res = $post(di, $x) push!(results.tables, res |> to_table) - if !(devop && i == len) + if !(devop && i == len) push!(results.pkgs, pkgs[i]) end - end results end diff --git a/src/versions.jl b/src/versions.jl index 4d78dc9..21cfe0c 100644 --- a/src/versions.jl +++ b/src/versions.jl @@ -15,15 +15,19 @@ julia> get_pkg_versions("ConstraintLearning") v"0.1.2" ``` """ -function get_pkg_versions(name::String, regname::Union{Nothing,Vector{String}} = nothing)::Vector{VersionNumber} - regs = Types.Context().registries - indexes = isnothing(regname) ? collect(1:length(regs)) : findall(x -> x.name in regname, regs) +function get_pkg_versions(name::String, + regname::Union{Nothing, Vector{String}} = nothing)::Vector{VersionNumber} + regs = Types.Context().registries + indexes = isnothing(regname) ? collect(1:length(regs)) : + findall(x -> x.name in regname, regs) - versions::Set{String} = Set([]) - for i in indexes - push!(versions, keys(parse(regs[i].in_memory_registry[join([first(name),name,"Versions.toml"], '/')]))...) - end - return VersionNumber.(versions) + versions::Set{String} = Set([]) + for i in indexes + push!(versions, + keys(parse(regs[i].in_memory_registry[join( + [first(name), name, "Versions.toml"], '/')]))...) + end + return VersionNumber.(versions) end const VerConfig = Tuple{String, Symbol, Vector{VersionNumber}, Bool} @@ -73,25 +77,25 @@ function arrange_major(a::VersionNumber, v::Vector{VersionNumber}, maxo::Bool) end function arrange_custom(a::VersionNumber, ::Vector{VersionNumber}, ::Bool) - return [a] + return [a] end function get_versions(pkgconf::VerConfig, regname::Union{Nothing, Vector{String}} = nothing) - versions = get_pkg_versions(pkgconf[1], regname) + versions = get_pkg_versions(pkgconf[1], regname) - s = pkgconf[2] - f = if s == :patches - arrange_patches - elseif s == :breaking - arrange_breaking - elseif s == :major - arrange_major - elseif s == :minor - arrange_minor - elseif s == :custom - arrange_custom - else - error("Unknown option provided $s") - end - return pkgconf[1], Iterators.flatten(map(x -> f(x, versions, pkgconf[4]), pkgconf[3])) + s = pkgconf[2] + f = if s == :patches + arrange_patches + elseif s == :breaking + arrange_breaking + elseif s == :major + arrange_major + elseif s == :minor + arrange_minor + elseif s == :custom + arrange_custom + else + error("Unknown option provided $s") + end + return pkgconf[1], Iterators.flatten(map(x -> f(x, versions, pkgconf[4]), pkgconf[3])) end diff --git a/test/Aqua.jl b/test/Aqua.jl new file mode 100644 index 0000000..fd93354 --- /dev/null +++ b/test/Aqua.jl @@ -0,0 +1,28 @@ +@testset "Aqua.jl" begin + import Aqua + import PerfChecker + + # TODO: Fix the broken tests and remove the `broken = true` flag + Aqua.test_all( + PerfChecker; + ambiguities = (broken = true,), + deps_compat = false, + piracies = (broken = true,) + ) + + @testset "Ambiguities: PatternFolds" begin + Aqua.test_ambiguities(PerfChecker) + end + + @testset "Piracies: PatternFolds" begin + Aqua.test_piracies(PerfChecker; + # treat_as_own = [Intervals.Interval] + ) + end + + @testset "Dependencies compatibility (no extras)" begin + Aqua.test_deps_compat(PerfChecker; + check_extras = false # ignore = [:Random] + ) + end +end diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 1739b3f..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,16 +0,0 @@ -[deps] -BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -CompatHelperLocal = "5224ae11-6099-4aaa-941d-3aab004bd678" -ConstraintDomains = "5800fd60-8556-4464-8d61-84ebf7a0bedb" -Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" -PatternFolds = "c18a7f1d-76ad-4ce4-950d-5419b888513b" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[compat] -BenchmarkTools = "1.5.0" -CompatHelperLocal = "0.1.26" -ConstraintDomains = "0.3.9" -PatternFolds = "0.2.3" -julia = "1" diff --git a/test/pattern_folds.jl b/test/pattern_folds.jl index 0a7422d..45e67b7 100644 --- a/test/pattern_folds.jl +++ b/test/pattern_folds.jl @@ -1,8 +1,8 @@ @testset "PatternFolds.jl" begin x = @check :alloc Dict(:targets => ["PatternFolds"], :path => @__DIR__) begin using PatternFolds - end begin - itv = Interval{Open,Closed}(0.0, 1.0) + end begin + itv = Interval{Open, Closed}(0.0, 1.0) i = IntervalsFold(itv, 2.0, 1000) @info "Checking IntervalsFold" i pattern(i) gap(i) folds(i) size(i) length(i) @@ -24,11 +24,12 @@ @info x - t = @check :benchmark Dict(:path => @__DIR__, :evals => 1, :samples => 100, :seconds => 100) begin + t = @check :benchmark Dict( + :path => @__DIR__, :evals => 1, :samples => 100, :seconds => 100) begin using PatternFolds - end begin + end begin # Intervals - itv = Interval{Open,Closed}(0.0, 1.0) + itv = Interval{Open, Closed}(0.0, 1.0) i = IntervalsFold(itv, 2.0, 1000) unfold(i) diff --git a/test/runtests.jl b/test/runtests.jl index 0de52df..695e41c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,12 +1,14 @@ -using BenchmarkTools -using Distributed -using PerfChecker using Test -import CompatHelperLocal +@testset "Package tests: PerfChecker" begin + include("Aqua.jl") -CompatHelperLocal.@check() + @testset "Other Packages" begin + using BenchmarkTools + using Distributed + using PerfChecker -# include("compositional_networks.jl") - -include("pattern_folds.jl") + # include("compositional_networks.jl") + include("pattern_folds.jl") + end +end From daf5d9e4e93675b628375a5e2d386bcad47e3a48 Mon Sep 17 00:00:00 2001 From: Azzaare Date: Tue, 14 May 2024 03:48:31 +0000 Subject: [PATCH 2/4] Moved a broken test to unbroken --- Project.toml | 2 +- test/Aqua.jl | 45 +++++++++++++++++++++++---------------------- test/runtests.jl | 16 ++++++++-------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Project.toml b/Project.toml index aee9457..35b9dca 100644 --- a/Project.toml +++ b/Project.toml @@ -35,4 +35,4 @@ PatternFolds = "c18a7f1d-76ad-4ce4-950d-5419b888513b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "BenchmarkTools", "PatternFolds","Test"] +test = ["Aqua", "BenchmarkTools", "PatternFolds", "Test"] diff --git a/test/Aqua.jl b/test/Aqua.jl index fd93354..add78f4 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -1,28 +1,29 @@ @testset "Aqua.jl" begin - import Aqua - import PerfChecker + import Aqua + import PerfChecker - # TODO: Fix the broken tests and remove the `broken = true` flag - Aqua.test_all( - PerfChecker; - ambiguities = (broken = true,), - deps_compat = false, - piracies = (broken = true,) - ) + # TODO: Fix the broken tests and remove the `broken = true` flag + Aqua.test_all( + PerfChecker; + ambiguities = (broken = true,), + deps_compat = false, + piracies = (broken = false,) + ) - @testset "Ambiguities: PatternFolds" begin - Aqua.test_ambiguities(PerfChecker) - end + @testset "Ambiguities: PatternFolds" begin + Aqua.test_ambiguities(PerfChecker) + end - @testset "Piracies: PatternFolds" begin - Aqua.test_piracies(PerfChecker; - # treat_as_own = [Intervals.Interval] - ) - end + @testset "Piracies: PatternFolds" begin + Aqua.test_piracies(PerfChecker; + # treat_as_own = [Intervals.Interval] + ) + end - @testset "Dependencies compatibility (no extras)" begin - Aqua.test_deps_compat(PerfChecker; - check_extras = false # ignore = [:Random] - ) - end + @testset "Dependencies compatibility (no extras)" begin + Aqua.test_deps_compat(PerfChecker; + check_extras = false, + ignore = [:Distributed, :Pkg, :Profile, :TOML] + ) + end end diff --git a/test/runtests.jl b/test/runtests.jl index 695e41c..934ca90 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,14 +1,14 @@ using Test @testset "Package tests: PerfChecker" begin - include("Aqua.jl") + include("Aqua.jl") - @testset "Other Packages" begin - using BenchmarkTools - using Distributed - using PerfChecker + @testset "Other Packages" begin + using BenchmarkTools + using Distributed + using PerfChecker - # include("compositional_networks.jl") - include("pattern_folds.jl") - end + # include("compositional_networks.jl") + # include("pattern_folds.jl") + end end From 5cf2065290fffdaccdaaef588e798698262fd873 Mon Sep 17 00:00:00 2001 From: Azzaare Date: Tue, 14 May 2024 03:55:16 +0000 Subject: [PATCH 3/4] Fix typo and commented tests --- README.md | 8 +++----- test/Aqua.jl | 4 ++-- test/runtests.jl | 16 ++++++++-------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index fbe14a3..3262d84 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,10 @@ [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaConstraints.github.io/PerfChecker.jl/dev) [![Build Status](https://github.com/JuliaConstraints/PerfChecker.jl/workflows/CI/badge.svg)](https://github.com/JuliaConstraints/PerfChecker.jl/actions) [![codecov](https://codecov.io/gh/JuliaConstraints/PerfChecker.jl/branch/main/graph/badge.svg?token=YVJhN4dpBp)](https://codecov.io/gh/JuliaConstraints/PerfChecker.jl) -[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) +[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle) [![Chat: Mattermost](https://img.shields.io/badge/chat-mattermost-blueviolet.svg)](https://nohost.iijlab.net/chat/signup_user_complete/?id=nnuc1g14gtrqtnas6thu193xmr) [![Website: JuliaConstraints](https://img.shields.io/badge/website-JuliaConstraints-informational.svg)](https://juliaconstraints.github.io/) - - `PerfChecker` is a set of performance checking tools for Julia packages. The ultimate aim is to create an environment where the tool can run similarly to a test environment. By doing so, it would be possible to test the performance of a package `P` in separate Julia instances. This would allow for each version of `P`: - The use of the latest compatible versions of Julia and other dependencies of P @@ -123,7 +121,7 @@ using PerfChecker using Test # Target(s) -using CompositionalNetworks # lastest release: 0.3.1 +using CompositionalNetworks # latest release: 0.3.1 # Direct dependencies of this script using ConstraintDomains @@ -166,7 +164,7 @@ using PerfChecker using BenchmarkTools # Target(s) -using CompositionalNetworks # lastest release: 0.3.1 +using CompositionalNetworks # latest release: 0.3.1 # Direct dependencies of this script using ConstraintDomains diff --git a/test/Aqua.jl b/test/Aqua.jl index add78f4..028a66d 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -10,11 +10,11 @@ piracies = (broken = false,) ) - @testset "Ambiguities: PatternFolds" begin + @testset "Ambiguities: PerfChecker" begin Aqua.test_ambiguities(PerfChecker) end - @testset "Piracies: PatternFolds" begin + @testset "Piracies: PerfChecker" begin Aqua.test_piracies(PerfChecker; # treat_as_own = [Intervals.Interval] ) diff --git a/test/runtests.jl b/test/runtests.jl index 934ca90..695e41c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,14 +1,14 @@ using Test @testset "Package tests: PerfChecker" begin - include("Aqua.jl") + include("Aqua.jl") - @testset "Other Packages" begin - using BenchmarkTools - using Distributed - using PerfChecker + @testset "Other Packages" begin + using BenchmarkTools + using Distributed + using PerfChecker - # include("compositional_networks.jl") - # include("pattern_folds.jl") - end + # include("compositional_networks.jl") + include("pattern_folds.jl") + end end From 1409b2de97ed17d6093aa30a4abf4c78aa36e7d1 Mon Sep 17 00:00:00 2001 From: Azzaare Date: Tue, 14 May 2024 03:59:14 +0000 Subject: [PATCH 4/4] Fix format --- test/Aqua.jl | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/test/Aqua.jl b/test/Aqua.jl index 028a66d..4affd12 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -1,29 +1,29 @@ @testset "Aqua.jl" begin - import Aqua - import PerfChecker + import Aqua + import PerfChecker - # TODO: Fix the broken tests and remove the `broken = true` flag - Aqua.test_all( - PerfChecker; - ambiguities = (broken = true,), - deps_compat = false, - piracies = (broken = false,) - ) + # TODO: Fix the broken tests and remove the `broken = true` flag + Aqua.test_all( + PerfChecker; + ambiguities = (broken = true,), + deps_compat = false, + piracies = (broken = false,) + ) - @testset "Ambiguities: PerfChecker" begin - Aqua.test_ambiguities(PerfChecker) - end + @testset "Ambiguities: PerfChecker" begin + Aqua.test_ambiguities(PerfChecker) + end - @testset "Piracies: PerfChecker" begin - Aqua.test_piracies(PerfChecker; - # treat_as_own = [Intervals.Interval] - ) - end + @testset "Piracies: PerfChecker" begin + Aqua.test_piracies(PerfChecker; + # treat_as_own = [Intervals.Interval] + ) + end - @testset "Dependencies compatibility (no extras)" begin - Aqua.test_deps_compat(PerfChecker; - check_extras = false, - ignore = [:Distributed, :Pkg, :Profile, :TOML] - ) - end + @testset "Dependencies compatibility (no extras)" begin + Aqua.test_deps_compat(PerfChecker; + check_extras = false, + ignore = [:Distributed, :Pkg, :Profile, :TOML] + ) + end end