|
1 | 1 | # r-pkg
|
2 | 2 |
|
3 |
| -Devcontainer Configuration for creating R packages inside of GitHub Codespaces |
| 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 | 4 |
|
5 |
| -Obtain a copy of the devcontainer by using: |
| 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 [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. 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 | +## Quick start |
| 24 | + |
| 25 | +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. |
| 26 | + |
| 27 | +```r |
| 28 | +usethis::create_package("name-of-package") |
| 29 | +usethis::use_package_doc() |
| 30 | +usethis::use_agpl3_license() |
| 31 | +usethis::use_testthat() |
| 32 | +usethis::use_github_action("check-standard") |
| 33 | +usethis::use_pkgdown_github_pages() |
| 34 | +``` |
| 35 | + |
| 36 | +## Resources |
| 37 | + |
| 38 | +- [Manual: Writing R extensions](https://cran.r-project.org/doc/manuals/r-release/R-exts.html) |
| 39 | +- [Textbook: R Packages](https://r-pkgs.org/) |
| 40 | +- [usethis](https://usethis.r-lib.org/) |
| 41 | +- [devtools](https://devtools.r-lib.org/) |
| 42 | + |
| 43 | +## Developer notes |
| 44 | + |
| 45 | +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). |
| 46 | + |
| 47 | +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. |
| 48 | + |
| 49 | +> [!IMPORTANT] |
| 50 | +> |
| 51 | +> Make sure to specify the permissions as stated in the GitHub Actions workflow linked above |
| 52 | +> and for organizations please make sure to have the organization's container registry enabled. |
| 53 | +> |
| 54 | +> 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