Skip to content
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

Style and roxygen workflow improvements #216

Merged
merged 8 commits into from
Feb 23, 2024
Merged
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
5 changes: 5 additions & 0 deletions .github/workflows/build-check-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ jobs:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
path: ${{ github.event.repository.name }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
# When fetch-depth is set to 1 (default), and if additional commits are added
# to the branch between this step and the 'Set TESTING_DEPTH' step, git might fail
# referencing ${{ github.event.after }} commit
# because it's not the latest commit fetched by this step.
fetch-depth: 0

- name: Checkout repo 🛎
uses: actions/checkout@v4
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/roxygen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ jobs:
echo "Regenerating man pages via auto-update"
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A man/ DESCRIPTION
git commit -m "Roxygen Man Pages Auto Update"
git config pull.rebase false
BRANCH_NAME="${{ steps.branch-name.outputs.head_ref_branch }}"
git pull origin ${BRANCH_NAME}
git pull origin ${BRANCH_NAME} || true
git add -A man/ DESCRIPTION
git commit -m "[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update"
git push -v origin HEAD:${BRANCH_NAME} || \
(echo "⚠️ Could not push to ${BRANCH_NAME} on $(git remote -v show -n origin | grep Push)" && \
AUTO_UPDATE=failed)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spelling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
if: github.event_name == 'push'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update WORDLIST"
commit_message: "[skip ci] Update WORDLIST"
file_pattern: "${{ steps.file-pattern.outputs.file-pattern }}"
commit_user_name: github-actions
commit_user_email: >-
Expand Down
34 changes: 27 additions & 7 deletions .github/workflows/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
- main
workflow_dispatch:
workflow_call:
secrets:
REPO_GITHUB_TOKEN:
description: |
Github token with write access to the repo
required: false
inputs:
auto-update:
description: If R code style is not up-to-date, styling will automatically be applied and restyled files will be automatically committed o the branch.
Expand Down Expand Up @@ -42,17 +47,31 @@ jobs:
image: ghcr.io/insightsengineering/rstudio:latest

steps:
- name: Checkout Code 🛎
uses: actions/checkout@v4
with:
path: ${{ github.event.repository.name }}
fetch-depth: 0
- name: Setup token 🔑
id: github-token
run: |
if [ "${{ secrets.REPO_GITHUB_TOKEN }}" == "" ]; then
echo "REPO_GITHUB_TOKEN is empty. Substituting it with GITHUB_TOKEN."
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
else
echo "Using REPO_GITHUB_TOKEN."
echo "token=${{ secrets.REPO_GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Get branch names 🌿
if: inputs.auto-update
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout Code 🛎
uses: actions/checkout@v4
with:
path: ${{ github.event.repository.name }}
fetch-depth: 0
token: ${{ steps.github-token.outputs.token }}
ref: ${{ steps.branch-name.outputs.head_ref_branch }}

- name: Install styler 👚
run: |
install.packages("styler", repos = "https://cloud.r-project.org")
Expand Down Expand Up @@ -119,9 +138,10 @@ jobs:
run: |
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config pull.rebase false
git pull origin ${{ steps.branch-name.outputs.head_ref_branch }} || true
git add ${{ steps.problem-files.outputs.unstyled-files }}
git commit -m 'Restyle files'
git pull origin ${{ steps.branch-name.outputs.head_ref_branch }}
git commit -m '[skip style] [skip vbump] Restyle files'
git push -v origin HEAD:${{ steps.branch-name.outputs.head_ref_branch }} || \
echo "⚠️ Could not push to ${BRANCH_NAME} on $(git remote -v show -n origin | grep Push)"
shell: bash
Expand Down
Loading