diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..87b476d --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,2 @@ +^\.github$ +^LICENSE\.md$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..e10bb38 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,31 @@ +# 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] + pull_request: + branches: [main] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..f5e15fa --- /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 \ No newline at end of file diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..cf9fa24 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -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: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage + + - name: Test coverage + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package \ No newline at end of file diff --git a/.github/workflows/urlchecker.yaml b/.github/workflows/urlchecker.yaml new file mode 100644 index 0000000..2537d21 --- /dev/null +++ b/.github/workflows/urlchecker.yaml @@ -0,0 +1,39 @@ +# A custom workflow that checks the validity of +# URLs in source code as well as documentation. +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: urlchecker + +jobs: + urlchecker: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::urlchecker + + - name: Check for valid URLs + run: | + urlchecker::url_check( + path = ".", + db = NULL, + parallel = TRUE, + pool = curl::new_pool(), + progress = TRUE + ) + shell: Rscript {0} diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..a5e1a76 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,14 @@ +Package: devops.toolkit +Title: What the Package Does (One Line, Title Case) +Version: 0.0.0.9000 +Authors@R: + person("First", "Last", , "first.last@example.com", role = c("aut", "cre"), + comment = c(ORCID = "YOUR-ORCID-ID")) +Description: What the package does (one paragraph). +License: Apache License (>= 2) +Encoding: UTF-8 +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.2.3 +Suggests: testthat (>= 3.2.0) +Config/testthat/edition: 3 +Config/testthat/parallel: true diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..01843dc --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,3 @@ +# Generated by roxygen2: do not edit by hand + +export(hello) diff --git a/R/hello.R b/R/hello.R new file mode 100644 index 0000000..cb9dd05 --- /dev/null +++ b/R/hello.R @@ -0,0 +1,10 @@ +#' Greet an entity. Could be a person, an animal, or an alien. +#' +#' @param name The name of the entity to greet. +#' @return A greeting as a string. +#' @export +#' @examples +#' hello("E.T.") +hello <- function(name) { + paste("Hello", name) +} diff --git a/man/hello.Rd b/man/hello.Rd new file mode 100644 index 0000000..e0151dd --- /dev/null +++ b/man/hello.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/hello.R +\name{hello} +\alias{hello} +\title{Greet an entity. Could be a person, an animal, or an alien.} +\usage{ +hello(name) +} +\arguments{ +\item{name}{The name of the entity to greet.} +} +\value{ +A greeting as a string. +} +\description{ +Greet an entity. Could be a person, an animal, or an alien. +} +\examples{ +hello("E.T.") +} diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..f3647c2 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,3 @@ +pkg_name <- "devops.toolkit" +library(pkg_name, character.only = TRUE) +testthat::test_check(pkg_name) diff --git a/tests/testthat/test-hello.R b/tests/testthat/test-hello.R new file mode 100644 index 0000000..89713a4 --- /dev/null +++ b/tests/testthat/test-hello.R @@ -0,0 +1,5 @@ +test_that("hello greets the entity", { + result <- hello("foo") + expected <- "Hello foo" + expect_identical(result, expected) +})