From 469d621352db34fe2a6b9ae49a92030e5bee41f2 Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 15:56:11 +0000 Subject: [PATCH 01/12] add GHA checks --- .Rbuildignore | 1 + .github/.gitignore | 1 + .github/workflows/call-allcontributors.yml | 12 ++++++++++++ .github/workflows/call-build-pkgdown.yml | 16 ++++++++++++++++ .github/workflows/call-doc-and-style-r.yml | 17 +++++++++++++++++ .github/workflows/call-pr-checklist.yml | 12 ++++++++++++ .github/workflows/call-r-cmd-check.yml | 12 ++++++++++++ .github/workflows/call-spell-check.yml | 16 ++++++++++++++++ .github/workflows/call-update-pkgdown.yml | 12 ++++++++++++ 9 files changed, 99 insertions(+) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/call-allcontributors.yml create mode 100644 .github/workflows/call-build-pkgdown.yml create mode 100644 .github/workflows/call-doc-and-style-r.yml create mode 100644 .github/workflows/call-pr-checklist.yml create mode 100644 .github/workflows/call-r-cmd-check.yml create mode 100644 .github/workflows/call-spell-check.yml create mode 100644 .github/workflows/call-update-pkgdown.yml diff --git a/.Rbuildignore b/.Rbuildignore index 5ca465b..f5da234 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^\.Rproj\.user$ ^data-raw$ ^\.devcontainer$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/call-allcontributors.yml b/.github/workflows/call-allcontributors.yml new file mode 100644 index 0000000..7091a5e --- /dev/null +++ b/.github/workflows/call-allcontributors.yml @@ -0,0 +1,12 @@ +# 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: call-r-cmd-check + +on: + push: + workflow_dispatch: + +jobs: + call-workflow: + uses: NOAA-FIMS/FIMS/.github/workflows/call-allcontributors.yml@main \ No newline at end of file diff --git a/.github/workflows/call-build-pkgdown.yml b/.github/workflows/call-build-pkgdown.yml new file mode 100644 index 0000000..5339ed1 --- /dev/null +++ b/.github/workflows/call-build-pkgdown.yml @@ -0,0 +1,16 @@ +# 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: + # TODO: remove push trigger once tests are passing + push: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + call-workflow: + uses: nmfs-fish-tools/ghactions4r/.github/workflows/build-pkgdown.yml@main \ No newline at end of file diff --git a/.github/workflows/call-doc-and-style-r.yml b/.github/workflows/call-doc-and-style-r.yml new file mode 100644 index 0000000..1d4b18a --- /dev/null +++ b/.github/workflows/call-doc-and-style-r.yml @@ -0,0 +1,17 @@ +# 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: + # TODO: uncomment following lines once tests are passing + # branches: + # - main + workflow_dispatch: + +jobs: + call-workflow: + uses: nmfs-fish-tools/ghactions4r/.github/workflows/doc-and-style-r.yml@main + secrets: + PAT: ${{ secrets.PAT }} \ No newline at end of file diff --git a/.github/workflows/call-pr-checklist.yml b/.github/workflows/call-pr-checklist.yml new file mode 100644 index 0000000..007d011 --- /dev/null +++ b/.github/workflows/call-pr-checklist.yml @@ -0,0 +1,12 @@ +# 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: call-r-cmd-check + +on: + push: + workflow_dispatch: + +jobs: + call-workflow: + uses: NOAA-FIMS/FIMS/.github/workflows/pr-checklist.yml@main \ No newline at end of file diff --git a/.github/workflows/call-r-cmd-check.yml b/.github/workflows/call-r-cmd-check.yml new file mode 100644 index 0000000..9512459 --- /dev/null +++ b/.github/workflows/call-r-cmd-check.yml @@ -0,0 +1,12 @@ +# Runs R CMD CHECK on the package. +name: call-r-cmd-check + +on: + push: + workflow_dispatch: + +jobs: + call-workflow: + uses: nmfs-fish-tools/ghactions4r/.github/workflows/r-cmd-check.yml@main + with: + gha_timeout_minutes: 60 \ No newline at end of file diff --git a/.github/workflows/call-spell-check.yml b/.github/workflows/call-spell-check.yml new file mode 100644 index 0000000..90963b7 --- /dev/null +++ b/.github/workflows/call-spell-check.yml @@ -0,0 +1,16 @@ +# Runs devtools::spell_check(). +name: call-spell-check + +on: + pull_request: + branches: + - main + push: + # TODO: uncomment following lines once tests are passing + # branches: + # - main + workflow_dispatch: + +jobs: + call-workflow: + uses: nmfs-fish-tools/ghactions4r/.github/workflows/spell-check.yml@main \ No newline at end of file diff --git a/.github/workflows/call-update-pkgdown.yml b/.github/workflows/call-update-pkgdown.yml new file mode 100644 index 0000000..770e241 --- /dev/null +++ b/.github/workflows/call-update-pkgdown.yml @@ -0,0 +1,12 @@ +# 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: + # TODO: uncomment following lines once tests are passing + # branches: [main] + +jobs: + call-workflow: + uses: nmfs-fish-tools/ghactions4r/.github/workflows/update-pkgdown.yml@main \ No newline at end of file From 35d54722e8b6345d25f22562dd874b7da9b0e5c9 Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 15:58:51 +0000 Subject: [PATCH 02/12] fix GitHub organization name --- .github/workflows/call-build-pkgdown.yml | 2 +- .github/workflows/call-doc-and-style-r.yml | 2 +- .github/workflows/call-r-cmd-check.yml | 2 +- .github/workflows/call-spell-check.yml | 2 +- .github/workflows/call-update-pkgdown.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/call-build-pkgdown.yml b/.github/workflows/call-build-pkgdown.yml index 5339ed1..7b429f8 100644 --- a/.github/workflows/call-build-pkgdown.yml +++ b/.github/workflows/call-build-pkgdown.yml @@ -13,4 +13,4 @@ on: jobs: call-workflow: - uses: nmfs-fish-tools/ghactions4r/.github/workflows/build-pkgdown.yml@main \ No newline at end of file + uses: nmfs-ost/ghactions4r/.github/workflows/build-pkgdown.yml@main \ No newline at end of file diff --git a/.github/workflows/call-doc-and-style-r.yml b/.github/workflows/call-doc-and-style-r.yml index 1d4b18a..0bebcc1 100644 --- a/.github/workflows/call-doc-and-style-r.yml +++ b/.github/workflows/call-doc-and-style-r.yml @@ -12,6 +12,6 @@ on: jobs: call-workflow: - uses: nmfs-fish-tools/ghactions4r/.github/workflows/doc-and-style-r.yml@main + uses: nmfs-ost/ghactions4r/.github/workflows/doc-and-style-r.yml@main secrets: PAT: ${{ secrets.PAT }} \ No newline at end of file diff --git a/.github/workflows/call-r-cmd-check.yml b/.github/workflows/call-r-cmd-check.yml index 9512459..93d9994 100644 --- a/.github/workflows/call-r-cmd-check.yml +++ b/.github/workflows/call-r-cmd-check.yml @@ -7,6 +7,6 @@ on: jobs: call-workflow: - uses: nmfs-fish-tools/ghactions4r/.github/workflows/r-cmd-check.yml@main + uses: nmfs-ost/ghactions4r/.github/workflows/r-cmd-check.yml@main with: gha_timeout_minutes: 60 \ No newline at end of file diff --git a/.github/workflows/call-spell-check.yml b/.github/workflows/call-spell-check.yml index 90963b7..23fa524 100644 --- a/.github/workflows/call-spell-check.yml +++ b/.github/workflows/call-spell-check.yml @@ -13,4 +13,4 @@ on: jobs: call-workflow: - uses: nmfs-fish-tools/ghactions4r/.github/workflows/spell-check.yml@main \ No newline at end of file + uses: nmfs-ost/ghactions4r/.github/workflows/spell-check.yml@main \ No newline at end of file diff --git a/.github/workflows/call-update-pkgdown.yml b/.github/workflows/call-update-pkgdown.yml index 770e241..8c19fa1 100644 --- a/.github/workflows/call-update-pkgdown.yml +++ b/.github/workflows/call-update-pkgdown.yml @@ -9,4 +9,4 @@ on: jobs: call-workflow: - uses: nmfs-fish-tools/ghactions4r/.github/workflows/update-pkgdown.yml@main \ No newline at end of file + uses: nmfs-ost/ghactions4r/.github/workflows/update-pkgdown.yml@main \ No newline at end of file From 36aa9ff9335ac3f0dc442d8e75dc44702ac88290 Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:12:59 +0000 Subject: [PATCH 03/12] fix typos --- .Rbuildignore | 3 +++ .devcontainer/devcontainer.json | 2 +- .gitignore | 1 + DESCRIPTION | 1 + R/get_functional_groups.R | 2 +- R/load_.R | 2 +- _pkgdown.yml | 4 ++++ inst/WORDLIST | 14 ++++++++++++++ 8 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 _pkgdown.yml create mode 100644 inst/WORDLIST diff --git a/.Rbuildignore b/.Rbuildignore index f5da234..95b3786 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,6 @@ ^data-raw$ ^\.devcontainer$ ^\.github$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aa53181..d2886ca 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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", "installSystemRequirements": true }, // option to run rstudio. you can type rserver into the command line to diff --git a/.gitignore b/.gitignore index 7cc8b6a..b27cb91 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ po/*~ # RStudio Connect folder rsconnect/ .Rproj.user +docs diff --git a/DESCRIPTION b/DESCRIPTION index 0790c43..e7c0ff7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,3 +31,4 @@ Config/testthat/edition: 3 Depends: R (>= 3.5) LazyData: true +Language: en-US diff --git a/R/get_functional_groups.R b/R/get_functional_groups.R index c289961..20fe9b1 100644 --- a/R/get_functional_groups.R +++ b/R/get_functional_groups.R @@ -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. #' diff --git a/R/load_.R b/R/load_.R index cd97355..99ceecf 100644 --- a/R/load_.R +++ b/R/load_.R @@ -7,7 +7,7 @@ utils::globalVariables(c("timestep", "group", "fleet", "month", "type", "year")) #' #' @param file_path The path to the CSV file containing the EwE output data. #' @param model_years A vector of years corresponding to the model years. TODO: this can be removed -#' after havgina a utility function to extract model years globally from annual data +#' after having a utility function to extract model years globally from annual data #' @param functional_groups A vector of names of the functional groups in the model. #' #' @export diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..3796f23 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,4 @@ +url: https://NOAA-FIMS.github.io/ecosystemdata +template: + bootstrap: 5 + diff --git a/inst/WORDLIST b/inst/WORDLIST new file mode 100644 index 0000000..1623825 --- /dev/null +++ b/inst/WORDLIST @@ -0,0 +1,14 @@ +Brito +Buchheister +Chagaris +Cieri +Ecopath +Ecosim +EwE +Schueller +bookdown +fmars +nwatlantic +testthat +tibble +usethis \ No newline at end of file From 0c4e04d6ebb3236db51bb819d5aec6497203380c Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:21:31 +0000 Subject: [PATCH 04/12] add helper code to installgit LFS --- tests/testthat/test-helper.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/testthat/test-helper.R diff --git a/tests/testthat/test-helper.R b/tests/testthat/test-helper.R new file mode 100644 index 0000000..6a8a922 --- /dev/null +++ b/tests/testthat/test-helper.R @@ -0,0 +1,16 @@ +# Path to the basic_estimates.csv file in the package +base_run_path <- fs::path( + system.file("extdata", package = "ecosystemdata"), + "ewe_nwatlantic", "base_run", "basic_estimates.csv" +) +# Scan the file to read its contents +temp <- scan(base_run_path, what = "", sep = "\n", quiet = TRUE) + +# Check if the second element of temp contains "oid" as part of the string. +# If so, run the system command to install git-lfs and pull the data +if (grepl("oid", temp[2])) { + system( + "sudo apt update; sudo apt install git-lfs; git lfs install; git lfs pull", + intern = TRUE + ) +} From f29680d338905466499fd0bf6ebd1b985532d050 Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:27:05 +0000 Subject: [PATCH 05/12] rename test setup file --- tests/testthat/{test-helper.R => setup.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/testthat/{test-helper.R => setup.R} (100%) diff --git a/tests/testthat/test-helper.R b/tests/testthat/setup.R similarity index 100% rename from tests/testthat/test-helper.R rename to tests/testthat/setup.R From bf0508e777bb9e5d634abd510decc95c6f203fcc Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:02:17 +0000 Subject: [PATCH 06/12] add OS specific code to install LFS --- .github/workflows/call-allcontributors.yml | 38 ++++++++++++++++-- .github/workflows/call-pr-checklist.yml | 46 ++++++++++++++++++---- .github/workflows/call-r-cmd-check.yml | 14 +++++++ .github/workflows/greetings.yml | 26 ++++++++++++ man/ewe_nwatlantic_base.Rd | 4 +- man/get_functional_groups.Rd | 2 +- man/load_csv_ewe.Rd | 2 +- tests/testthat/setup.R | 24 +++++++++-- 8 files changed, 136 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/greetings.yml diff --git a/.github/workflows/call-allcontributors.yml b/.github/workflows/call-allcontributors.yml index 7091a5e..a70f5b9 100644 --- a/.github/workflows/call-allcontributors.yml +++ b/.github/workflows/call-allcontributors.yml @@ -1,12 +1,42 @@ # 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: call-r-cmd-check +name: Collect contributors on: - push: + schedule: + - cron: '0 8 * * 1' workflow_dispatch: jobs: - call-workflow: - uses: NOAA-FIMS/FIMS/.github/workflows/call-allcontributors.yml@main \ No newline at end of file + 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"), alphabetical = TRUE)' + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "chore: Updates contributors" + branch: update-contributors + base: dev + title: "Update contributors" + body: "This PR updates the contributors list." + labels: "auto-update" + add-paths: | + README.md \ No newline at end of file diff --git a/.github/workflows/call-pr-checklist.yml b/.github/workflows/call-pr-checklist.yml index 007d011..042edbb 100644 --- a/.github/workflows/call-pr-checklist.yml +++ b/.github/workflows/call-pr-checklist.yml @@ -1,12 +1,42 @@ -# 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: call-r-cmd-check +# 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: - push: - workflow_dispatch: + pull_request: + types: [opened] jobs: - call-workflow: - uses: NOAA-FIMS/FIMS/.github/workflows/pr-checklist.yml@main \ No newline at end of file + 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). + - [ ] 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. + - [ ] The code is commented and the comments are clear, useful, and mostly explain why instead of what. + - [ ] Code is appropriately documented (doxygen and roxygen). + ` + const { issue: { number: issue_number }, repo: { owner, repo } } = context; + github.issues.createComment({ issue_number, owner, repo, body: msg }); \ No newline at end of file diff --git a/.github/workflows/call-r-cmd-check.yml b/.github/workflows/call-r-cmd-check.yml index 93d9994..f196ac9 100644 --- a/.github/workflows/call-r-cmd-check.yml +++ b/.github/workflows/call-r-cmd-check.yml @@ -6,6 +6,20 @@ on: workflow_dispatch: jobs: + # Install git LFS and pull the data + install-git-lfs: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + lfs: true + - name: Install git-lfs + run: | + sudo apt-get update + sudo apt-get install git-lfs + git lfs install + git lfs pull call-workflow: uses: nmfs-ost/ghactions4r/.github/workflows/r-cmd-check.yml@main with: diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml new file mode 100644 index 0000000..6040e55 --- /dev/null +++ b/.github/workflows/greetings.yml @@ -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! + 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). \ No newline at end of file diff --git a/man/ewe_nwatlantic_base.Rd b/man/ewe_nwatlantic_base.Rd index f742aec..a950410 100644 --- a/man/ewe_nwatlantic_base.Rd +++ b/man/ewe_nwatlantic_base.Rd @@ -9,7 +9,7 @@ \subsection{\verb{EWE NW Atlantic}}{ A tibble with 35640 rows and the following -8 columns: +10 columns: \describe{ \item{file_name}{The path to the file name, note that the path could be a relative path. This column is helpful for understanding which EWE model @@ -28,7 +28,7 @@ row pertains to. } } -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 35640 rows and 8 columns. +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 35640 rows and 10 columns. } \source{ \url{https://www.github.com/nmfs-ost/} diff --git a/man/get_functional_groups.Rd b/man/get_functional_groups.Rd index e82e8bd..65c5b3e 100644 --- a/man/get_functional_groups.Rd +++ b/man/get_functional_groups.Rd @@ -27,7 +27,7 @@ multiple groups. } \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. } diff --git a/man/load_csv_ewe.Rd b/man/load_csv_ewe.Rd index 67cf739..5cff9bd 100644 --- a/man/load_csv_ewe.Rd +++ b/man/load_csv_ewe.Rd @@ -10,7 +10,7 @@ load_csv_ewe(file_path, model_years, functional_groups) \item{file_path}{The path to the CSV file containing the EwE output data.} \item{model_years}{A vector of years corresponding to the model years. TODO: this can be removed -after havgina a utility function to extract model years globally from annual data} +after having a utility function to extract model years globally from annual data} \item{functional_groups}{A vector of names of the functional groups in the model.} } diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 6a8a922..7d326eb 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -8,9 +8,25 @@ temp <- scan(base_run_path, what = "", sep = "\n", quiet = TRUE) # Check if the second element of temp contains "oid" as part of the string. # If so, run the system command to install git-lfs and pull the data +# Code for Linux system if (grepl("oid", temp[2])) { - system( - "sudo apt update; sudo apt install git-lfs; git lfs install; git lfs pull", - intern = TRUE - ) + # Check if the system is Linux + if (Sys.info()["sysname"] != "Linux") { + system( + "sudo apt update; sudo apt install git-lfs; git lfs install; git lfs pull", + intern = TRUE + ) + } + + # Check if the system is macOS + if (Sys.info()["sysname"] == "Darwin") { + system( + "brew install git-lfs; git lfs install; git lfs pull", + intern = TRUE + ) + } + + if (Sys.info()["sysname"] == "Windows") { + system("winget install -e --id GitHub.GitLFS; git lfs install; git lfs pull") + } } From 4bcc829627f60f4185dd7a13ea2ee3a11895c9fa Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:12:34 +0000 Subject: [PATCH 07/12] fix typos --- .github/workflows/call-allcontributors.yml | 6 +++-- .github/workflows/call-pr-checklist.yml | 4 ++- tests/testthat/setup.R | 29 ++++++---------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/call-allcontributors.yml b/.github/workflows/call-allcontributors.yml index a70f5b9..6fb1081 100644 --- a/.github/workflows/call-allcontributors.yml +++ b/.github/workflows/call-allcontributors.yml @@ -4,8 +4,10 @@ name: Collect contributors on: - schedule: - - cron: '0 8 * * 1' + # schedule: + # - cron: '0 8 * * 1' + # TODO: remove push trigger once tests are passing and uncomment schedule + push: workflow_dispatch: jobs: diff --git a/.github/workflows/call-pr-checklist.yml b/.github/workflows/call-pr-checklist.yml index 042edbb..929c1c1 100644 --- a/.github/workflows/call-pr-checklist.yml +++ b/.github/workflows/call-pr-checklist.yml @@ -3,6 +3,8 @@ name: Add a comment with reviewer checklist when PR opened on: + # TODO: remove push trigger once tests are passing + push: pull_request: types: [opened] @@ -36,7 +38,7 @@ jobs: - [ ] The functionality is good for the users of the code. - [ ] Code coverage remains high, indicating the new code is tested. - [ ] The code is commented and the comments are clear, useful, and mostly explain why instead of what. - - [ ] Code is appropriately documented (doxygen and roxygen). + - [ ] Code is appropriately documented. ` const { issue: { number: issue_number }, repo: { owner, repo } } = context; github.issues.createComment({ issue_number, owner, repo, body: msg }); \ No newline at end of file diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 7d326eb..acbb101 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -8,25 +8,12 @@ temp <- scan(base_run_path, what = "", sep = "\n", quiet = TRUE) # Check if the second element of temp contains "oid" as part of the string. # If so, run the system command to install git-lfs and pull the data -# Code for Linux system if (grepl("oid", temp[2])) { - # Check if the system is Linux - if (Sys.info()["sysname"] != "Linux") { - system( - "sudo apt update; sudo apt install git-lfs; git lfs install; git lfs pull", - intern = TRUE - ) - } - - # Check if the system is macOS - if (Sys.info()["sysname"] == "Darwin") { - system( - "brew install git-lfs; git lfs install; git lfs pull", - intern = TRUE - ) - } - - if (Sys.info()["sysname"] == "Windows") { - system("winget install -e --id GitHub.GitLFS; git lfs install; git lfs pull") - } -} + sysname <- Sys.info()[["sysname"]] + switch( + sysname, + "Linux" = system("sudo apt update; sudo apt install -y git-lfs; git lfs install; git lfs pull", intern = TRUE), + "Darwin" = system("brew install git-lfs; git lfs install; git lfs pull", intern = TRUE), + "Windows" = system("winget install -e --id GitHub.GitLFS; git lfs install; git lfs pull", intern = TRUE) + ) +} \ No newline at end of file From b14e4d1e0f67cd9c3850f6d95d87a5331e72bf5f Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:32:34 +0000 Subject: [PATCH 08/12] update setup.R --- tests/testthat/setup.R | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index acbb101..e0a98eb 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -9,11 +9,25 @@ temp <- scan(base_run_path, what = "", sep = "\n", quiet = TRUE) # Check if the second element of temp contains "oid" as part of the string. # If so, run the system command to install git-lfs and pull the data if (grepl("oid", temp[2])) { - sysname <- Sys.info()[["sysname"]] - switch( - sysname, - "Linux" = system("sudo apt update; sudo apt install -y git-lfs; git lfs install; git lfs pull", intern = TRUE), - "Darwin" = system("brew install git-lfs; git lfs install; git lfs pull", intern = TRUE), - "Windows" = system("winget install -e --id GitHub.GitLFS; git lfs install; git lfs pull", intern = TRUE) + # Check if git LFS is installed using the system command + git_lfs_installed <- system( + "git lfs version", + intern = TRUE, + ignore.stdout = TRUE, + ignore.stderr = TRUE ) + + if (length(git_lfs_installed) == 0) { + # If git LFS is not installed, install it + sysname <- Sys.info()[["sysname"]] + switch( + sysname, + "Linux" = system("sudo apt update; sudo apt install -y git-lfs; git lfs install", intern = TRUE), + "Darwin" = system("brew install git-lfs; git lfs install", intern = TRUE), + "Windows" = system("winget install -e --id GitHub.GitLFS; git lfs install", intern = TRUE) + ) + } else { + # If git LFS is installed, pull the data + system("git lfs pull", intern = TRUE) + } } \ No newline at end of file From 43a1aaab61a7ca1bdf639e1ba9ee9b5c7f5ca6d4 Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:54:45 +0000 Subject: [PATCH 09/12] update setup.R --- .github/workflows/call-r-cmd-check.yml | 3 --- tests/testthat/setup.R | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/call-r-cmd-check.yml b/.github/workflows/call-r-cmd-check.yml index f196ac9..ccd61f1 100644 --- a/.github/workflows/call-r-cmd-check.yml +++ b/.github/workflows/call-r-cmd-check.yml @@ -16,9 +16,6 @@ jobs: lfs: true - name: Install git-lfs run: | - sudo apt-get update - sudo apt-get install git-lfs - git lfs install git lfs pull call-workflow: uses: nmfs-ost/ghactions4r/.github/workflows/r-cmd-check.yml@main diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index e0a98eb..0dc824c 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -23,8 +23,8 @@ if (grepl("oid", temp[2])) { switch( sysname, "Linux" = system("sudo apt update; sudo apt install -y git-lfs; git lfs install", intern = TRUE), - "Darwin" = system("brew install git-lfs; git lfs install", intern = TRUE), - "Windows" = system("winget install -e --id GitHub.GitLFS; git lfs install", intern = TRUE) + "Darwin" = system("brew reinstall git-lfs; git lfs install", intern = TRUE), + "Windows" = system("curl -LO https://github.com/git-lfs/git-lfs/releases/download/v3.6.1/git-lfs-windows-v3.6.1.exe; /git-lfs-windows-v3.6.1.exe; git lfs install", intern = TRUE) ) } else { # If git LFS is installed, pull the data From 55bb3fa32d2015a794ca2e4b3531bd2cdcb8a039 Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:12:45 +0000 Subject: [PATCH 10/12] add R CMD Check and remove all contributors check --- .github/workflows/R-CMD-check.yaml | 54 ++++++++++++++++++++++ .github/workflows/call-allcontributors.yml | 44 ------------------ .github/workflows/call-r-cmd-check.yml | 23 --------- tests/testthat/setup.R | 33 ------------- 4 files changed, 54 insertions(+), 100 deletions(-) create mode 100644 .github/workflows/R-CMD-check.yaml delete mode 100644 .github/workflows/call-allcontributors.yml delete mode 100644 .github/workflows/call-r-cmd-check.yml delete mode 100644 tests/testthat/setup.R diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..5789a56 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,54 @@ +# 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: + +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 + with: + # This will install Git LFS and checkout the LFS objects during the checkout process. + lfs: true + + - 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 + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/call-allcontributors.yml b/.github/workflows/call-allcontributors.yml deleted file mode 100644 index 6fb1081..0000000 --- a/.github/workflows/call-allcontributors.yml +++ /dev/null @@ -1,44 +0,0 @@ -# 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: - # schedule: - # - cron: '0 8 * * 1' - # TODO: remove push trigger once tests are passing and uncomment schedule - push: - 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"), alphabetical = TRUE)' - - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 - with: - commit-message: "chore: Updates contributors" - branch: update-contributors - base: dev - title: "Update contributors" - body: "This PR updates the contributors list." - labels: "auto-update" - add-paths: | - README.md \ No newline at end of file diff --git a/.github/workflows/call-r-cmd-check.yml b/.github/workflows/call-r-cmd-check.yml deleted file mode 100644 index ccd61f1..0000000 --- a/.github/workflows/call-r-cmd-check.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Runs R CMD CHECK on the package. -name: call-r-cmd-check - -on: - push: - workflow_dispatch: - -jobs: - # Install git LFS and pull the data - install-git-lfs: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - lfs: true - - name: Install git-lfs - run: | - git lfs pull - call-workflow: - uses: nmfs-ost/ghactions4r/.github/workflows/r-cmd-check.yml@main - with: - gha_timeout_minutes: 60 \ No newline at end of file diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R deleted file mode 100644 index 0dc824c..0000000 --- a/tests/testthat/setup.R +++ /dev/null @@ -1,33 +0,0 @@ -# Path to the basic_estimates.csv file in the package -base_run_path <- fs::path( - system.file("extdata", package = "ecosystemdata"), - "ewe_nwatlantic", "base_run", "basic_estimates.csv" -) -# Scan the file to read its contents -temp <- scan(base_run_path, what = "", sep = "\n", quiet = TRUE) - -# Check if the second element of temp contains "oid" as part of the string. -# If so, run the system command to install git-lfs and pull the data -if (grepl("oid", temp[2])) { - # Check if git LFS is installed using the system command - git_lfs_installed <- system( - "git lfs version", - intern = TRUE, - ignore.stdout = TRUE, - ignore.stderr = TRUE - ) - - if (length(git_lfs_installed) == 0) { - # If git LFS is not installed, install it - sysname <- Sys.info()[["sysname"]] - switch( - sysname, - "Linux" = system("sudo apt update; sudo apt install -y git-lfs; git lfs install", intern = TRUE), - "Darwin" = system("brew reinstall git-lfs; git lfs install", intern = TRUE), - "Windows" = system("curl -LO https://github.com/git-lfs/git-lfs/releases/download/v3.6.1/git-lfs-windows-v3.6.1.exe; /git-lfs-windows-v3.6.1.exe; git lfs install", intern = TRUE) - ) - } else { - # If git LFS is installed, pull the data - system("git lfs pull", intern = TRUE) - } -} \ No newline at end of file From 37c6a3e98c2f19307dfc75b0a378e17115770129 Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:14:31 +0000 Subject: [PATCH 11/12] update r cmd check trigger --- .github/workflows/R-CMD-check.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 5789a56..99a91c6 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -2,7 +2,8 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: [main, master] + # Unncomment the following line once the tests are passing + # branches: [main] pull_request: name: R-CMD-check.yaml From aaf3e4e24d13578ca0d5395c1bb8cb4f8e703350 Mon Sep 17 00:00:00 2001 From: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:17:25 +0000 Subject: [PATCH 12/12] style and docs: run devtools::document() and styler::style_pkg() --- DESCRIPTION | 25 +++++++++++++------------ R/ewe_nwatlantic.R | 2 +- R/get_functional_groups.R | 4 ++-- R/use_template.R | 2 +- tests/testthat/test-load_model.R | 6 +++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e7c0ff7..ad50b08 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,18 +2,18 @@ Package: ecosystemdata Title: Ecosystem database of Ecopath with Ecosim and Atlantis models Version: 0.1.0 Authors@R: c( - person("Bai", "Li", email = "bai.li@noaa.gov", role = c("aut", "cre"), + person("Bai", "Li", , "bai.li@noaa.gov", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8249-1442")), - person(c("Kelli", "F."), "Johnson", email = "kelli.johnson@noaa.gov", - role = "aut", comment = c(ORCID = "0000-0002-5149-451X")) + person(c("Kelli", "F."), "Johnson", , "kelli.johnson@noaa.gov", role = "aut", + comment = c(ORCID = "0000-0002-5149-451X")) ) -Description: Ecosystem database of Ecopath with Ecosim and Atlantis models. - The package provides functions to access and manipulate the ecosystem output - files from the Ecopath with Ecosim and Atlantis models. +Description: Ecosystem database of Ecopath with Ecosim and Atlantis + models. The package provides functions to access and manipulate the + ecosystem output files from the Ecopath with Ecosim and Atlantis + models. License: GPL (>= 3) | file LICENSE -Encoding: UTF-8 -Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +Depends: + R (>= 3.5) Imports: cli, dplyr, @@ -28,7 +28,8 @@ Suggests: testthat (>= 3.0.0), usethis Config/testthat/edition: 3 -Depends: - R (>= 3.5) -LazyData: true +Encoding: UTF-8 Language: en-US +LazyData: true +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.2 diff --git a/R/ewe_nwatlantic.R b/R/ewe_nwatlantic.R index 99f564c..72ec57e 100644 --- a/R/ewe_nwatlantic.R +++ b/R/ewe_nwatlantic.R @@ -12,7 +12,7 @@ #' relative path. This column is helpful for understanding which EWE model #' and which run the data came from. #' } -#' \item{type}{The type refers to what data type this row is, e.g., landings, +#' \item{type}{The type refers to what data type this row is, e.g., landings, #' catch, biomass, weight, and mortality. #' } #' \item{year}{A four-digit integer specifying the year.} diff --git a/R/get_functional_groups.R b/R/get_functional_groups.R index 20fe9b1..a62326b 100644 --- a/R/get_functional_groups.R +++ b/R/get_functional_groups.R @@ -39,12 +39,12 @@ get_functional_groups <- function(file_path) { out_vector <- utils::read.table( text = as.character(temp[-1]), sep = "," - ) |> + ) |> # Extract non-NA rows from the first column dplyr::filter(!is.na(V1)) |> # Pull the names of the functional groups dplyr::pull(V2) - + # Return a tibble with the functional groups, species, and group names split_functional_groups(out_vector) } diff --git a/R/use_template.R b/R/use_template.R index c45f271..d8c3861 100644 --- a/R/use_template.R +++ b/R/use_template.R @@ -56,4 +56,4 @@ use_testthat_template <- function(name) { cli::cli_abort("{path} already exists.") } invisible(TRUE) -} \ No newline at end of file +} diff --git a/tests/testthat/test-load_model.R b/tests/testthat/test-load_model.R index 2adfa3c..8414a35 100644 --- a/tests/testthat/test-load_model.R +++ b/tests/testthat/test-load_model.R @@ -26,12 +26,12 @@ model_years <- 1985:2017 test_that("load_model() works with correct inputs", { ewe_model <- load_model( directory = base_run_dir, - functional_groups = functional_groups, + functional_groups = functional_groups, type = "ewe" ) - + expected_colnames <- c( - "file_name", "type", "year", "month", "functional_group", + "file_name", "type", "year", "month", "functional_group", "value", "species", "group", "fleet", "reference" ) #' @description Test that load_model() returns correct columns.