-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (67 loc) · 2.38 KB
/
test-coverage.yaml
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
# This action will test the code coverage of all R files that contains examples and
# Unit tests. This will be triggered using `workflow_run` after a successful run of
# the Lint action.
#
# This file must live on `main` branch, and any version in other branches will not
# be triggered. This is a "feature" of GH-actions. The workaround for working with
# the right branch is using the 'github.event.workflow_run.head_branch' on action
# 'actions/checkout'. Thanks to Potherca https://stackoverflow.com/a/65081720/2195337
name: Covr
on:
push:
branches:
- main
- master
- develop
workflow_dispatch:
repository_dispatch:
concurrency:
group: coverage
cancel-in-progress: true
jobs:
test-coverage:
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, 'coverage') }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv
CODECOV_TOKEN: "4676dbf0-8296-4fd8-9542-a476503b0118"
steps:
- name: Checking out shallow repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.workflow_run.head_branch }}
- run: git branch
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install other dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgit2-dev libharfbuzz-dev libcurl4-openssl-dev \
libfribidi-dev libzmq3-dev libmagick++-dev
- name: Setting up R installation
uses: r-lib/actions/setup-r@v2
- name: Setting up pandoc and pandoc-citeproc
uses: r-lib/actions/setup-pandoc@v2
- name: Cache R packages
uses: actions/cache@v2.1.4
id: cache-packages
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}-targets-v2
restore-keys: |
${{ runner.os }}-renv-
- name: Install dependencies
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
Sys.unsetenv("GITHUB_PAT")
renv::restore()
shell: Rscript {0}
- name: Test coverage
run: covr::codecov()
shell: Rscript {0}