Skip to content

Commit 16db94c

Browse files
committed
fix unit tests for time check
1 parent b44711d commit 16db94c

File tree

6 files changed

+54
-124
lines changed

6 files changed

+54
-124
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
2-
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
1+
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
5-
branches:
6-
- main
7-
- master
5+
branches: [main, master]
86
pull_request:
9-
branches:
10-
- main
11-
- master
7+
branches: [main, master]
128

139
name: R-CMD-check
1410

@@ -22,72 +18,30 @@ jobs:
2218
fail-fast: false
2319
matrix:
2420
config:
21+
- {os: macOS-latest, r: 'release'}
2522
- {os: windows-latest, r: 'release'}
2623
- {os: windows-latest, r: 'devel'}
27-
- {os: macOS-latest, r: 'release'}
28-
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
29-
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
24+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
25+
- {os: ubuntu-latest, r: 'release'}
26+
- {os: ubuntu-latest, r: 'oldrel-1'}
3027

3128
env:
32-
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
33-
RSPM: ${{ matrix.config.rspm }}
3429
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
30+
R_KEEP_PKG_SOURCE: yes
3531

3632
steps:
3733
- uses: actions/checkout@v2
3834

35+
- uses: r-lib/actions/setup-pandoc@v1
36+
3937
- uses: r-lib/actions/setup-r@v1
4038
with:
4139
r-version: ${{ matrix.config.r }}
40+
http-user-agent: ${{ matrix.config.http-user-agent }}
41+
use-public-rspm: true
4242

43-
- uses: r-lib/actions/setup-pandoc@v1
44-
45-
- name: Query dependencies
46-
run: |
47-
install.packages('remotes')
48-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
49-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
50-
shell: Rscript {0}
51-
52-
- name: Restore R package cache
53-
uses: actions/cache@v2
43+
- uses: r-lib/actions/setup-r-dependencies@v1
5444
with:
55-
path: ${{ env.R_LIBS_USER }}
56-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
57-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
45+
extra-packages: rcmdcheck
5846

59-
- name: Install system dependencies
60-
if: runner.os == 'Linux'
61-
run: |
62-
while read -r cmd
63-
do
64-
eval sudo $cmd
65-
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
66-
67-
- name: Install dependencies
68-
run: |
69-
remotes::install_deps(dependencies = TRUE)
70-
remotes::install_cran("rcmdcheck")
71-
shell: Rscript {0}
72-
73-
- name: Check
74-
env:
75-
_R_CHECK_CRAN_INCOMING_REMOTE_: false
76-
run: |
77-
options(crayon.enabled = TRUE)
78-
print(R.version)
79-
args <- if (.Platform$OS.type == "windows" & grepl("unstable", R.version$status)) {
80-
c("--no-manual", "--as-cran", "--no-multiarch")
81-
} else {
82-
c("--no-manual", "--as-cran")
83-
}
84-
print(args)
85-
rcmdcheck::rcmdcheck(args = args, error_on = "warning", check_dir = "check")
86-
shell: Rscript {0}
87-
88-
- name: Upload check results
89-
if: failure()
90-
uses: actions/upload-artifact@main
91-
with:
92-
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
93-
path: check
47+
- uses: r-lib/actions/check-r-package@v1

.github/workflows/pkgdown.yaml

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on:
24
push:
3-
branches:
4-
- main
5-
- master
5+
branches: [main, master]
6+
release:
7+
types: [published]
8+
workflow_dispatch:
69

710
name: pkgdown
811

912
jobs:
1013
pkgdown:
11-
runs-on: macOS-latest
14+
runs-on: ubuntu-latest
1215
env:
1316
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1417
steps:
1518
- uses: actions/checkout@v2
1619

17-
- uses: r-lib/actions/setup-r@v1
18-
1920
- uses: r-lib/actions/setup-pandoc@v1
2021

21-
- name: Query dependencies
22-
run: |
23-
install.packages('remotes')
24-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
25-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
26-
shell: Rscript {0}
27-
28-
- name: Cache R packages
29-
uses: actions/cache@v2
22+
- uses: r-lib/actions/setup-r@v1
3023
with:
31-
path: ${{ env.R_LIBS_USER }}
32-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
33-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
34-
35-
- name: Install dependencies
36-
run: |
37-
remotes::install_deps(dependencies = TRUE)
38-
remotes::install_github("ThinkR-open/thinkrtemplate", upgrade = "never")
39-
install.packages("pkgdown", type = "binary")
40-
shell: Rscript {0}
24+
use-public-rspm: true
4125

42-
- name: Install package
43-
run: R CMD INSTALL .
26+
- uses: r-lib/actions/setup-r-dependencies@v1
27+
with:
28+
extra-packages: pkgdown
29+
needs: website
4430

4531
- name: Deploy package
4632
run: |
47-
git config --local user.email "[email protected]"
48-
git config --local user.name "GitHub Actions"
33+
git config --local user.name "$GITHUB_ACTOR"
34+
git config --local user.email "[email protected]"
35+
Rscript -e 'install.packages("remotes");remotes::install_github("ThinkR-open/thinkrtemplate", upgrade = "never")'
4936
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'

.github/workflows/test-coverage.yaml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,29 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on:
24
push:
3-
branches:
4-
- main
5-
- master
5+
branches: [main, master]
66
pull_request:
7-
branches:
8-
- main
9-
- master
7+
branches: [main, master]
108

119
name: test-coverage
1210

1311
jobs:
1412
test-coverage:
15-
runs-on: macOS-latest
13+
runs-on: ubuntu-latest
1614
env:
1715
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16+
1817
steps:
1918
- uses: actions/checkout@v2
2019

2120
- uses: r-lib/actions/setup-r@v1
22-
23-
- uses: r-lib/actions/setup-pandoc@v1
24-
25-
- name: Query dependencies
26-
run: |
27-
install.packages('remotes')
28-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
29-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
30-
shell: Rscript {0}
31-
32-
- name: Cache R packages
33-
uses: actions/cache@v2
3421
with:
35-
path: ${{ env.R_LIBS_USER }}
36-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
37-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
22+
use-public-rspm: true
3823

39-
- name: Install dependencies
40-
run: |
41-
install.packages(c("remotes"))
42-
remotes::install_deps(dependencies = TRUE)
43-
remotes::install_cran("covr")
44-
shell: Rscript {0}
24+
- uses: r-lib/actions/setup-r-dependencies@v1
25+
with:
26+
extra-packages: covr
4527

4628
- name: Test coverage
4729
run: covr::codecov()

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: gitdown
22
Title: Turn Your Git Commit Messages into a HTML Book
3-
Version: 0.1.3.9000
3+
Version: 0.1.4
44
Authors@R:
55
c(person(given = "Sébastien",
66
family = "Rochette",

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# gitdown (development version)
1+
# gitdown 0.1.4
2+
3+
* Allow tests to start a day and finish the following one
24

35
# gitdown 0.1.3
46

tests/testthat/test-get_info_files.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ files <- list.files(repo_pkg, recursive = TRUE)
66
infos <- get_info(files[grep("example", files)], repo = repo_pkg)
77
infos_not_in_repo <- get_info(files[grep("my_mean", files)], repo = repo_pkg)
88
today <- as.character(Sys.Date())
9+
# if check started one day and finishes the other day
10+
tomorrow <- as.character(Sys.Date() + 1)
911

1012
test_that("get_info works", {
1113
expect_true(infos$in_repository)
1214
expect_equal(infos$file, "example.txt")
13-
expect_equal(as.character(as.Date(infos$first_modif)), setNames(today, "first"))
14-
expect_equal(as.character(as.Date(infos$last_modif)), setNames(today, "last"))
15+
expect_true(as.character(as.Date(infos$first_modif)) %in%
16+
c(setNames(today, "first"), setNames(tomorrow, "first")))
17+
expect_true(as.character(as.Date(infos$last_modif)) %in%
18+
c(setNames(today, "last"), setNames(tomorrow, "first")))
1519

1620
expect_false(infos_not_in_repo$in_repository)
1721
expect_equal(infos_not_in_repo$file, "R/my_mean.R")
1822
expect_true(is.na(infos_not_in_repo$first_modif))
19-
expect_equal(as.character(as.Date(infos_not_in_repo$last_modif)), setNames(today, "last"))
23+
expect_true(as.character(as.Date(infos_not_in_repo$last_modif)) %in%
24+
c(setNames(today, "last"), setNames(tomorrow, "first")))
2025
})
2126

2227
# get_last_modif ----

0 commit comments

Comments
 (0)