Skip to content

Commit

Permalink
Updated pkgdown GH action to run all examples (#106)
Browse files Browse the repository at this point in the history
* Test pkgdown in grass shell

* Add check/restore original grass session if present in initGRASS example
  • Loading branch information
stevenpawley authored Jan 19, 2025
1 parent 1f2fbf7 commit cec2fbf
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GRASS_INSTALLATION: /usr/lib/grass83
GRASS_INSTALLATION: /usr/lib/grass78
permissions:
contents: write
steps:
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y grass-dev libgdal-dev libudunits2-dev libharfbuzz-dev libfribidi-dev
sudo apt-get install -y grass libgdal-dev libudunits2-dev libharfbuzz-dev libfribidi-dev
- uses: r-lib/actions/setup-r-dependencies@v2
with:
Expand All @@ -48,12 +48,9 @@ jobs:
unzip /tmp/nc_basic_spm_grass7.zip -d /tmp/grassdb
rm /tmp/nc_basic_spm_grass7.zip
- name: Build site
- name: Build pkgdown site
run: |
gisBase <- system2("grass", "--config path", stdout = TRUE)
rgrass::initGRASS(gisBase = gisBase, gisDbase = "/tmp/grassdb", location = "nc_basic_spm_grass7", mapset = "PERMANENT")
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, run_dont_run = TRUE)
shell: Rscript {0}
grass /tmp/grassdb/nc_basic_spm_grass7/PERMANENT --exec sh -c "R -e 'pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, run_dont_run = TRUE)'"
- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
Expand Down
18 changes: 18 additions & 0 deletions R/initGRASS.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@
#' plot(r, col = terrain.colors(50))
#' }
#'
#' # Check for existing GRASS session running
#' if (run) {
#' loc_existing <- try(gmeta())
#' }
#'
#' if (run) {
#' # Initialize a temporary GRASS project using the example data
#' loc <- initGRASS(
Expand Down Expand Up @@ -142,6 +147,19 @@
#' u1 <- read_RAST(c("elev", "slope", "aspect"), return_format = "terra")
#' plot(u1[["elev"]], col = terrain.colors(50))
#' }
#'
#' # Restore the original GRASS session
#' if (run) {
#' if (!inherits(loc, "try-error")) {
#' loc <- initGRASS(
#' gisBase = GRASS_INSTALLATION,
#' gisDbase = loc_existing$GISDBASE,
#' location = loc_existing$LOCATION_NAME,
#' mapset = loc_existing$MAPSET,
#' override = TRUE
#' )
#' }
#' }
initGRASS <- function(
gisBase = NULL, home, SG, gisDbase, addon_base, location,
mapset, override = FALSE, use_g.dirseps.exe = TRUE, pid,
Expand Down
18 changes: 18 additions & 0 deletions man/initGRASS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cec2fbf

Please sign in to comment.