-
Notifications
You must be signed in to change notification settings - Fork 3
106 lines (90 loc) · 3.33 KB
/
Copy pathtest-coverage.yml
File metadata and controls
106 lines (90 loc) · 3.33 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
# 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:
name: test-coverage
permissions:
contents: 'read'
id-token: 'write'
jobs:
test-coverage:
runs-on: ubuntu-latest
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
WIF_PROVIDER: ${{ secrets.WIF_PROVIDER }}
GCP_SA_EMAIL: ${{ secrets.GCP_SA_EMAIL }}
steps:
- uses: actions/checkout@v6
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: actions/setup-python@v6
with:
python-version: '3.13'
architecture: 'x64'
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::remotes, any::covr, any::xml2, rstudio/reticulate, local::.
needs: coverage
- name: Install Python dependencies
run: |
reticulate::virtualenv_create("r-rgeedim")
reticulate::use_virtualenv("r-rgeedim")
reticulate::virtualenv_install("r-rgeedim", "geedim")
shell: Rscript {0}
- name: Authenticate to Google Cloud (WIF)
uses: 'google-github-actions/auth@v3'
with:
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
token-format: 'access_token'
access_token_lifetime: '3600s'
- name: Set up Google Application Credentials for rgeedim
run: |
creds_file <- Sys.getenv("GOOGLE_APPLICATION_CREDENTIALS")
if (creds_file == "" || !file.exists(creds_file)) {
stop("GOOGLE_APPLICATION_CREDENTIALS not set or file does not exist")
}
shell: Rscript {0}
- name: Authenticate with Earth Engine
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
run: |
rgeedim::gd_authenticate()
rgeedim::gd_initialize(project = Sys.getenv("GCP_PROJECT_ID"))
shell: Rscript {0}
- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
print(cov)
covr::to_cobertura(cov)
shell: Rscript {0}
- uses: codecov/codecov-action@v7
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
files: ./cobertura.xml
plugins: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v7
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package