Repository navigation
69 lines (59 loc) · 2.13 KB
/
Copy pathcoverage.yaml
File metadata and controls
69 lines (59 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
name: coverage
permissions: read-all
# Cancel a superseded run (e.g. a newer push to the same ref) so its minutes
# are not wasted completing.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage
# Test fixtures are deterministic generated artifacts (gitignored), so
# they are rebuilt here rather than committed. See data-raw/make_fixtures.R.
- name: Generate test fixtures
run: Rscript data-raw/make_fixtures.R
- name: Compute coverage and gate core modules
run: |
cov <- covr::package_coverage(
quiet = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "entropiaR")
)
res <- covr::coverage_to_list(cov)$filecoverage
core <- c("connect", "schema", "corpus", "collect")
idx <- vapply(names(res), function(n) basename(n) %in% paste0(core, ".R"), logical(1))
core_cov <- res[idx]
core_cov <- core_cov[order(names(core_cov))]
print(core_cov)
low <- core_cov[core_cov < 80]
if (length(low) > 0) {
stop(
"Coverage below 80% on core modules: ",
paste(names(low), collapse = ", ")
)
}
cat("Core-module coverage gate passed (>= 80%).\n")
shell: Rscript {0}
- name: Show testthat output
if: failure()
run: |
find "${{ runner.temp }}/entropiaR" -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash