Repository navigation
116 lines (101 loc) · 3.49 KB
/
Copy pathtest-coverage.yaml
File metadata and controls
116 lines (101 loc) · 3.49 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
on:
push:
branches: [develop]
pull_request:
branches: [develop]
types: [opened, reopened, synchronize, ready_for_review]
workflow_dispatch:
name: test-coverage
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
checks: write
pull-requests: write
jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
EQ_API_KEY: ${{ secrets.EQ_API_KEY }}
steps:
- uses: actions/checkout@v7
- 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, any::xml2
needs: coverage
- name: Capture Environment Info
run: |
Rscript -e '
env_vars <- Sys.getenv()
pkg_versions <- installed.packages()[, c("Package", "Version")]
sys_info <- Sys.info()
save(env_vars, pkg_versions, sys_info, file = "ci_env_info.RData")
'
- name: Upload Environment Info
if: always()
uses: actions/upload-artifact@v7
with:
name: ci_env_info
path: ci_env_info.RData
if-no-files-found: ignore
- name: Test coverage
run: |
orig <- getwd(); on.exit(setwd(orig), add = TRUE)
cat("Working dir (start):", getwd(), "\n")
cov <- covr::package_coverage(
path = ".",
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
print(cov)
out <- file.path(Sys.getenv("GITHUB_WORKSPACE"), "cobertura.xml")
covr::to_cobertura(cov, filename = out)
message("Wrote: ", out, " exists? ", file.exists(out))
cat("Working dir (end):", getwd(), "\n")
shell: Rscript {0}
- name: Show testthat output
if: always()
run: |
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Verify coverage file
if: always()
run: |
echo "PWD: $(pwd)"
ls -lah
echo "Searching for cobertura.xml in workspace and temp..."
find "$GITHUB_WORKSPACE" -maxdepth 3 -name 'cobertura.xml' -ls || true
find "$RUNNER_TEMP" -maxdepth 5 -name 'cobertura.xml' -ls || true
shell: bash
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v7
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
if-no-files-found: ignore
- name: Upload coverage report
if: ${{ hashFiles('cobertura.xml') != '' }}
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: ${{ github.workspace }}/cobertura.xml
if-no-files-found: error
- name: Comment coverage
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && hashFiles('cobertura.xml') != '' }}
uses: 5monkeys/cobertura-action@master
with:
report_name: coverage-report
path: ${{ github.workspace }}/cobertura.xml
minimum_coverage: 20
only_changed_files: true
show_missing: true
link_missing_lines: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}