Skip to content

Commit

Permalink
feat: add additional args to yaml files
Browse files Browse the repository at this point in the history
- update the following YAML files to support additional arguments on
  Windows, macOS, and Ubuntu: .github/workflows/build-pkgdown.yml,
  .github/workflows/r-cmd-check.yml, and
  .github/workflows/update-pkgdown.yml
- allow additional arguments to be specified after checking out the repo
  and before setting up R
- add a helper function validate_additional_args() to validate
  additional arguments for R functions
- add a helper function add_args() to include platform-specific
  additional arguments in a YAML file
- add additional_args to use_r_cmd_check(), use_update_pkgdown(), and
  use_build_pkgdown() to pass additional arguments to YAML files (e.g.,
  call_*.yml)
- add unit and integration tests to verify the new feature
- update the WORDLIST to pass the spell check
- import the cli package and use its functions to signal errors with a cli
  formatted message
  • Loading branch information
Bai-Li-NOAA committed Nov 22, 2024
1 parent d1ca9b5 commit 29b7717
Show file tree
Hide file tree
Showing 20 changed files with 1,357 additions and 748 deletions.
97 changes: 61 additions & 36 deletions .github/workflows/build-pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,61 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_call:

name: build-pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
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: build pkgdown
run: |
Rscript -e 'pkgdown::build_site()'
- name: save pkgdown output
uses: actions/upload-artifact@v4
with:
name: pkgdown-site
path: docs/

# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_call:
inputs:
additional_args_windows:
required: false
type: string
default: ""
additional_args_macos:
required: false
type: string
default: ""
additional_args_ubuntu:
required: false
type: string
default: ""

name: build-pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- name: run additional args on windows
if: matrix.config.os == 'windows-latest'
run: ${{ inputs.additional_args_windows }}

- name: run additional args on macOS
if: matrix.config.os == 'macOS-latest'
run: ${{ inputs.additional_args_macos }}

- name: run additional args on ubuntu
if: matrix.config.os == 'ubuntu-latest'
run: ${{ inputs.additional_args_ubuntu }}

- 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: build pkgdown
run: |
Rscript -e 'pkgdown::build_site()'
- name: save pkgdown output
uses: actions/upload-artifact@v4
with:
name: pkgdown-site
path: docs/

15 changes: 15 additions & 0 deletions .github/workflows/call-build-pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Checks that the pkgdown site builds for a repository.
# this assumes pkgdown is already set up.
name: call-build-pkgdown
# on specifies the build triggers. See more info at https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
# this workflow runs on pushes to main or master or any time a new tag is pushed
# it also runs everytime a pull request to main or master is opened.
push:
branches: [main, master]
tags: ['*']
pull_request:
branches: [main, master]
jobs:
call-workflow:
uses: nmfs-fish-tools/ghactions4r/.github/workflows/build-pkgdown.yml@main
34 changes: 17 additions & 17 deletions .github/workflows/call-r-cmd-check.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Run r cmd check
on:
workflow_dispatch:
push:
paths-ignore:
- '.github/workflows/call**'
pull_request:
paths-ignore:
- '.github/workflows/call**'
schedule:
# This should run the default branch weekly on sunday
- cron: '0 0 * * 0'
name: call-r-cmd-check

jobs:
call-workflow:
uses: nmfs-fish-tools/ghactions4r/.github/workflows/r-cmd-check.yml@main
# Run r cmd check
on:
workflow_dispatch:
push:
paths-ignore:
- '.github/workflows/call**'
pull_request:
paths-ignore:
- '.github/workflows/call**'
schedule:
# This should run the default branch weekly on sunday
- cron: '0 0 * * 0'
name: call-r-cmd-check

jobs:
call-workflow:
uses: nmfs-fish-tools/ghactions4r/.github/workflows/r-cmd-check.yml@main
26 changes: 13 additions & 13 deletions .github/workflows/call-update-pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# updates exiting pkgdown site for a repository
# deploys to a branch gh-pages
name: call-update-pkgdown
# on specifies the build triggers. See more info at https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
# this workflow runs on pushes to main or master or any time a new tag is pushed
workflow_dispatch:
push:
branches: [main, master]
tags: ['*']
jobs:
call-workflow:
uses: nmfs-fish-tools/ghactions4r/.github/workflows/update-pkgdown.yml@main
# updates exiting pkgdown site for a repository
# deploys to a branch gh-pages
name: call-update-pkgdown
# on specifies the build triggers. See more info at https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
# this workflow runs on pushes to main or master or any time a new tag is pushed
workflow_dispatch:
push:
branches: [main, master]
tags: ['*']
jobs:
call-workflow:
uses: nmfs-fish-tools/ghactions4r/.github/workflows/update-pkgdown.yml@main
Loading

0 comments on commit 29b7717

Please sign in to comment.