Skip to content

Commit

Permalink
Merge pull request #261 from grunwaldlab/update-ci
Browse files Browse the repository at this point in the history
[chore] Update Continuous Integration
  • Loading branch information
zkamvar authored May 16, 2024
2 parents 9e732b2 + f891338 commit aa90f4f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 45 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:

name: R-CMD-check

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand All @@ -34,7 +36,7 @@ jobs:
TINYTEX_INSTALLER: TinyTex

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -44,14 +46,7 @@ jobs:
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-tinytex@v2
# - name: Install LaTeX packages
# run: |
# tlmgr install colortbl
# tlmgr install mathtools
# tlmgr install preprint
# tlmgr install natbib

- uses: r-lib/actions/setup-r-dependencies@v2
with:
Expand All @@ -61,3 +56,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
49 changes: 23 additions & 26 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
# 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
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: macOS-latest
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v3
- uses: r-lib/actions/setup-r@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
install.packages("pkgdown")
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}
use-public-rspm: true

- name: Install package
run: R CMD INSTALL .
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Deploy package
- name: Build site
run: pkgdown::deploy_to_branch(new_process = FALSE, run_dont_run = TRUE)
shell: Rscript {0}
25 changes: 18 additions & 7 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,54 @@ on:

name: test-coverage

permissions: read-all

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

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- 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, local::.
needs: check
extra-packages: any::covr, any::xml2
needs: coverage

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

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: 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
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 1 addition & 1 deletion tests/testthat/test-import.R
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ test_that("diploid missing data is handled correctly", {
file1 <- tempfile()
genind2genalex(nancycats, file1, quiet = TRUE)
nan <- read.genalex(file1, genclone = FALSE)
expect_identical(summary(nancycats, verbose = FALSE), summary(nan, verbose = FALSE))
expect_equal(summary(nancycats, verbose = FALSE), summary(nan, verbose = FALSE))
})

test_that("sequence data is handled correctly", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ test_that("pair.ia can plot p-values", {
expect_is(p1, "ggplot")
expect_is(p2, "ggplot")
# The previous plot is not the same as the current plot
expect_failure(expect_identical(p1$data, p2$data))
expect_failure(expect_equal(dim(p1$data), dim(p2$data)))
})

context("diversity_ci plots")
Expand Down
7 changes: 5 additions & 2 deletions tests/testthat/test-round-robin.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ test_that("correction is properly applied in rraf", {

# sum_to_one argument augments does what it says
monc_sum2one <- vapply(monc_sto, sum, numeric(1))
# If the sum to one works, then we should have leftover tolerance that is
# greater than zero but less than one.
tol <- sum(monc_vec - monc_sum2one)
expect_lt(tol, 1)
expect_gt(tol, 0)
expect_equal(sum(monc_sum2one), nLoc(monpop))
expect_true(all(monc_vec >= monc_sum2one))

# The default is 1/n
expect_equivalent(SER(monc), 1/nInd(monpop))
expect_true(identical(SER(monc)[[1]], SED(monc)[[1]]))
Expand Down

0 comments on commit aa90f4f

Please sign in to comment.