diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE new file mode 100644 index 0000000..17a4e7a --- /dev/null +++ b/.github/ISSUE_TEMPLATE @@ -0,0 +1,16 @@ + + +### Issue Description +Please provide a brief description of the issue here. + +### Inputs +Please describe your experimental/sequencing strategy (e.g. pgPEN library and screening data, sequenced with an Illumina MiSeq, etc.) + +### Your environment +Describe how you ran the pipeline (e.g. high-performance computing [HPC] cluster, linux/shell interface (Ubuntu, MacOS terminal, Windows powershell, etc.) + +### Steps to reproduce +Please include relevant commands and steps taken. If your counts table was generated outside of the Berger Lab's pgPEN analysis workflow, please also describe the steps taken to pre-process your data. + +### Pipeline behavior and error messages +Please include relevant screenshots or codeblocks with any relevant error messages. If your code ran up to a certain point before encountering an error, please include this information as well. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..a129617 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,34 @@ + + +# Description + + + +Fixes # (issue) + +## Type of change + + + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update + +# How Has This Been Tested? + + + +- [ ] Test A +- [ ] Test B + +# Checklist: + +- [ ] My code follows the style guidelines of this project +- [ ] I have performed a self-review of my code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] My changes generate no new warnings +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes +- [ ] Any dependent changes have been merged and published in downstream modules diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..1de52d3 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,93 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - main + pull_request: + branches: + - main + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: windows-latest, r: 'release'} + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-pandoc@v2 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Restore R package cache + if: runner.os != 'Windows' + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Check + run: | + options(crayon.enabled = TRUE) + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), check_dir = "check") + shell: Rscript {0} + + - name: Check testthat + if: runner.os != 'Windows' + id: check_check + run: | + error_num=$(Rscript --vanilla '.github/workflows/check_testthat.R') + echo "error_num=$error_num" >> $GITHUB_OUTPUT + + - name: Stop if there are errors! + if: ${{ steps.check_check.outputs.error_num != '0' }} + run: exit 1 + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/check_testthat.R b/.github/workflows/check_testthat.R new file mode 100644 index 0000000..7f33880 --- /dev/null +++ b/.github/workflows/check_testthat.R @@ -0,0 +1,31 @@ +# Check up on the testthat results +# C. Savonen +# Nov 2023 + +library(magrittr) + + +# Find .git root directory +root_dir <- rprojroot::find_root(rprojroot::has_dir(".git")) + +out_file <- list.files(pattern = "testthat.Rout$|Rout.fail$", file.path(root_dir, "check"), + recursive = TRUE, full.names = TRUE) + +check_content <- readLines(out_file) +test_result <- grep("\\[ FAIL", check_content, value = TRUE)[1] +test_result <- unlist(strsplit(test_result, "\\||\\[|\\]")) + +# Format the data into a dataframe +test_result_df <- data.frame(result = trimws(test_result)) %>% + dplyr::filter(result != "") %>% + tidyr::separate(result, sep = " ", into = c("test_name", "num")) %>% + dplyr::mutate(num = as.numeric(num)) + +fail_num <- test_result_df %>% + dplyr::filter(test_name %in% c("FAIL", "WARN")) %>% + dplyr::summarize(total = sum(num)) + +fail_num <- as.character(fail_num$total) + +# Spit the number out +writeLines(fail_num, con = stdout()) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..ed7650c --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,48 @@ +# 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: + push: + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: + +name: pkgdown + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.4.1 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/style-code.yml b/.github/workflows/style-code.yml new file mode 100644 index 0000000..06c29f3 --- /dev/null +++ b/.github/workflows/style-code.yml @@ -0,0 +1,37 @@ +# Candace Savonen 2024 + +name: Style Code + +on: + pull_request: + branches: [ main, staging ] + +jobs: + + style-code: + name: Style code + runs-on: ubuntu-latest + container: + image: cansav09/gimap + + steps: + - name: Checkout files + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Login as jhudsl-robot + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.email "itcrtrainingnetwork@gmail.com" + git config --global user.name "jhudsl-robot" + + - name: Run styler + run: Rscript -e "styler::style_file(list.files(pattern = 'Rmd$', recursive = TRUE, full.names = TRUE));warnings()" + + - name: Commit styled files + run: | + git config --system --add safe.directory "$GITHUB_WORKSPACE" + git add \*.Rmd + git commit -m 'Style Rmds' || echo "No changes to commit" + git push origin || echo "No changes to commit"