Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
^\.Rproj\.user$
^data-raw$
^\.devcontainer$
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"packages": "clang,clang-format,clang-tidy,cmake,doxygen,g++,gcc,libxt6,libxtst6,make,ninja-build"
},
"ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
"packages": "dplyr,devtools,ggplot2,jsonlite,methods,mockery,Rcpp,RcppEigen,scales,snowfall,TMB,tibble,tidyr,usethis",
"packages": "dplyr,devtools,ggplot2,jsonlite,methods,mockery,Rcpp,RcppEigen,scales,snowfall,spelling,TMB,tibble,tidyr,usethis",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need Rcpp, RcppEigen, and TMB in this repository?

"installSystemRequirements": true
},
// option to run rstudio. you can type rserver into the command line to
Expand Down
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
41 changes: 41 additions & 0 deletions .github/workflows/call-allcontributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Runs allcontributors::add_contributors() to add, or update, an alphabetized
# list of contributors to the README.md file and open a new PR with those
# changes.
name: Collect contributors

on:
push:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to run this on every push or at some other interval like monthly?

workflow_dispatch:

jobs:
run-r-script:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup R
uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
gh
allcontributors
- name: Collect contributor data
run: Rscript -e 'allcontributors::add_contributors(files = c("README.md"))'
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore: Updates contributors"
branch: update-contributors
base: main
title: "Update contributors"
body: "This PR updates the contributors list."
labels: "auto-update"
add-paths: |
README.md
14 changes: 14 additions & 0 deletions .github/workflows/call-build-pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Checks that the pkgdown site builds for a repository, assuming that one
# already exists, but it does not actually deploy it. See
# call-update-pkgdown.yml for that.
name: call-build-pkgdown

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
call-workflow:
uses: nmfs-ost/ghactions4r/.github/workflows/build-pkgdown.yml@main
16 changes: 16 additions & 0 deletions .github/workflows/call-doc-and-style-r.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Runs devtools::document() and styler::style_active_package(), then opens a
# pull request to the branch that had changes in the push that triggered the
# workflow.
name: call-doc-and-style-r

on:
push:
branches:
- main
workflow_dispatch:

jobs:
call-workflow:
uses: nmfs-ost/ghactions4r/.github/workflows/doc-and-style-r.yml@main
secrets:
PAT: ${{ secrets.PAT }}
42 changes: 42 additions & 0 deletions .github/workflows/call-pr-checklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Adds a comment to a newly opened PR letting reviewers know what should be
# included in their review.
name: Add a comment with reviewer checklist when PR opened

on:
pull_request:
types: [opened]

jobs:
pr-checklist:
runs-on: ubuntu-latest
name: pr-checklist
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 'Comment PR'
uses: actions/github-script@v0.3.0
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var msg = `# Instructions for code reviewer

Hello reviewer, thanks for taking the time to review this PR!

- Please use this checklist during your review, checking off items that you have verified are complete, but feel free to skip over items that are not relevant!
- See the [GitHub documentation for how to comment on a PR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/commenting-on-a-pull-request) to indicate where you have questions or changes are needed before approving the PR.
- Please use conventions in the [guidelines for conventional commit messages](https://www.conventionalcommits.org/) for both commit messages and comments.
- PR reviews are a great way to learn so feel free to share your tips and tricks. However, when suggesting changes to the PR that are optional please include \`nit:\` (for nitpicking) as the comment type. For example, \`nit:\` I prefer using a \`data.frame()\` instead of a \`matrix\` because ...
- Engage with the developer when they respond to comments and check off additional boxes as they become complete so the PR can be merged in when all the tasks are fulfilled. Make it clear when the PR is approved by selecting the approved status, and potentially by commenting on the PR with something like \`This PR is now ready to be merged, no additional changes are needed\`.

## Checklist

- [ ] The PR is requested to be merged into the appropriate branch (typically dev).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall having a dev branch in this repo.

Suggested change
- [ ] The PR is requested to be merged into the appropriate branch (typically dev).
- [ ] The PR is requested to be merged into the appropriate branch (typically main).

- [ ] The code is well-designed.
- [ ] The functionality is good for the users of the code.
- [ ] Code coverage remains high, indicating the new code is tested.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have code coverage in this repository?

- [ ] The code is commented and the comments are clear, useful, and mostly explain why instead of what.
- [ ] Code is appropriately documented.
`
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
github.issues.createComment({ issue_number, owner, repo, body: msg });
17 changes: 17 additions & 0 deletions .github/workflows/call-r-cmd-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Runs R CMD CHECK on the package.
name: call-r-cmd-check

on:
push:
workflow_dispatch:

# no permissions are needed by the default github token for this workflow to
# run, so don't pass any.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
permissions: {}

jobs:
call-workflow:
uses: nmfs-ost/ghactions4r/.github/workflows/r-cmd-check.yml@main
with:
gha_timeout_minutes: 60
15 changes: 15 additions & 0 deletions .github/workflows/call-spell-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Runs devtools::spell_check().
name: call-spell-check

on:
pull_request:
branches:
- main
push:
branches:
- main
Comment on lines +5 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think will lead to two workflows on the same code so I recommend removing lines 8--10.

workflow_dispatch:

jobs:
call-workflow:
uses: nmfs-ost/ghactions4r/.github/workflows/spell-check.yml@main
17 changes: 17 additions & 0 deletions .github/workflows/call-update-data-r.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Update data files in /data whenever changes are made to files in /data-raw.
# This workflow automatically commits changes directly to the working branch.
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is brilliant! I do not understand though why we are calling another file within this repository rather than just using the other file?

name: call-update-data-r

on:
push:
paths:
- 'data-raw/**'
workflow_dispatch:

jobs:
call-workflow:
uses: NOAA-FIMS/ecosystemdata/.github/workflows/update-data-r.yml@add-gha-checks
secrets:
PAT: ${{ secrets.PAT }}
with:
commit-directly: true
11 changes: 11 additions & 0 deletions .github/workflows/call-update-pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Updates the exiting pkgdown site for a repository by deploying the changes
# made to the pkgdown site to a branch called gh-pages.
name: call-update-pkgdown

on:
push:
branches: [main]

jobs:
call-workflow:
uses: nmfs-ost/ghactions4r/.github/workflows/update-pkgdown.yml@main
26 changes: 26 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Greetings

on: [pull_request_target, issues]

jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: >
Thank you for contributing to {ecosystemdata} and opening your first issue
here! We are happy to have your contributions. We encourage you to
introduce yourself to the community on the [introduction thread in
our Discussions](https://github.com/orgs/NOAA-FIMS/discussions/801).
pr-message: >
Thank you for contributing to {ecosystemdata} and opening your first PR
here! We are happy to have your contributions. Please ensure that the
PR is made to the dev branch and let us know if you need any help!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PR is made to the dev branch and let us know if you need any help!
PR is made to the main branch and let us know if you need any help!

Right now, we are using the main branch for this repo rather than a dev branch.

Also, we encourage you to introduce yourself to the community on the
[introduction thread in our
Discussions](https://github.com/orgs/NOAA-FIMS/discussions/801).
22 changes: 22 additions & 0 deletions .github/workflows/test-download-artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test-download-artifact
on:
workflow_run:
workflows: ["call-r-cmd-check"]
types:
- completed
branches:
- add-gha-checks
workflow_dispatch:

permissions:
contents: read
actions: read

jobs:
test-simple-model:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

steps:
- name: Checkout test repo (this repo)
uses: actions/checkout@v4
106 changes: 106 additions & 0 deletions .github/workflows/update-data-r.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Update /data when files in /data-raw are changed
# This workflow runs R code to regenerate data in /data when files in /data-raw are changed.
# Once the update is complete, the changes are committed.
# If 'commit-directly' is set to false (the default), a pull request will be opened
# to the branch where the workflow was triggered. The PR will contain the commit with updated data.
# If 'commit-directly' is set to true, changes are pushed directly to the triggering branch.
# Note that the job will fail if force pushing is required.
on:
workflow_call:
secrets:
PAT:
required: false
inputs:
commit-directly:
required: false
type: boolean
default: false

# Give the fewest permissions possible. content and pull-requests are necessary.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
permissions:
contents: write
pull-requests: write

# Cancel runs happening simultaneously on the same branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: update data

jobs:
update-data-r:
name: update R data from /data-raw
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.PAT }}
steps:
- name: setup env using GITHUB_TOKEN, if no pat
if: env.GITHUB_PAT == ''
run: echo "GITHUB_PAT=${{ secrets.GITHUB_TOKEN}}" >> "$GITHUB_ENV"

- name: checkout, make changes and submit as pr on new branch
if: inputs.commit-directly == false
uses: actions/checkout@v4

- name: checkout, make changes directly
if: inputs.commit-directly == true
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

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

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
devtools

- name: Run R code to update files in /data
run: |
devtools::install()
r_scripts <- list.files("data-raw", pattern = "\\.R$", full.names = TRUE)
if (length(r_scripts) > 0) {
for (script in r_scripts) {
system(paste("Rscript ", shQuote(script)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused 😕 why you would use a system call to run Rscript instead of just sourcing the function within R here?

}
} else {
message("No R scripts found in /data-raw.")
}
shell: Rscript {0}

- name: commit if using commit directly
if: inputs.commit-directly == true
uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: 'update data from /data-raw'

- name: specify base branch
id: specify-base
if: ${{ inputs.commit-directly == false }}
run: |
if [ -n ${{ github.head_ref }} ]; then
echo "base=${{github.head_ref}}" >> "$GITHUB_OUTPUT"
elif [ -n ${{ github.ref_name }} ]; then
echo "base=${{github.ref_name}}" >> "$GITHUB_OUTPUT"
else
echo "both github.head_ref and github.ref_name do not exist" >&2
exit 1
fi

- name: Create Pull Request
if: ${{inputs.commit-directly == false}}
uses: peter-evans/create-pull-request@v7
with:
commit-message: 'update R data from /data-raw'
token: ${{ env.GITHUB_PAT }}
branch: update-data-${{ github.ref_name }}
base: ${{ steps.specify-base.outputs.base }}
title: 'update R data'
body: |
Auto-generated by [update-data-r.yml][1]

[1]: https://github.com/NOAA-FIMS/ecosystemdata/tree/main/.github/workflows/update-data-r.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ po/*~
# RStudio Connect folder
rsconnect/
.Rproj.user
docs
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Config/testthat/edition: 3
Depends:
R (>= 3.5)
LazyData: true
Language: en-US
2 changes: 1 addition & 1 deletion R/get_functional_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ utils::globalVariables(c("V1", "V2"))
#'
#' @description
#' Functional group names are useful for the column names of output data from
#' an EeW model, and thus, this function is a way to get them automatically
#' an EwE model, and thus, this function is a way to get them automatically
#' from the EwE output. The functional group names come from the basic
#' estimates file.
#'
Expand Down
Loading
Loading