-
Notifications
You must be signed in to change notification settings - Fork 0
Add GHA checks #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add GHA checks #11
Changes from all commits
34afdae
965fe0b
42371b9
75dc489
ba41f5d
a0ecfa5
a552327
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,7 @@ | |
| ^\.Rproj\.user$ | ||
| ^data-raw$ | ||
| ^\.devcontainer$ | ||
| ^\.github$ | ||
| ^_pkgdown\.yml$ | ||
| ^docs$ | ||
| ^pkgdown$ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.html |
| 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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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 |
| 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 }} |
| 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). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 code is well-designed. | ||||||
| - [ ] The functionality is good for the users of the code. | ||||||
| - [ ] Code coverage remains high, indicating the new code is tested. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }); | ||||||
| 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 |
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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 |
| 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! | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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). | ||||||
| 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 |
| 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))) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,3 +48,4 @@ po/*~ | |
| # RStudio Connect folder | ||
| rsconnect/ | ||
| .Rproj.user | ||
| docs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ Config/testthat/edition: 3 | |
| Depends: | ||
| R (>= 3.5) | ||
| LazyData: true | ||
| Language: en-US | ||
There was a problem hiding this comment.
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?