Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sorinvoicu committed Mar 13, 2024
0 parents commit 528300b
Show file tree
Hide file tree
Showing 24 changed files with 658 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
^dv.templates\.Rproj$
^\.Rproj\.user$
^.*\.Rproj$
^LICENSE\.md$
^LICENSE$
^\.github
_pkgdown.yml
workflows.md
dependencies.yml
57 changes: 57 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
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: Install package dependencies 📄
run: |
if (file.exists("dependencies.yml")) {
repos <- yaml::yaml.load(readLines("dependencies.yml"))$dependencies |>
sapply(function(x) x$repo)
if(repos |> length() > 0) {
repos |>
pak::pak(dependencies = TRUE, ask = FALSE, upgrade = FALSE)
}
}
shell: Rscript {0}

- 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 tests]') && github.event.pull_request.draft == false
run: |
options(crayon.enabled = TRUE)
devtools::test()
shell: Rscript {0}
60 changes: 60 additions & 0 deletions .github/workflows/gitleaks.yml
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
44 changes: 44 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Check URLs 🌐

on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
push:
branches:
- main
workflow_call:

concurrency:
group: links-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
links:
name: ${{ vars.CI_IMAGE }}
runs-on: ubuntu-latest

steps:
- name: Checkout project ⬇️
uses: actions/checkout@v4

- name: Check URLs 🌐
uses: lycheeverse/lychee-action@v1
with:
fail: true
args: >-
--verbose
--no-progress
--exclude "https://github.com.*.tar.gz"
**/*.md
**/*.Rmd
**/*.html
**/*.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/lintr.yml
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 }}
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yml
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
55 changes: 55 additions & 0 deletions .github/workflows/roxygen.yml
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 }}
32 changes: 32 additions & 0 deletions .github/workflows/shared_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Checks 🧩

on:
workflow_call:

jobs:
check-test:
name: Check 📦
uses: boehringer-ingelheim/dv.templates/.github/workflows/check.yml@main

lintr:
name: Lintr 🔍
uses: boehringer-ingelheim/dv.templates/.github/workflows/lintr.yml@main
with:
lintr-error-on-lint: true

gitleaks:
name: Gitleaks 🌧️
uses: boehringer-ingelheim/dv.templates/.github/workflows/gitleaks.yml@main

roxygen:
name: Roxygen 📄
uses: boehringer-ingelheim/dv.templates/.github/workflows/roxygen.yml@main

pkgdown:
name: Pkgdown 📖
uses: boehringer-ingelheim/dv.templates/.github/workflows/pkgdown.yml@main

links:
name: Check URLs 🌐
uses: boehringer-ingelheim/dv.templates/.github/workflows/links.yml@main
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Rproj.user
_snaps/
docs/
21 changes: 21 additions & 0 deletions DESCRIPTION
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 Pharma GmbH & Co.KG", 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
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Boehringer-Ingelheim Pharma GmbH & Co.KG

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.
Loading

0 comments on commit 528300b

Please sign in to comment.