|
| 1 | +# r-pkg |
| 2 | + |
| 3 | +This repository houses a devcontainer that setups an R package development environment. The container is setup to work with [GitHub Codespaces](https://github.com/features/codespaces) to instantly have a cloud-based developer workflow. |
| 4 | + |
| 5 | +You can try out the Codespace by clicking on the following button: |
| 6 | + |
| 7 | +[](https://codespaces.new/coatless-devcontainer/r-pkg?quickstart=1) |
| 8 | + |
| 9 | +> [!NOTE] |
| 10 | +> |
| 11 | +> Codespaces are available to Students and Teachers for free [up to 180 core hours per month](https://docs.github.com/en/education/manage-coursework-with-github-classroom/integrate-github-classroom-with-an-ide/using-github-codespaces-with-github-classroom#about-github-codespaces) |
| 12 | +> through [GitHub Education](https://education.github.com/). Otherwise, you will have |
| 13 | +> [up to 60 core hours and 15 GB free per month](https://github.com/features/codespaces#pricing). |
| 14 | +
|
| 15 | +Or, you can press the template button to create a new repository with the same setup so that you |
| 16 | +can work locally on the devcontainer: |
| 17 | + |
| 18 | +[](https://github.com/coatless-devcontainer/r-pkg/generate) |
| 19 | + |
| 20 | +This will create a fork of the repository that can be worked on inside a local copy of |
| 21 | +[Visual Studio Code](https://code.visualstudio.com/) through the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). With the extension installed, you can open the repository in a container by pressing `F1` (to bring up command palette) and typing `Dev Container: Reopen in Container`. |
| 22 | + |
| 23 | +Lastly, you can directly obtain the underlying container image by typing in Terminal: |
| 24 | + |
| 25 | +```sh |
| 26 | +docker pull ghcr.io/coatless-devcontainer/r-pkg:latest |
| 27 | +``` |
| 28 | + |
| 29 | +## Quick start |
| 30 | + |
| 31 | +Run the following series of commands inside of R once the container opens. Make sure to change `"name-of-package"` to your current package name. |
| 32 | + |
| 33 | +```r |
| 34 | +usethis::create_package("name-of-package") |
| 35 | +usethis::use_package_doc() |
| 36 | +usethis::use_agpl3_license() |
| 37 | +usethis::use_testthat() |
| 38 | +usethis::use_github_action("check-standard") |
| 39 | +usethis::use_pkgdown_github_pages() |
| 40 | +``` |
| 41 | + |
| 42 | +## Resources |
| 43 | + |
| 44 | +- [Manual: Writing R extensions](https://cran.r-project.org/doc/manuals/r-release/R-exts.html) |
| 45 | +- [Textbook: R Packages](https://r-pkgs.org/) |
| 46 | +- [usethis](https://usethis.r-lib.org/) |
| 47 | +- [devtools](https://devtools.r-lib.org/) |
| 48 | + |
| 49 | +## Developer notes |
| 50 | + |
| 51 | +This repository uses a pre-built container strategy to have GitHub Actions build and, then, store the devcontainer in [GitHub's Container Repository](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry). |
| 52 | + |
| 53 | +We place the main logic of the devcontainer in [`.github/.devcontainer/devcontainer.json`](https://github.com/coatless-devcontainer/r-pkg/blob/main/.github/.devcontainer/devcontainer.json). From there, we use [`.github/workflows/pre-build-devcontainer.yml`](https://github.com/coatless-devcontainer/r-pkg/blob/main/.github/workflows/pre-build-devcontainer.yml) to build and publish the devcontainer onto GitHub's Container repository for the organization. Then, the repository's [`.devcontainer/devcontainer.json`](https://github.com/coatless-devcontainer/r-pkg/blob/main/.devcontainer/devcontainer.json) pulls the pre-built image. |
| 54 | + |
| 55 | +> [!IMPORTANT] |
| 56 | +> |
| 57 | +> Make sure to specify the permissions as stated in the GitHub Actions workflow linked above |
| 58 | +> and for organizations please make sure to have the organization's container registry enabled. |
| 59 | +> |
| 60 | +> For more information, see [GitHub's Container Registry documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry). |
0 commit comments