Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Heptazhou committed Dec 28, 2022
1 parent f7aae4c commit f077b32
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Example

```yaml
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
Expand All @@ -17,6 +18,32 @@
file: lcov.info
```
OR
```yaml
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: julia-actions/setup-julia@v1
with:
show-versioninfo: true
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: heptazhou/julia-codecov@v1
with:
skip: true
keep: false
file: lcov.info
dirs: |
src
dir1
dir2
- uses: codecov/codecov-action@v3
with:
file: lcov.info
```
### Option
See [action.yml](action.yml).
Expand Down
21 changes: 13 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ branding:
color: "gray-dark"

inputs:
directory:
dirs:
default: "src"
description: "Colon-separated list of directories to look for coverage (e.g., `src:examples`)"
description: "List of directories to look for coverage, separated by endl or colon (e.g., `src:dir1:dir2`)"
required: false
file:
default: "lcov.info"
description: "Path of lcov file to use. Will try to generate it if not exists."
description: "Path of the lcov file to use. Will generate one if missing."
required: false
force:
keep:
default: "true"
description: "If so, use an existing lcov file (`true` or `false`)."
required: false
skip:
default: "false"
description: "Force to generate a new lcov file (`true` or `false`)."
description: "Skip any missing directory (`true` or `false`)."
required: false

runs:
Expand All @@ -26,6 +30,7 @@ runs:
- run: julia --color=yes "$GITHUB_ACTION_PATH"/main.jl
shell: bash
env:
INPUT_DIRECTORY: ${{ inputs.directory }}
INPUT_FILE_LCOV: ${{ inputs.file }}
INPUT_FORCE: ${{ inputs.force }}
INPUT_DIRECTORY: ${{ inputs.dirs }}
INPUT_LCOV_FILE: ${{ inputs.file }}
INPUT_LCOV_KEEP: ${{ inputs.keep }}
INPUT_SKIP_MISS: ${{ inputs.skip }}
18 changes: 11 additions & 7 deletions main.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
const bool(s::AbstractString) = parse(Bool, s)

using Pkg

Pkg.activate("coveragetempenv", shared = true)
Pkg.activate("coverage_temp_env", shared = true)
Pkg.add(PackageSpec(name = "CoverageTools"))

using CoverageTools

dirs = get(ENV, "INPUT_DIRECTORY", "src")
lcov = get(ENV, "INPUT_FILE_LCOV", "lcov.info")
ign = parse(Bool, get(ENV, "INPUT_FORCE", "false"))
file = get(ENV, "INPUT_LCOV_FILE", "lcov.info")
keep = get(ENV, "INPUT_LCOV_KEEP", "1") |> bool
skip = get(ENV, "INPUT_SKIP_MISS", "0") |> bool

dirs = filter!(!isempty, split(dirs, ":"))
dirs = filter!(!isempty, split(dirs, r":|\n"))
skip && filter!(ispath, dirs)
for dir in dirs
isdir(dir) || error("`$dir` is not a directory")
end
isdir(lcov) && error("`$lcov` is a directory")
isdir(file) && error("`$file` is a directory")

fcs = !ign && isfile(lcov) ? LCOV.readfile(lcov) : vcat(process_folder.(dirs)...)
LCOV.writefile(lcov, fcs)
fcs = keep && isfile(file) ? LCOV.readfile(file) : vcat(process_folder.(dirs)...)
LCOV.writefile(file, fcs)

cvr, tot = get_summary(fcs)
pct = round(100cvr / tot, digits = 2)
Expand Down

0 comments on commit f077b32

Please sign in to comment.