Skip to content

Commit fb94139

Browse files
committed
Initial commit
0 parents  commit fb94139

14 files changed

+448
-0
lines changed

.Rbuildignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
^LICENSE\.md$
2+
.github
3+
Dockerfile
4+
_pkgdown.yml

.github/workflows/basic_checks.yaml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
on: [push, pull_request]
2+
3+
env:
4+
cache-version: v1
5+
repo-name: seandavi/buildabiocworkshop
6+
7+
jobs:
8+
job1:
9+
runs-on: ubuntu-latest
10+
container: bioconductor/bioconductor_docker:devel
11+
steps:
12+
- uses: actions/checkout@v1
13+
14+
- name: Query dependencies and update old packages
15+
run: |
16+
BiocManager::install(ask=FALSE)
17+
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
18+
shell: Rscript {0}
19+
20+
- name: Cache R packages
21+
if: runner.os != 'Windows'
22+
uses: actions/cache@v1
23+
with:
24+
path: /usr/local/lib/R/site-library
25+
key: ${{ env.cache-version }}-${{ runner.os }}-r-${{ hashFiles('.github/depends.Rds') }}
26+
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-r-
27+
28+
# This lets us augment with additional dependencies
29+
- name: Install system dependencies
30+
if: runner.os == 'Linux'
31+
env:
32+
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
33+
run: |
34+
Rscript -e "remotes::install_github('r-hub/sysreqs')"
35+
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
36+
sudo -s eval "$sysreqs"
37+
38+
- name: Install dependencies
39+
run: |
40+
options(repos = c(CRAN = "https://cran.r-project.org"))
41+
BiocManager::repositories()
42+
remotes::install_deps(dependencies = TRUE, repos = BiocManager::repositories())
43+
remotes::install_cran("rcmdcheck")
44+
shell: Rscript {0}
45+
46+
- name: Check
47+
env:
48+
_R_CHECK_CRAN_INCOMING_REMOTE_: false
49+
run: rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "warning", check_dir = "check")
50+
shell: Rscript {0}
51+
52+
53+
- name: Build pkgdown
54+
run: |
55+
PATH=$PATH:$HOME/bin/ Rscript -e 'pkgdown::build_site(".")'
56+
57+
# deploy needs rsync? Seems so.
58+
- name: Install deploy dependencies
59+
run: |
60+
apt-get update
61+
apt-get -y install rsync
62+
63+
- name: Deploy 🚀
64+
uses: JamesIves/github-pages-deploy-action@releases/v3
65+
with:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
BRANCH: gh-pages # The branch the action should deploy to.
68+
FOLDER: docs # The folder the action should deploy.
69+
70+
- uses: docker/build-push-action@v1
71+
with:
72+
# The two entries below need to be entered as
73+
# github secrets. The "secret" names are "DOCKER_USERNAME"
74+
# and "DOCKER_PASSWORD". See https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository
75+
# for detailed instructions.
76+
#
77+
# DO NOT EDIT THESE ENTRIES HERE. Doing so will
78+
# expose your docker username and password on github.
79+
username: ${{ secrets.DOCKER_USERNAME }}
80+
password: ${{ secrets.DOCKER_PASSWORD }}
81+
# Use the environment variable on first few lines to set repo name--just centralizes changes
82+
repository: ${{ env.repo-name }}
83+
tag_with_ref: true
84+
tag_with_sha: true
85+
tags: latest

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
inst/doc
2+
*~

DESCRIPTION

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Package: BuildABiocWorkshop
2+
Title: Bioconductor Workshop Template and Github Actions
3+
Version: 0.9.0
4+
Authors@R:
5+
person(given = "Sean",
6+
family = "Davis",
7+
role = c("aut", "cre"),
8+
email = "[email protected]",
9+
comment = c(ORCID = "your-orc-id-here"))
10+
Description: This package serves as a template for using github actions to
11+
prepare a Bioconductor Workshop package for use. In particular,
12+
a pkgdown website and docker image are generated based on workflow
13+
settings.
14+
License: MIT + file LICENSE
15+
Encoding: UTF-8
16+
LazyData: true
17+
Roxygen: list(markdown = TRUE)
18+
RoxygenNote: 7.1.0
19+
Depends:
20+
Biobase
21+
Suggests:
22+
knitr,
23+
rmarkdown,
24+
pkgdown
25+
URL: https://seandavi.github.io/BuildABiocWorkshop/
26+
BugReports: https://github.com/seandavi/BuildABiocWorkshop/issues/new/choose
27+
VignetteBuilder: knitr
28+
DockerImage: seandavi/buildabiocworkshop:latest

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM bioconductor/bioconductor_docker:devel
2+
3+
WORKDIR /home/rstudio
4+
5+
COPY --chown=rstudio:rstudio . /home/rstudio/
6+
7+
RUN Rscript -e "options(repos = c(CRAN = 'https://cran.r-project.org')); BiocManager::install(ask=FALSE)"
8+
9+
RUN Rscript -e "options(repos = c(CRAN = 'https://cran.r-project.org')); devtools::install('.', dependencies=TRUE, build_vignettes=TRUE, repos = BiocManager::repositories())"

LICENSE

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
YEAR: 2020
2+
COPYRIGHT HOLDER: Sean Davis

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
3+
Copyright (c) 2020 Sean Davis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NAMESPACE

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated by roxygen2: do not edit by hand
2+

README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# BuildABiocWorkshop
2+
3+
This package is a template for building a Bioconductor workshop. The package
4+
includes Github actions to:
5+
6+
1. Set up bioconductor/bioconductor_docker:devel on Github resources
7+
2. Install package dependencies for your package (based on the `DESCRIPTION` file)
8+
3. Run `rcmdcheck::rcmdcheck`
9+
4. Build a pkgdown website and push it to github pages
10+
5. Build a docker image with the installed package and dependencies
11+
12+
## Responsibilities
13+
14+
This year, package authors will be primarily responsible for:
15+
16+
1. Creating a landing site of their choosing for their workshops (a website). This website should be listed in the `DESCRIPTION` file as the `URL`.
17+
2. Creating a docker account and image that will contain workshop materials and the installed packages necessary to run those materials. The name of the resulting docker image, including "tag" if desired, should be listed in a non-standard tag, `DockerImage:` in the `DESCRIPTION` file.
18+
19+
Both of those tasks can be accomplished using the Github actions included in this template package. The vignette accompanying this package describes how to accomplish both of these tasks.
20+
21+
## Details
22+
23+
For detailed instructions, see the `How to build a workshop` article/vignette.
24+
25+
## Results of successful deployment
26+
27+
- A working docker image that contains the installed package and dependencies.
28+
- An up-to-date `pkgdown` website at https://YOURUSERNAME.github.io/YOURREPOSITORYNAME/
29+
- Docker image will be tagged with `latest`, `sha-XXXXXX` where `XXXXXX` is the hash of the current `master` commit, and `master`.
30+
31+
## To use the resulting image:
32+
33+
```sh
34+
docker run -e PASSWORD=<choose_a_password_for_rstudio> -p 8787:8787 YOURDOCKERIMAGENAME
35+
```
36+
Once running, navigate to https://localhost:8787/ and then login with `rstudio`:`yourchosenpassword`.
37+
38+
To try with **this** repository docker image:
39+
40+
```sh
41+
docker run -e PASSWORD=abc -p 8787:8787 seandavi/buildabiocworkshop2020
42+
```
43+
44+
*NOTE*: Running docker that uses the password in plain text like above exposes the password to others
45+
in a multi-user system (like a shared workstation or compute node). In practice, consider using an environment
46+
variable instead of plain text to pass along passwords and other secrets in docker command lines.
47+
48+
49+
## Whatcha get
50+
51+
https://seandavi.github.io/BuildABiocWorkshop
52+
53+
![dockerhub](https://github.com/seandavi/BuildABiocWorkshop/raw/master/inst/images/dockerhub_result.png)

_pkgdown.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
url: https://seandavi.github.io/BuildABiocWorkshop
2+
3+
template:
4+
params:
5+
bootswatch: flatly
6+
#ganalytics: UA-99999999-9
7+
8+
home:
9+
title: "BuildABiocWorkshop"
10+
type: inverse
11+
12+
13+
navbar:
14+
right:
15+
- icon: fa-github
16+
href: https://github.com/seandavi/BuildABiocWorkshop
17+
18+

inst/images/dockerhub_result.png

226 KB
Loading

vignettes/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.html
2+
*.R

vignettes/HOWTO_BUILD_WORKSHOP.Rmd

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: "How To Build A Workshop Package"
3+
subtitle: "In other words, how do I use what's here"
4+
author: Sean Davis^[[email protected]]
5+
output: rmarkdown::html_vignette
6+
vignette: >
7+
%\VignetteIndexEntry{How to Use this Package to Build a Bioc Workshop}
8+
%\VignetteEngine{knitr::rmarkdown}
9+
%\VignetteEncoding{UTF-8}
10+
---
11+
12+
First, this package doesn't do much except add a template Github Action to
13+
build all the pieces necessary for a workshop.
14+
15+
## Quickstart
16+
17+
- [ ] Create a repo from this template and rename it (do not fork the repository).
18+
- [ ] Edit `DESCRIPTION` file
19+
- [ ] Change package name
20+
- [ ] Change title and description
21+
- [ ] Change authors
22+
- [ ] Check dependencies
23+
- [ ] Change DockerImage tag
24+
- [ ] Edit '_pkgdown.yml' and`.github/workflows/basic_checks.yaml`
25+
- [ ] Write a normal R package that can be installed
26+
- [ ] Include one or more vignettes that will constitute the workshop materials
27+
28+
## Details
29+
30+
To accomplish this follow each of the 7 steps below. Once your edit the yaml files, Github actions will run each time you commit to github and it creates the pkgdown website and docker image for you.
31+
32+
### 1. Clone this repo
33+
Clone this repo, fork and **rename** it, or create a repo from this template
34+
35+
```
36+
git clone https://github.com/seandavi/BuildABiocWorkshop MYPKGDIR
37+
```
38+
39+
### 2. Edit `DESCRIPTION` file
40+
41+
- Change the package name to something identifiable and descriptive, ideally
42+
something that will be somewhat unique.
43+
- Edit the title and description as per any normal R package.
44+
- Update authors (unless you want me to get credit for your work).
45+
- Workshop packages are normal R packages, so dependencies work as usual. Append libraries to the Depends/Suggests/Imports in this package DESCRIPTION File, which includes;
46+
47+
Depends:
48+
Biobase
49+
Suggests:
50+
knitr,
51+
rmarkdown,
52+
pkgdown
53+
If your packages depend on a github R repos, be sure to specify the correct repo `username/reponame`. Installation will deal with this.
54+
55+
- Edit the last 3 lines of the DESCRIPTION FILE, URL, BugReports and DockerImage (described in more detail below)
56+
57+
### 3. Set up a website (Github Pages)
58+
59+
In your repository, click on settings or url https://github.com/<github username>/<workshop repos name>/settings. Midway down the page, in the GitHub Pages section, select source 'gh-pages branch'. If only 'master branch' is visible, select master for now, but once Github actions runs, 'gh-pages branch' will be available and is required to render the website.
60+
61+
In the DESCRIPTION file, update the URL: to the website url eg https://seandavi.github.io/BuildABiocWorkshop/
62+
63+
### 4. Edit _pkgdown.yml
64+
65+
Edit the file _pkgdown.yml, updating the url:, title and href: which should be your website url, title of your workshop and github repos url respectively. You do not need to edit this file further. You do not need to add menus or links to vignettes. GitHub Actions and pkgdown will do this when it builds the website
66+
67+
### 5. Edit `.github/workflows/basic_checks.yaml`
68+
69+
You need a dockerhub account, which if you don't have one, can be created at hub.docker.com. Your <docker user name> maybe different to your <gitub username name>.
70+
71+
You do not need to create a docker image manually. Github actions will read Dockerfile located in this template, and using the yamls files will create, build and push to dockerhub an image with your desired name.
72+
73+
- **You MUST change the `repository` line in this yaml file to be YOUR desired Docker image name**.
74+
75+
- The **image name must be in lower case**.
76+
77+
78+
79+
80+
```yaml
81+
on: [push, pull_request]
82+
83+
env:
84+
cache-version: v1
85+
# Change the following line to what you want YOUR
86+
# docker image to be called. Do not include
87+
# any tags--those will be added automatically
88+
repo-name: seandavi/buildabiocworkshop
89+
```
90+
91+
In the DESCRIPTION file, the **DockerImage: should match your desired name for a dockerhub repository**.
92+
93+
### 6. Add "secrets" to github repo
94+
95+
Secrets are encrypted environment variables that you create in a
96+
repository or organization. The secrets you create are available to
97+
use in GitHub Actions workflows. GitHub uses a libsodium sealed box to
98+
help ensure that secrets are encrypted before they reach GitHub, and
99+
remain encrypted until you use them in a workflow.
100+
101+
See [Creating and storing encrypted secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)
102+
103+
- `DOCKER_USERNAME`: your dockerhub username; create a dockerhub account if you do not have one
104+
- `DOCKER_PASSWORD`: your dockerhub password or an access token obtained from [Docker Hub][]
105+
106+
[Docker Hub]: https://hub.docker.com/settings/security
107+
108+
109+
### 7. Edit README.md, add vignettes to vignettes folder
110+
Edit the README.md. and add one or more Rmd vignettes that will constitute the workshop materials. It is normal R package that should pass rcmdcheck::rcmdcheck(), and be installed using regular R package install commands.
111+
112+

0 commit comments

Comments
 (0)