Skip to content

Commit

Permalink
update CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
kadyb authored Nov 6, 2024
1 parent 50bb8a7 commit 06cba3b
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 96 deletions.
63 changes: 26 additions & 37 deletions .github/workflows/lintr.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,34 @@
# source: https://github.com/r-lib/actions/blob/master/examples/lint.yaml

name: lintr

# 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: [ master ]
branches: [main, master]
pull_request:
branches: [ master ]
branches: [main, master]

name: lintr

permissions: read-all

jobs:
lintr:
runs-on: macOS-latest
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@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@v4
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: |
options("pkgType" = "binary")
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("lintr")
shell: Rscript {0}

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
- 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::lintr, local::.
needs: lint

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
64 changes: 33 additions & 31 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
# source: https://github.com/r-lib/actions/blob/master/examples/pkgdown.yaml

# 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: master
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

- 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}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Cache R packages
uses: actions/cache@v4
- uses: r-lib/actions/setup-r-dependencies@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: |
options("pkgType" = "binary")
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown")
shell: Rscript {0}
extra-packages: any::pkgdown, local::.
needs: website

- name: Install package
run: R CMD INSTALL .
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy package
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, examples = FALSE)'
- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
72 changes: 44 additions & 28 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,68 @@
# source: https://github.com/r-lib/actions/blob/master/examples/test-coverage.yaml

# test coverage is skipped for these functions:
# geonames_download, geodb_download, borders_download (too large file size)
# DEM_request, ortho_request (requests from GitHub are blocked)

name: test-coverage

# 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: [ master ]
branches: [main, master]
pull_request:
branches: [ master ]
branches: [main, master]

name: test-coverage

permissions: read-all

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

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-pandoc@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Query dependencies
- name: Test coverage
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")
skip_fun = c("geonames_download", "geodb_download", "borders_download",
"DEM_request", "ortho_request", "orto_request")
cov <- covr::package_coverage(
function_exclusions = skip_fun,
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v4
- uses: codecov/codecov-action@v4
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-
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Install dependencies
- name: Show testthat output
if: always()
run: |
options("pkgType" = "binary")
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
shell: Rscript {0}
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Test coverage
run: |
skip_fun = c("geonames_download", "geodb_download", "borders_download",
"DEM_request", "ortho_request", "orto_request")
covr::codecov(function_exclusions = skip_fun)
shell: Rscript {0}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package

0 comments on commit 06cba3b

Please sign in to comment.