From 3143ec46d8d0c506e2becbcb1652c7d4f15e3df6 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Mon, 31 Mar 2025 18:04:42 -0700 Subject: [PATCH 1/4] ci: replace auto-ci with commands * style, lint, document, preview-docs all in pr-commands and can now be triggered with PR comments * update PR template to remind user to run these commands --- .github/pull_request_template.md | 6 + .github/workflows/doc-preview.yaml | 65 ----------- .github/workflows/document.yaml | 58 ---------- .github/workflows/lint.yaml | 39 ------- .github/workflows/pr-commands.yaml | 173 +++++++++++++++++++++++++++++ .github/workflows/style.yml | 87 --------------- 6 files changed, 179 insertions(+), 249 deletions(-) delete mode 100644 .github/workflows/doc-preview.yaml delete mode 100644 .github/workflows/document.yaml delete mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/pr-commands.yaml delete mode 100644 .github/workflows/style.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c8841c356..2443c9255 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -14,6 +14,12 @@ Please: (backwards-incompatible changes to the documented interface) are noted. Collect the changes under the next release number (e.g. if you are on 1.7.2, then write your changes under the 1.8 heading). +- [ ] Styling, linting, and documentation checks. Make a PR comment with: + - `/document` to check the package documentation and fix any issues. + - `/style` to check the style and fix any issues. + - `/lint` to check the linting. + - `/preview-docs` to preview the docs. + - See Actions GitHub tab to track progress of these commands. - See [DEVELOPMENT.md](DEVELOPMENT.md) for more information on the development process. diff --git a/.github/workflows/doc-preview.yaml b/.github/workflows/doc-preview.yaml deleted file mode 100644 index 068184225..000000000 --- a/.github/workflows/doc-preview.yaml +++ /dev/null @@ -1,65 +0,0 @@ -on: - issue_comment: - types: [created] - -name: doc-preview.yaml - -permissions: read-all - -jobs: - preview: - if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/preview-docs') }} - - runs-on: ubuntu-latest - permissions: - # Needed to write a comment on the PR - pull-requests: write - # Needed to read the PR branch - contents: read - steps: - - uses: actions/checkout@v4 - with: - # Checkout the PR branch - ref: refs/pull/${{ github.event.issue.number }}/head - - - 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 site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) - shell: Rscript {0} - - - name: Deploy to Netlify - uses: nwtgck/actions-netlify@v3.0 - with: - # Standard config - github-token: ${{ secrets.GITHUB_TOKEN }} - deploy-message: "Deploy from GitHub Actions" - # 'docs/' is the default directory for pkgdown::build_site() - # we add 'dev' because _pkgdown.yml has 'development: mode: devel' - publish-dir: './docs/dev' - # Development deploys only - production-deploy: false - # Enable pull request comment (default) - enable-pull-request-comment: true - # Overwrite the pull request comment with updated link (default) - overwrites-pull-request-comment: true - # Don't deploy to GitHub - enable-github-deployment: false - # Don't update the status of the commit - enable-commit-status: false - # Don't comment on the commit - enable-commit-comment: false - env: - # Netlify credentials (currently from Dmitry's account) - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - timeout-minutes: 1 diff --git a/.github/workflows/document.yaml b/.github/workflows/document.yaml deleted file mode 100644 index bfc3c43da..000000000 --- a/.github/workflows/document.yaml +++ /dev/null @@ -1,58 +0,0 @@ -# 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 -# -# Modifications: -# - devtools::build_readme() -# - workflow_dispatch added to allow manual triggering of the workflow -# - trigger branches changed -# - API key secrets.DELPHI_GITHUB_ACTIONS_EPIDATA_API_KEY -on: - push: - paths: ["R/**", "README.Rmd"] - workflow_dispatch: - -name: Document - -jobs: - document: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - DELPHI_EPIDATA_KEY: ${{ secrets.DELPHI_GITHUB_ACTIONS_EPIDATA_API_KEY }} - steps: - - name: Checkout repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - name: Install dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: | - any::devtools - any::roxygen2 - needs: | - devtools - roxygen2 - - - name: Document - run: roxygen2::roxygenise() - shell: Rscript {0} - - - name: Build README.md from README.Rmd - run: Rscript -e 'if (file.exists("README.Rmd")) devtools::build_readme()' - - - name: Commit and push changes - run: | - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - git add README.md - git add man/\* NAMESPACE DESCRIPTION - git commit -m "docs: document (GHA)" || echo "No changes to commit" - git pull --rebase - git push origin diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 21d030c94..000000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# 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 -# -# Modifications: -# * workflow_dispatch added to allow manual triggering of the workflow -# * trigger branches changed -# * API key secrets.DELPHI_GITHUB_ACTIONS_EPIDATA_API_KEY -on: - push: - branches: [main, dev] - pull_request: - branches: [main, dev] - workflow_dispatch: - -name: Lint - -jobs: - lint: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - DELPHI_EPIDATA_KEY: ${{ secrets.DELPHI_GITHUB_ACTIONS_EPIDATA_API_KEY }} - steps: - - uses: actions/checkout@v3 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::lintr, local::. - needs: lint - - - name: Lint - run: lintr::lint_package() - shell: Rscript {0} - env: - LINTR_ERROR_ON_LINT: true diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 000000000..1f8103608 --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,173 @@ +# 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 +# Modifications: +# - Allow more roles to trigger each PR command +# - Document builds README.md from README.Rmd with devtools::build_readme() +# - Include a lint command (from https://github.com/r-lib/actions/tree/v2/examples#lint-workflow) +# - Include a doc-preview command (uses Netlify to preview the docs) +on: + issue_comment: + types: [created] + +name: pr-commands.yaml + +permissions: read-all + +jobs: + document: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} + name: document + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: Build README.md from README.Rmd + run: Rscript -e 'if (file.exists("README.Rmd")) devtools::build_readme()' + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m 'Document' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + style: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} + name: style + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + + - name: Install dependencies + run: install.packages("styler") + shell: Rscript {0} + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add \*.R + git commit -m 'Style' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + lint: + runs-on: ubuntu-latest + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/lint') }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::lintr, local::. + needs: lint + + - name: Lint + run: lintr::lint_package() + shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true + + preview: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/preview-docs') }} + + runs-on: ubuntu-latest + permissions: + # Needed to write a comment on the PR + pull-requests: write + # Needed to read the PR branch + contents: read + steps: + - uses: actions/checkout@v4 + with: + # Checkout the PR branch + ref: refs/pull/${{ github.event.issue.number }}/head + + - 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 site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v3.0 + with: + # Standard config + github-token: ${{ secrets.GITHUB_TOKEN }} + deploy-message: "Deploy from GitHub Actions" + # 'docs/' is the default directory for pkgdown::build_site() + # we add 'dev' because _pkgdown.yml has 'development: mode: devel' + publish-dir: './docs/dev' + # Development deploys only + production-deploy: false + # Enable pull request comment (default) + enable-pull-request-comment: true + # Overwrite the pull request comment with updated link (default) + overwrites-pull-request-comment: true + # Don't deploy to GitHub + enable-github-deployment: false + # Don't update the status of the commit + enable-commit-status: false + # Don't comment on the commit + enable-commit-comment: false + env: + # Netlify credentials (currently from Dmitry's account) + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + timeout-minutes: 1 diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml deleted file mode 100644 index 396200a5f..000000000 --- a/.github/workflows/style.yml +++ /dev/null @@ -1,87 +0,0 @@ -# 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 -# -# Modifications: -# * workflow_dispatch added to allow manual triggering of the workflow -# * trigger branches changed -# * API key secrets.DELPHI_GITHUB_ACTIONS_EPIDATA_API_KEY -on: - push: - paths: - [ - "**.[rR]", - "**.[qrR]md", - "**.[rR]markdown", - "**.[rR]nw", - "**.[rR]profile", - ] - workflow_dispatch: - -name: Style - -jobs: - style: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - DELPHI_EPIDATA_KEY: ${{ secrets.DELPHI_GITHUB_ACTIONS_EPIDATA_API_KEY }} - steps: - - name: Checkout repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - name: Install dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::styler, any::roxygen2 - needs: styler - - - name: Enable styler cache - run: styler::cache_activate() - shell: Rscript {0} - - - name: Determine cache location - id: styler-location - run: | - cat( - "location=", - styler::cache_info(format = "tabular")$location, - "\n", - file = Sys.getenv("GITHUB_OUTPUT"), - append = TRUE, - sep = "" - ) - shell: Rscript {0} - - - name: Cache styler - uses: actions/cache@v3 - with: - path: ${{ steps.styler-location.outputs.location }} - key: ${{ runner.os }}-styler-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-styler- - ${{ runner.os }}- - - - name: Style - run: styler::style_pkg() - shell: Rscript {0} - - - name: Commit and push changes - run: | - if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \ - | egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$')) - then - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - git commit ${FILES_TO_COMMIT[*]} -m "style: styler (GHA)" - git pull --rebase - git push origin - else - echo "No changes to commit." - fi From 1326dad44649d63c01bfb807b85941076b6e2cd4 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Thu, 3 Apr 2025 14:59:28 -0700 Subject: [PATCH 2/4] ci: bring back auto-linting --- .github/workflows/lint.yaml | 35 ++++++++++++++++++++++++++++++ .github/workflows/pr-commands.yaml | 24 -------------------- 2 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 000000000..78eae465f --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,35 @@ +# 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, dev] + pull_request: + branches: [main, dev] + workflow_dispatch: + +name: lint.yaml + +permissions: read-all + +jobs: + lint: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::lintr, local::. + needs: lint + + - name: Lint + run: lintr::lint_package() + shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index 1f8103608..6cf91e878 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -3,7 +3,6 @@ # Modifications: # - Allow more roles to trigger each PR command # - Document builds README.md from README.Rmd with devtools::build_readme() -# - Include a lint command (from https://github.com/r-lib/actions/tree/v2/examples#lint-workflow) # - Include a doc-preview command (uses Netlify to preview the docs) on: issue_comment: @@ -92,29 +91,6 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} - lint: - runs-on: ubuntu-latest - if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/lint') }} - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::lintr, local::. - needs: lint - - - name: Lint - run: lintr::lint_package() - shell: Rscript {0} - env: - LINTR_ERROR_ON_LINT: true - preview: if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/preview-docs') }} From bb87f9c53a008a61dee39b8cbb577ebe21955669 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Thu, 3 Apr 2025 15:00:17 -0700 Subject: [PATCH 3/4] template --- .github/pull_request_template.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 2443c9255..04d173d94 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -17,7 +17,6 @@ Please: - [ ] Styling, linting, and documentation checks. Make a PR comment with: - `/document` to check the package documentation and fix any issues. - `/style` to check the style and fix any issues. - - `/lint` to check the linting. - `/preview-docs` to preview the docs. - See Actions GitHub tab to track progress of these commands. - See [DEVELOPMENT.md](DEVELOPMENT.md) for more information on the development From 1594226ae513816e104138d30dee9fc7f57ef471 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Thu, 3 Apr 2025 15:00:33 -0700 Subject: [PATCH 4/4] a --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 04d173d94..93b00f150 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -14,7 +14,7 @@ Please: (backwards-incompatible changes to the documented interface) are noted. Collect the changes under the next release number (e.g. if you are on 1.7.2, then write your changes under the 1.8 heading). -- [ ] Styling, linting, and documentation checks. Make a PR comment with: +- [ ] Styling and documentation checks. Make a PR comment with: - `/document` to check the package documentation and fix any issues. - `/style` to check the style and fix any issues. - `/preview-docs` to preview the docs.