Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

essai1 test codecov #232

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- 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

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- 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@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ URL: https://www.econ.puc-rio.br/datazoom/
Depends:
R (>= 4.0)
Imports:
withr,
data.table,
dplyr,
Hmisc,
Expand All @@ -45,7 +46,9 @@ Suggests:
knitr,
RCurl,
rmarkdown,
terra
terra,
testthat (>= 3.0.0)
Config/testthat/edition: 3
LinkingTo:
Rcpp
VignetteBuilder:
Expand Down
20 changes: 20 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true

jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
14 changes: 14 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(datazoom.amazonia)


test_check("datazoom.amazonia")

1 change: 1 addition & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
withr::local_options(usethis.quiet = TRUE, .local_envir = teardown_env())
11 changes: 11 additions & 0 deletions tests/testthat/test-climate.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("uploads the data without error", {
expect_no_error(load_climate(dataset='precipitation',
time_period=2010,
legal_amazon_only = TRUE,
language = "pt"), message="No success")
expect_no_error(load_climate(dataset='potential_evaporation',
time_period=2015,
legal_amazon_only = TRUE,
language = "eng"), message="No success")
})

8 changes: 8 additions & 0 deletions tests/testthat/test-datasus.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("uploads the data without error", {
expect_no_error(load_datasus(dataset = "datasus_sim_do",
time_period = 2010,
states = c("AM", "PA"),
raw_data = FALSE,
keep_all = FALSE,
language = "pt"), message="No success")
})
10 changes: 10 additions & 0 deletions tests/testthat/test-deter.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test_that("uploads the data without error", {
expect_no_error(load_deter(dataset='deter_amz',
raw_data=TRUE), message="No success")
expect_no_error(load_deter(dataset='deter_cerrado',
raw_data=TRUE), message="No success")
expect_no_error(load_deter(dataset='deter_amz',
raw_data=FALSE), message="No success")
})


6 changes: 6 additions & 0 deletions tests/testthat/test-ips.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_that("uploads the data without error", {
expect_no_error(load_ips(dataset = "deforest", raw_data = FALSE,
time_period = 2018, language = "pt"), message="No success")
expect_no_error(load_ips(dataset = "life_quality", raw_data = FALSE,
time_period = 2013, language = "eng"), message="No success")
})
12 changes: 12 additions & 0 deletions tests/testthat/test-seeg.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
test_that("uploads the data without error", {
expect_no_error(load_seeg(dataset = "seeg_industry",
raw_data = FALSE,
geo_level = "country",
language = "pt"), message="No success")
expect_no_error(load_seeg(dataset = "seeg_farming",
raw_data = FALSE,
geo_level = "state",
language = "eng"), message="No success")
})


Loading