tfiers / PkgGraph.jl

Visualize the dependency graph of a Julia package
https://tfiers.github.io/PkgGraph.jl
MIT License
42 stars 2 forks source link

Test/Code coverage #30

Open tfiers opened 1 year ago

tfiers commented 1 year ago

I mainly just want the badge w/ the number.

There's https://github.com/JuliaCI/Coverage.jl

How do other pkg's do it? which have it.. julia itself yes. ah, dataframes https://github.com/JuliaData/DataFrames.jl/blob/main/.github/workflows/ci.yml https://codecov.io/gh/JuliaData/DataFrames.jl/tree/master/src https://docs.julialang.org/en/v1/stdlib/Test/ (nothing there)

tfiers commented 1 year ago

docs.julialang.org/en/v1/stdlib/Test (nothing there)

yes but, ] ?test does have a --coverage flag (I knew I'd seen sth)

tfiers commented 1 year ago

That flag produces a bunch of .cov files.. e.g. depgraph.jl.33204.cov (next to src/internals.depgraph.jl)

        - """
        -     depgraph(pkgname)
        -    
⋮
        - """
        9 depgraph(pkgname) = begin
        9     rootpkg = string(pkgname)
        9     packages = packages_in_active_manifest()
        9     if rootpkg ∉ keys(packages)
        1         error("""
        -         The given package ($pkgname) must be installed in the active project
        -         (which is currently `$(active_project())`)""")
        -     end
        8     deps = Vector{Pair{String, String}}()
       42     add_deps_of(name) = begin
       34         pkg_info = only(packages[name])  # Two packages with same name not supported.
       34         direct_deps = get(pkg_info, "deps", [])
       34         for dep in direct_deps
       26             push!(deps, name => dep)
       26             add_deps_of(dep)
       26         end
        -     end
        8     add_deps_of(rootpkg)
        8     return unique!(deps)  # Could use a SortedSet instead; but this spares a pkg load.
        - end
…

guess that's no. of times line is hit

tfiers commented 1 year ago

btw, it's a cmd-line flag for julia itself: julia --code-coverage, https://docs.julialang.org/en/v1/manual/command-line-options/

(found via https://github.com/tfiers/PkgGraphs.jl/actions/runs/3800070568/jobs/6463193393#step:6:43)

tfiers commented 1 year ago

Ah, PkgTemplates has a flag for it (that I manually set false). Template(plugins = [GitHubActions(coverage = true, …)])