added new tests and changed documentation #39
Workflow file for this run
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
--- | ||
name: R CMD Check 𧬠| ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
branches: | ||
- main | ||
- pre-release | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
branches: | ||
- main | ||
- pre-release | ||
workflow_dispatch: | ||
workflow_call: | ||
secrets: | ||
GITHUB_TOKEN: | ||
Check failure on line 23 in .github/workflows/build-check-install.yaml GitHub Actions / .github/workflows/build-check-install.yamlInvalid workflow file
|
||
description: | | ||
Github token with read access to repositories, required for staged.dependencies installation | ||
required: false | ||
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: true | ||
type: boolean | ||
R_CHECK_FORCE_SUGGESTS: | ||
description: If true, give an error if suggested packages are not available | ||
required: false | ||
default: true | ||
type: boolean | ||
skip-r-cmd-check: | ||
description: Skip the R CMD check step in this workflow | ||
required: false | ||
default: false | ||
type: boolean | ||
skip-r-cmd-install: | ||
description: Skip the R CMD INSTALL step in this workflow | ||
required: false | ||
default: false | ||
type: boolean | ||
check-note-blocklist: | ||
description: Whether to check for NOTEs that should cause the pipeline to fail | ||
required: false | ||
default: false | ||
type: boolean | ||
note-blocklist: | ||
description: List of regular expressions appearing in NOTEs that should cause the pipeline to fail | ||
# Example usage: | ||
# note-blocklist: | | ||
# checking package dependencies ... NOTE( )+Depends: includes the non-default packages | ||
# checking R code for possible problems ... NOTE( )+.*: no visible global function definition for | ||
# checking for unstated dependencies in vignettes ... NOTE( )+\'.*\' import not declared from | ||
# checking dependencies in R code ... NOTE( )+Namespace in Imports field not imported from | ||
# checking installed package size ... NOTE( )+installed size is | ||
required: false | ||
default: "" | ||
type: string | ||
concurrency: | ||
group: r-cmd-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
build-install-check: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- image: ghcr.io/insightsengineering/rstudio_4.2.1_bioc_3.15 | ||
tag: latest | ||
name: ${{ matrix.config.image }}, version ${{ matrix.config.tag }} | ||
runs-on: ubuntu-latest | ||
if: > | ||
!contains(github.event.commits[0].message, '[skip r-cmd]') | ||
&& github.event.pull_request.draft == false | ||
container: | ||
image: ${{ matrix.config.image }}:${{ matrix.config.tag }} | ||
steps: | ||
- name: Get branch names πΏ | ||
id: branch-name | ||
uses: tj-actions/branch-names@v5 | ||
- name: Checkout repo π | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ steps.branch-name.outputs.head_ref_branch }} | ||
path: ${{ github.event.repository.name }} | ||
- name: Run Staged dependencies π¦ | ||
uses: insightsengineering/staged-dependencies-action@v1 | ||
with: | ||
run-system-dependencies: ${{ inputs.install-system-dependencies }} | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
SD_REPO_PATH: ${{ github.event.repository.name }} | ||
SD_ENABLE_CHECK: ${{ inputs.enable-staged-dependencies-check }} | ||
- name: Show session info and installed packages βΉ | ||
run: | | ||
sessionInfo() | ||
as.data.frame(installed.packages()[, c("LibPath", "Version")]) | ||
shell: Rscript {0} | ||
- name: Build R package π | ||
run: | | ||
R CMD build ${{ github.event.repository.name }} | ||
echo "PKGBUILD=$(echo *.tar.gz)" >> $GITHUB_ENV | ||
shell: bash | ||
- name: Set TESTING_DEPTH β | ||
env: | ||
COMMIT_NEWEST_MESSAGE: ${{ github.event.head_commit.message }} | ||
COMMIT_OLDEST_MESSAGE: ${{ github.event.commits[0].message }} | ||
run: | | ||
cd ${{ github.event.repository.name }} | ||
# set TESTING_DEPTH for PR | ||
if [[ ! -z "${GITHUB_HEAD_REF}" ]]; then | ||
TESTING_DEPTH=3 | ||
echo "TESTING_DEPTH=3" >> $GITHUB_ENV | ||
COMMIT_NEWEST_MESSAGE=$(git log --format=%B -n 1 ${{ github.event.after }}) | ||
fi | ||
if [[ $COMMIT_NEWEST_MESSAGE == *"[skip tests]"* ]]; then | ||
echo "NO_TESTS=1" >> $GITHUB_ENV | ||
fi | ||
# default TESTING_DEPTH | ||
if [[ -z "${TESTING_DEPTH}" ]]; then | ||
echo "TESTING_DEPTH=1" >> $GITHUB_ENV | ||
fi | ||
shell: bash | ||
- name: Run R CMD check π | ||
run: | | ||
if [ "${{ inputs.skip-r-cmd-check }}" == "true" ] | ||
then { | ||
echo "Skipping R CMD check as 'skip-r-cmd-check' was set to 'true'" | ||
exit 0 | ||
} | ||
fi | ||
if [ "${{ inputs.R_CHECK_FORCE_SUGGESTS }}" == "" ] | ||
then { | ||
_R_CHECK_FORCE_SUGGESTS_="FALSE" | ||
} | ||
fi | ||
if [[ -z "${{ env.NO_TESTS }}" ]]; then | ||
R CMD check ${{ env.PKGBUILD }} | ||
else | ||
R CMD check --no-tests ${{ env.PKGBUILD }} | ||
fi | ||
shell: bash | ||
continue-on-error: true | ||
env: | ||
_R_CHECK_TESTS_NLINES_: 0 | ||
_R_CHECK_VIGNETTES_NLINES_: 0 | ||
_R_CHECK_FORCE_SUGGESTS_: ${{ inputs.R_CHECK_FORCE_SUGGESTS }} | ||
- name: Check whether JUnit XML report exists π¦ | ||
id: check-junit-xml | ||
uses: andstor/file-existence-action@v1 | ||
with: | ||
files: "${{ github.event.repository.name }}.Rcheck/tests/testthat/junit-result.xml" | ||
- name: Publish Unit Test Summary π | ||
uses: EnricoMi/publish-unit-test-result-action@v1 | ||
if: steps.check-junit-xml.outputs.files_exists == 'true' && github.event_name == 'pull_request' | ||
with: | ||
check_name: Unit Tests Summary | ||
files: "${{ github.event.repository.name }}.Rcheck/tests/testthat/junit-result.xml" | ||
- name: Catch warnings in R CMD check output π³ | ||
id: catch-errors | ||
run: | | ||
check_log <- "${{ github.event.repository.name }}.Rcheck/00check.log" | ||
if (file.exists(check_log)) { | ||
x <- tail(readLines(check_log), 1) | ||
if (grepl("ERROR", x)) { | ||
writeLines(readLines(check_log)) | ||
stop("β R CMD check has errors") | ||
} | ||
if (grepl("WARNING", x)) { | ||
writeLines(readLines(check_log)) | ||
stop("β R CMD check has warnings") | ||
} | ||
if ("${{ inputs.check-note-blocklist }}" == "true") { | ||
print("Checking notes...") | ||
regexes <- "${{ inputs.note-blocklist }}" | ||
regexes <- unlist(strsplit(regexes, split = "\n")) | ||
lines <- paste(readLines(check_log), collapse = " ") | ||
notes_result <- vapply( | ||
regexes, | ||
function(r){ | ||
if (grepl(r, lines)) { | ||
print(r) | ||
return(TRUE) | ||
} | ||
return(FALSE) | ||
}, | ||
logical(1) | ||
) | ||
if (any(notes_result)) { | ||
stop("NOTEs on the blocklist were found (see above).") | ||
} | ||
} | ||
} | ||
shell: Rscript {0} | ||
- name: Install R package π§ | ||
run: | | ||
if [ "${{ inputs.skip-r-cmd-install }}" == "true" ] | ||
then { | ||
echo "Skipping R CMD INSTALL as 'skip-r-cmd-install' was set to 'true'" | ||
exit 0 | ||
} | ||
fi | ||
R CMD INSTALL ${{ env.PKGBUILD }} | ||
shell: bash | ||
- name: Upload package build ‴ | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: ${{ env.PKGBUILD }} | ||
name: ${{ env.PKGBUILD }} | ||
upload-release-assets: | ||
name: Upload build tar.gz | ||
needs: build-install-check | ||
runs-on: ubuntu-latest | ||
if: > | ||
startsWith(github.ref, 'refs/tags/v') | ||
&& (!contains(github.event.commits[0].message, '[skip r-cmd]')) | ||
&& github.event.pull_request.draft == false | ||
steps: | ||
- name: Checkout repo π | ||
uses: actions/checkout@v3 | ||
- name: Set release version and package build filename π | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV | ||
- name: Get package build filename π¦ | ||
run: echo "PKGBUILD=${{ github.event.repository.name }}_${{ env.RELEASE_VERSION }}.tar.gz" >> $GITHUB_ENV | ||
- name: Download artifact β¬ | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ env.PKGBUILD }} | ||
- name: Upload binaries to release πΌ | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ${{ env.PKGBUILD }} | ||
asset_name: ${{ env.PKGBUILD }} | ||
tag: ${{ github.ref }} | ||
overwrite: true |