-
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
0 parents
commit 17e6846
Showing
21 changed files
with
552 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
^dv.templates\.Rproj$ | ||
^\.Rproj\.user$ | ||
^.*\.Rproj$ | ||
^LICENSE\.md$ | ||
^LICENSE$ | ||
^\.github | ||
_pkgdown.yml | ||
workflows.md |
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,45 @@ | ||
--- | ||
name: Check 📦 | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
workflow_call: | ||
|
||
concurrency: | ||
group: check-test-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check-test: | ||
name: ${{ vars.CI_IMAGE }} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ${{ vars.CI_IMAGE }} | ||
|
||
steps: | ||
- name: Checkout project ⬇️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check 📦 | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
devtools::check(error_on="error", args=c("--no-tests")) | ||
shell: Rscript {0} | ||
|
||
- name: Test 🧪 | ||
if: > | ||
!contains(github.event.commits[0].message, '[skip ci-tests]') && github.event.pull_request.draft == false | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
devtools::test() | ||
shell: Rscript {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,60 @@ | ||
--- | ||
name: Gitleaks 🌧️ | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
workflow_call: | ||
inputs: | ||
gitleaks-version: | ||
description: Gitleaks executable version. | ||
required: false | ||
type: string | ||
default: "8.18.2" | ||
|
||
concurrency: | ||
group: gitleaks-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
gitleaks: | ||
name: ${{ vars.CI_IMAGE }} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ${{ vars.CI_IMAGE }} | ||
|
||
steps: | ||
- name: Checkout project ⬇️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Normalize inputs 📐 | ||
shell: bash | ||
run: | | ||
gitleaks_version_input="${{ inputs.gitleaks-version }}" | ||
echo "GITLEAKS_VERSION=${gitleaks_version_input:-8.18.2}" >> $GITHUB_ENV | ||
- name: Install gitleaks 💧 | ||
run: | | ||
cd /tmp | ||
wget -q \ | ||
"https://github.com/zricethezav/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \ | ||
-O gitleaks.tar.gz || \ | ||
(echo "Error downloading gitleaks ${GITLEAKS_VERSION} tarball" && exit 1) | ||
tar -xvzf gitleaks.tar.gz || \ | ||
(echo "Error unarchiving gitleaks ${GITLEAKS_VERSION} tarball" && exit 1) | ||
mv gitleaks /usr/bin/. || \ | ||
(echo "Error moving gitleaks for /usr/bin" && exit 1) | ||
shell: bash | ||
|
||
- name: Run gitleaks 🌧️ | ||
run: gitleaks -v detect --no-git --source . | ||
shell: bash |
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,43 @@ | ||
--- | ||
name: Lintr 🔍 | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
workflow_call: | ||
inputs: | ||
lintr-error-on-lint: | ||
description: Raise lintr error when lints found. | ||
required: false | ||
default: true | ||
type: boolean | ||
|
||
concurrency: | ||
group: lint-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lintr: | ||
name: ${{ vars.CI_IMAGE }} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ${{ vars.CI_IMAGE }} | ||
|
||
steps: | ||
- name: Checkout project ⬇️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Lintr 🔍 | ||
run: lintr::lint_package() | ||
shell: Rscript {0} | ||
env: | ||
LINTR_ERROR_ON_LINT: ${{ inputs.lintr-error-on-lint }} |
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,49 @@ | ||
--- | ||
name: Pkgdown 📖 | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
workflow_call: | ||
|
||
concurrency: | ||
group: pkgdown-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
pkgdown: | ||
name: ${{ vars.CI_IMAGE }} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ${{ vars.CI_IMAGE }} | ||
|
||
steps: | ||
- name: Checkout project ⬇️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build site 🔧 | ||
run: pkgdown::build_site() | ||
shell: Rscript {0} | ||
|
||
- name: Checkout gh-pages branch ⬇️ | ||
uses: actions/checkout@v4 | ||
with: | ||
path: gh-pages | ||
ref: gh-pages | ||
|
||
- name: Deploy to GitHub pages 📰 | ||
if: (github.event_name == 'push') && (github.ref_name == 'main') | ||
uses: JamesIves/[email protected] | ||
with: | ||
clean: true | ||
branch: gh-pages | ||
folder: docs |
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,55 @@ | ||
--- | ||
name: Roxygen 📄 | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
workflow_call: | ||
|
||
concurrency: | ||
group: roxygen-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
roxygen: | ||
name: ${{ vars.CI_IMAGE }} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ${{ vars.CI_IMAGE }} | ||
|
||
steps: | ||
- name: Checkout project ⬇️ | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ${{ github.event.repository.name }} | ||
|
||
- name: Generate man pages 📄 | ||
run: | | ||
Rscript -e 'roxygen2::roxygenize()' | ||
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 "Here are the differences:" | ||
git diff man/* DESCRIPTION | ||
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 | ||
else | ||
echo "👍 Manuals are up-to-date with roxygen comments" | ||
fi | ||
shell: bash | ||
working-directory: ${{ github.event.repository.name }} |
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,3 @@ | ||
.Rproj.user | ||
_snaps/ | ||
docs/ |
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,21 @@ | ||
Package: dv.templates | ||
Title: Provides reusable functionality for R and CI/CD | ||
Version: 0.0.0.9100 | ||
Authors@R: c( | ||
person("Boehringer Ingelheim International GmbH", role = c("cph", "fnd")), | ||
person("Sorin", "Voicu", , "[email protected]", role = c("aut", "cre")) | ||
) | ||
Description: Provides reusable functionality for R and CI/CD. | ||
License: Apache License 2.0 | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
Imports: | ||
shiny, | ||
stringr | ||
Suggests: | ||
knitr, | ||
testthat (>= 2.0), | ||
shinytest2 | ||
VignetteBuilder: | ||
knitr | ||
RoxygenNote: 7.3.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,13 @@ | ||
Copyright 2024 Boehringer Ingelheim International GmbH | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(hello) | ||
export(run_app) |
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,40 @@ | ||
#' Personal greeting | ||
#' | ||
#' @description Greet a person and appropriately capitalize their name. | ||
#' | ||
#' @param name Your name (character string; e.g. "john doe"). | ||
#' | ||
#' @return A character string, capitalized to title case. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' hello("james bond") | ||
hello <- function(name = "your name") { | ||
name <- stringr::str_to_title(name) | ||
print(paste("Hello,", name)) | ||
} | ||
|
||
#' Personal greeting as a Shiny app | ||
#' | ||
#' @description Greet a person and appropriately capitalize their name | ||
#' as a Shiny app. | ||
#' | ||
#' @return Shiny app showcasing the personal greeting feature. | ||
#' @export | ||
#' | ||
run_app <- function() { | ||
ui <- shiny::fluidPage( | ||
shiny::textInput("name", "What is your name?"), | ||
shiny::actionButton("greet", "Greet"), | ||
shiny::textOutput("greeting") | ||
) | ||
|
||
server <- function(input, output, session) { | ||
output$greeting <- shiny::renderText({ | ||
shiny::req(input$greet) | ||
hello(shiny::isolate(input$name)) | ||
}) | ||
} | ||
|
||
shiny::shinyApp(ui, server) | ||
} |
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,17 @@ | ||
<img src="inst/repo-logo.svg" align="right" height="138" alt="" /> | ||
|
||
# dv.templates | ||
|
||
[![Build status](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/check.yml/badge.svg)](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/check.yml?query=workflow) | ||
[![Build status](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/gitleaks.yml/badge.svg)](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/gitleaks.yml?query=workflow) | ||
[![Build status](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/lintr.yml/badge.svg)](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/lintr.yml?query=workflow) | ||
[![Build status](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/pkgdown.yml/badge.svg)](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/pkgdown.yml?query=workflow) | ||
[![Build status](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/roxygen.yml/badge.svg)](https://github.com/boehringer-ingelheim/dv.templates/actions/workflows/roxygen.yml?query=workflow) | ||
|
||
An R package template with built-in GitHub Actions-based CI/CD workflows. | ||
|
||
### Usage | ||
|
||
All CI/CD jobs are defined in the [.github/workflows](https://github.com/boehringer-ingelheim/dv.templates/blob/main/.github/workflows) directory in the form of GitHub Action workflows. These can be modified per your requirements, but are designed and implemented to follow best practices and to ensure the highest quality standards for your package. | ||
|
||
👉 For more information on workflows, please refer to the [Workflows documentation](./workflows.md). |
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,9 @@ | ||
url: https://boehringer-ingelheim.github.io/dv.templates/ | ||
|
||
template: | ||
bootstrap: 5 | ||
|
||
navbar: | ||
right: | ||
- icon: fa-github | ||
href: https://github.com/boehringer-ingelheim/dv.templates |
Oops, something went wrong.