-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
638 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
^chef\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^\.Rproj\.user$ | ||
^\.github$ | ||
^\.pre-commit-config\.yaml$ | ||
^_pkgdown\.yml$ | ||
^chef\.Rproj$ | ||
^docs$ | ||
^pkgdown$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
# | ||
# An example hook script to verify what is about to be committed. | ||
# Called by "git commit" with no arguments. The hook should | ||
# exit with non-zero status after issuing an appropriate message if | ||
# it wants to stop the commit. | ||
# | ||
# To enable this hook, rename this file to "pre-commit". | ||
|
||
export LOCAL_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
# Array of protected branches | ||
protected_branches=( | ||
"main" | ||
"stage" | ||
"dev" | ||
) | ||
|
||
|
||
|
||
|
||
for branch in "${protected_branches[@]}"; do | ||
if [[ "$LOCAL_BRANCH" == "$branch"* ]]; then | ||
echo "Pre-commit hook: Attempt to commit to a protected branch: ${LOCAL_BRANCH}" | ||
echo "" | ||
echo "Checkout a new feature/branchname and push from there." | ||
echo "Then go to github and create a pull request." | ||
exit 1 | ||
fi | ||
done | ||
|
||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# An example hook script to verify what is about to be pushed. Called by "git | ||
# push" after it has checked the remote status, but before anything has been | ||
# pushed. If this script exits with a non-zero status nothing will be pushed. | ||
# | ||
# This hook is called with the following parameters: | ||
# | ||
# $1 -- Name of the remote to which the push is being done | ||
# $2 -- URL to which the push is being done | ||
# | ||
# If pushing without using a named remote those arguments will be equal. | ||
# | ||
# Information about the commits which are being pushed is supplied as lines to | ||
# the standard input in the form: | ||
# | ||
# <local ref> <local oid> <remote ref> <remote oid> | ||
# | ||
# This sample shows how to prevent push of commits where the log message starts | ||
# with "WIP" (work in progress). | ||
|
||
remote="$1" | ||
url="$2" | ||
|
||
# Array of protected branches | ||
protected_branches=( | ||
"refs/heads/main/" | ||
"refs/heads/main" | ||
"refs/heads/stage/" | ||
"refs/heads/stage" | ||
"refs/heads/dev/" | ||
"refs/heads/dev" | ||
"refs/heads/testing/precommit" | ||
) | ||
|
||
while read local_ref local_sha remote_ref remote_sha; do | ||
for branch in "${protected_branches[@]}"; do | ||
if [[ "$remote_ref" == "$branch"* ]]; then | ||
echo "Pre-push hook: Attempt to commit to a protected branch: ${LOCAL_BRANCH}" | ||
echo "" | ||
echo "Checkout a new feature/branchname and push from there." | ||
echo "" | ||
echo "You can use the following commands to place the changes on a new branch:" | ||
echo "git reset --soft HEAD" | ||
echo "git checkout -b feature/branchname" | ||
echo "git add ." | ||
echo "git commit -m 'Your commit message'" | ||
echo "git push origin feature/branchname" | ||
echo "Then go to github and create a pull request." | ||
exit 1 | ||
exit 1 | ||
fi | ||
done | ||
done | ||
|
||
exit 0 | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
|
||
|
||
on: | ||
push: | ||
branches: [main, stage, dev] | ||
pull_request: | ||
branches: [main, stage, dev] | ||
workflow_dispatch: | ||
|
||
name: Check | ||
|
||
jobs: | ||
audit: | ||
name: Audit Dependencies π΅οΈββοΈ | ||
uses: insightsengineering/r.pkg.template/.github/workflows/audit.yaml@main | ||
|
||
licenses: | ||
name: License Check π | ||
uses: insightsengineering/r.pkg.template/.github/workflows/licenses.yaml@main | ||
|
||
check-reuse: | ||
name: RMD check π¦ | ||
uses: ./.github/workflows/R-CMD-check.yaml | ||
|
||
test: | ||
name: Test π§ͺ | ||
uses: ./.github/workflows/Test.yaml | ||
|
||
gitleaks: | ||
name: gitleaks π§ | ||
uses: insightsengineering/r.pkg.template/.github/workflows/gitleaks.yaml@main | ||
with: | ||
check-for-pii: true | ||
|
||
vbump: | ||
name: Version Bump π€π€ | ||
if: github.event_name == 'push' && github.ref != 'refs/heads/main' | ||
uses: insightsengineering/r.pkg.template/.github/workflows/version-bump.yaml@main | ||
secrets: | ||
REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# roxygen: | ||
# name: Roxygen π¦ | ||
# uses: ./.github/workflows/Roxygen.yaml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: PR cleanup | ||
|
||
on: | ||
pull_request: | ||
types: [closed, synchronize] | ||
|
||
jobs: | ||
delete_pr_artifacts: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: stefanluptak/delete-old-pr-artifacts@v1 | ||
with: | ||
workflow_filename: Check.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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: | ||
workflow_call: | ||
|
||
name: R-CMD-check | ||
|
||
# concurrency: | ||
# group: roxygen-${{ github.event.pull_request.number || github.ref }} | ||
# cancel-in-progress: true | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ${{ matrix.config.os }} | ||
|
||
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {os: ubuntu-latest, r: 'release'} | ||
# - {os: ubuntu-latest, r: 'oldrel-1'} | ||
# - {os: ubuntu-latest, r: 'oldrel-2'} | ||
# - {os: ubuntu-latest, r: 'oldrel-3'} | ||
# - {os: ubuntu-latest, r: 'oldrel-4'} | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
--- | ||
name: Roxygen π Ύ | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
# install-system-dependencies: | ||
# description: Check for and install system dependencies | ||
# required: false | ||
# default: false | ||
# type: boolean | ||
# enable-staged-dependencies-check: | ||
# description: Enable staged dependencies YAML check | ||
# required: false | ||
# default: false | ||
# type: boolean | ||
auto-update: | ||
description: If man pages are not up-to-date, they will be automatically updated and committed back to the branch. | ||
required: false | ||
default: false | ||
type: boolean | ||
# sd-direction: | ||
# description: The direction to use to install staged dependencies. Choose between 'upstream', 'downstream' and 'all' | ||
# required: false | ||
# type: string | ||
# default: upstream | ||
package-subdirectory: | ||
description: Subdirectory in the repository, where the R package is located. | ||
required: false | ||
type: string | ||
default: "." | ||
secrets: | ||
REPO_GITHUB_TOKEN: | ||
description: | | ||
Github token with read access to repositories, required for staged.dependencies installation | ||
required: false | ||
|
||
# concurrency: | ||
# group: roxygen-${{ github.event.pull_request.number || github.ref }} | ||
# cancel-in-progress: true | ||
|
||
jobs: | ||
roxygen: | ||
name: Manual pages check π | ||
runs-on: ubuntu-latest | ||
if: > | ||
!contains(github.event.commits[0].message, '[skip roxygen]') | ||
&& github.event.pull_request.draft == false | ||
container: | ||
image: ghcr.io/insightsengineering/rstudio:latest | ||
|
||
steps: | ||
- 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 πΏ | ||
id: branch-name | ||
uses: tj-actions/branch-names@v7 | ||
|
||
- name: Checkout repo (PR) π | ||
uses: actions/checkout@v4 | ||
if: github.event_name == 'pull_request' | ||
# with: | ||
# ref: ${{ steps.branch-name.outputs.head_ref_branch }} | ||
# path: ${{ github.event.repository.name }} | ||
# repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
# token: ${{ steps.github-token.outputs.token }} | ||
|
||
- name: Checkout repo π | ||
uses: actions/checkout@v4 | ||
if: github.event_name != 'pull_request' | ||
# with: | ||
# ref: ${{ steps.branch-name.outputs.head_ref_branch }} | ||
# path: ${{ github.event.repository.name }} | ||
|
||
- name: Setup R | ||
uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- name: Setup R dependencies | ||
uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::roxygen2 | ||
|
||
# - name: Restore SD cache π° | ||
# uses: actions/cache@v4 | ||
# with: | ||
# key: sd-${{ runner.os }}-${{ github.event.repository.name }} | ||
# path: ~/.staged.dependencies | ||
|
||
# - name: Run Staged dependencies π¦ | ||
# uses: insightsengineering/staged-dependencies-action@v1 | ||
# env: | ||
# GITHUB_PAT: ${{ steps.github-token.outputs.token }} | ||
# with: | ||
# path: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} | ||
# enable-check: ${{ inputs.enable-staged-dependencies-check }} | ||
# run-system-dependencies: ${{ inputs.install-system-dependencies }} | ||
# direction: ${{ inputs.sd-direction }} | ||
|
||
- name: Generate man pages π | ||
run: | | ||
logfile <- "roxygen_${{ github.event.repository.name }}.log" | ||
con <- file(logfile) | ||
sink(con, append = TRUE, split = TRUE) | ||
sink(con, append = TRUE, type = "message") | ||
roxygen2::roxygenize('.') | ||
sink() | ||
sink(type = "message") | ||
logs <- readLines(logfile) | ||
cat("πͺ΅ Log output of 'roxygen2::roxygenize()':\n") | ||
system2("cat", logfile) | ||
error_marker <- grep("Error:", logs) | ||
warnings_marker <- grep("Warning message", logs) | ||
if (length(warnings_marker) > 0) { | ||
cat("β One or more warnings were generated during the roxygen build:\n") | ||
cat(logs[warnings_marker[[1]]:length(logs)], sep = "\n") | ||
stop("Please π fix the warnings shown below this message π") | ||
} | ||
if (length(error_marker) > 0) { | ||
cat("β One or more errors were generated during the roxygen build:\n") | ||
cat(logs[error_marker[[1]]:length(logs)], sep = "\n") | ||
stop("Please π fix the errors shown below this message π") | ||
} | ||
shell: Rscript {0} | ||
working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} | ||
|
||
- name: Roxygen check π Ύ | ||
run: | | ||
AUTO_UPDATE=${{ inputs.auto-update }} | ||
if [[ -n `git status -s | grep -E "man|DESCRIPTION"` ]] | ||
then { | ||
ROXYGEN_VERSION="$(Rscript -e 'packageVersion("roxygen2")' | awk '{print $NF}')" | ||
echo "π Manuals are not up-to-date with roxygen comments!" | ||
echo "π The following differences were noted:" | ||
git diff man/* DESCRIPTION | ||
# Attempt to commit and push man-page updates | ||
if [ "${AUTO_UPDATE}" == "true" ] | ||
then { | ||
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 config pull.rebase false | ||
BRANCH_NAME="${{ steps.branch-name.outputs.head_ref_branch }}" | ||
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) | ||
} | ||
fi | ||
# If auto-update is disabled or is unsuccessful, let 'em know to fix manually | ||
if [ "${AUTO_UPDATE}" != "true" ] | ||
then { | ||
echo -e "\nπ» Please rerun the following command on your workstation and push your changes" | ||
echo "--------------------------------------------------------------------" | ||
echo "roxygen2::roxygenize('.')" | ||
echo "--------------------------------------------------------------------" | ||
echo "βΉ roxygen2 version that was used in this workflow: $ROXYGEN_VERSION" | ||
echo "π Please ensure that the 'RoxygenNote' field in the DESCRIPTION file matches this version" | ||
exit 1 | ||
} | ||
fi | ||
} else { | ||
echo "π Manuals are up-to-date with roxygen comments" | ||
} | ||
fi | ||
shell: bash | ||
working-directory: ${{ github.event.repository.name }}/${{ inputs.package-subdirectory }} |
Oops, something went wrong.