79170438

Date: 2024-11-08 14:37:54
Score: 1
Natty:
Report link

A solution was provided by @kadyb and Ezder. In order to make this work during github actions, a suitable source of geos and installation of sf from source will be required. This is taken care of by default for Mac and Windows, but some more work is needed for linux.

Within the: .github/worflows directory you will need to modify up to 2 files, one is used for building the pkgdown website, the other is for the tests.

the R-CMD-check.yaml will need to be edited to this:

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

name: R-CMD-check.yaml

permissions: read-all

jobs:
  R-CMD-check:
    runs-on: ${{ matrix.config.os }}

    name: ${{ matrix.config.os }} (${{ matrix.config.r }})

    strategy:
      fail-fast: false
      matrix:
        config:
          - {os: macos-latest,   r: 'release'}
          - {os: windows-latest, r: 'release'}
          - {os: ubuntu-latest,   r: 'devel', http-user-agent: 'release'}
          - {os: ubuntu-latest,   r: 'release'}
          - {os: ubuntu-latest,   r: 'oldrel-1'}

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      R_KEEP_PKG_SOURCE: yes

    steps:
      - uses: actions/checkout@v4

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

      - uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ matrix.config.r }}
          http-user-agent: ${{ matrix.config.http-user-agent }}
          use-public-rspm: true

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::rcmdcheck
          needs: check
          
      - name: Update GEOS
        if: runner.os == 'Linux'
        run: |
          sudo apt-get install software-properties-common
          sudo add-apt-repository ppa:ubuntugis/ppa
          sudo apt-get update
          sudo apt-get install libgeos-dev

      - name: Commpile sf from source
        if: runner.os == 'Linux'
        run: install.packages("sf", type = "source", repos = "https://cran.rstudio.com/")
        shell: Rscript {0}

      - uses: r-lib/actions/check-r-package@v2
        with:
          upload-snapshots: true
          build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

and the pkgdown.yaml which will allow the website to render also needs to be updated:

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

name: pkgdown.yaml

permissions: read-all

jobs:
  pkgdown:
    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-pandoc@v2

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

      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::pkgdown, local::.
          needs: website
          
      - name: Update GEOS
        if: runner.os == 'Linux'
        run: |
          sudo add-apt-repository ppa:ubuntugis/ppa
          sudo apt-get update
          sudo apt-get install libgeos-dev

      - name: Commpile sf from source
        if: runner.os == 'Linux'
        run: install.packages("sf", type = "source", repos = "https://cran.rstudio.com/")
        shell: Rscript {0}

      - name: Build site
        run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
        shell: Rscript {0}

      - name: Deploy to GitHub pages 🚀
        if: github.event_name != 'pull_request'
        uses: JamesIves/[email protected]
        with:
          clean: false
          branch: gh-pages
          folder: docs

What has happened with both is the addition of:

      - name: Update GEOS
        if: runner.os == 'Linux'
        run: |
          sudo add-apt-repository ppa:ubuntugis/ppa
          sudo apt-get update
          sudo apt-get install libgeos-dev

      - name: Commpile sf from source
        if: runner.os == 'Linux'
        run: install.packages("sf", type = "source", repos = "https://cran.rstudio.com/")
        shell: Rscript {0}

Which allows for a suitable GEOS installation and sf from source.

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @kadyb
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: steppe