Skip to content

Commit

Permalink
feat(update-renv): Add wf to update renv.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusSkytte committed Feb 19, 2024
1 parent 9e70dec commit 3c63436
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/update-renv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
workflow_call:
inputs:
cache_version:
type: string
default: '1'
run:
type: boolean
default: true
branch_name:
type: string
required: true

jobs:
lint:
name: 🛠️ Store dependency versions
if: ${{ inputs.run }}
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:
cache-version: ${{ inputs.cache_version }}
extra-packages: any::renv

- name: Update the renv.lock file
run: renv::snapshot(prompt = FALSE)
shell: Rscript {0}

- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git switch ${{ inputs.branch_name }}
git add man/\* NAMESPACE DESCRIPTION
git commit -m "chore: update renv.lock" || echo "No changes to commit"
git push
16 changes: 16 additions & 0 deletions .github/workflows/workflow-dispatcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,19 @@ jobs:
concurrency:
group: pkgdown-${{ needs.trigger.outputs.branch_name }}
cancel-in-progress: true

update-renv:
needs: trigger
uses: ./.github/workflows/update-renv.yaml
with:
cache_version: ${{ needs.trigger.outputs.cache_version }}
run: ${{ !contains(inputs.skip, 'update-renv') && (
inputs.event_name == 'workflow_dispatch' || (
needs.trigger.outputs.main_branch_affected == 'true' && (
needs.trigger.outputs.R_files_changed == 'true' ||
needs.trigger.outputs.test_files_changed == 'true' ||
needs.trigger.outputs.description_changed == 'true'))) }}
branch_name: ${{ needs.trigger.outputs.branch_name }}
secrets: inherit
concurrency:
group: push-${{ needs.trigger.outputs.branch_name }}
17 changes: 15 additions & 2 deletions workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ If any issues are found, the workflow will give an error.

## code-coverage.yaml
#### Trigger
Pushes or pull requests to the main branch if there are changes to any file in the `R/` or `tests/` folders.
Pushes or pull requests to the main branch if there are changes to the `DESCRIPTION`, or any file in the `R/` or
`tests/` folders.

#### Function
Determine the degree of [code coverage](https://en.wikipedia.org/wiki/Code_coverage) in your code base.
Expand Down Expand Up @@ -121,7 +122,7 @@ Changes to `README.Rmd`.
Knits `README.md` from `README.Rmd`.

#### Outcome
If this generates changes to `README.md`, it it will commit the updated README to the repository.
If this generates changes to `README.md`, it will commit the updated README to the repository.


## spell-checker.yaml
Expand All @@ -138,3 +139,15 @@ Click on the workflow and look for the "Run Spelling Check test" tab to see the

#### Exit status
If any spelling mistakes are found, the workflow will give an error.


## update-renv.yaml
#### Trigger
Pushes or pull requests to the main branch if there are changes to the `DESCRIPTION`, or any file in the `R/` or
`tests/` folders.

#### Function
Runs `renv::snapshot()` on the code base and commits results.

#### Outcome
The function will update the `renv.lock` file of the repository match the testing environment.

0 comments on commit 3c63436

Please sign in to comment.