Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fame2827 authored Nov 13, 2023
0 parents commit 84490d8
Show file tree
Hide file tree
Showing 14 changed files with 477 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
^LICENSE\.md$
.github
Dockerfile
_pkgdown.yml
142 changes: 142 additions & 0 deletions .github/workflows/basic_checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Check, build, and push image

on: [push, pull_request]

env:
cache-version: v1

jobs:
r-build-and-check:
runs-on: ubuntu-latest
container: bioconductor/bioconductor_docker:devel
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- name: Query dependencies and update old packages
run: |
BiocManager::install(ask=FALSE)
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
with:
path: /usr/local/lib/R/site-library
key: ${{ env.cache-version }}-${{ runner.os }}-r-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-r-

# This lets us augment with additional dependencies
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
BiocManager::repositories()
remotes::install_deps(dependencies = TRUE, repos = BiocManager::repositories())
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "warning", check_dir = "check")
shell: Rscript {0}


- name: Build pkgdown
run: |
PATH=$PATH:$HOME/bin/ Rscript -e 'pkgdown::build_site(".")'
# deploy needs rsync? Seems so.
- name: Install deploy dependencies
run: |
apt-get update
apt-get -y install rsync
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs # The folder the action should deploy.
docker-build-and-push:
#needs: r-build-and-check
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set Environment Variables
run: |
REPO_LOWER="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
REGISTRY=ghcr.io
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "REGISTRY=${REGISTRY}" >> $GITHUB_ENV
echo "IMAGE=${REGISTRY}/${REPO_LOWER}" >> $GITHUB_ENV
- name: Show environment
run: |
env
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422
with:
cosign-release: 'v1.4.0'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.IMAGE }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ env.GIT_SHA }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inst/doc
*~
28 changes: 28 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Package: BuildABiocWorkshop
Title: Bioconductor or R Workshop Template and Github Actions
Version: 2.0.0
Authors@R:
person(given = "Sean",
family = "Davis",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-8991-6458"))
Description: This package serves as a template for using github actions to
prepare a Bioconductor Workshop package for use. In particular,
a pkgdown website and docker image are generated based on workflow
settings.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
Depends:
Biobase
Suggests:
knitr,
rmarkdown,
pkgdown
URL: https://seandavi.github.io/BuildABiocWorkshop/
BugReports: https://github.com/seandavi/BuildABiocWorkshop/issues/new/choose
VignetteBuilder: knitr
DockerImage: ghcr.io/seandavi/buildabiocworkshop:latest
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM bioconductor/bioconductor_docker:devel

WORKDIR /home/rstudio

COPY --chown=rstudio:rstudio . /home/rstudio/

RUN Rscript -e "options(repos = c(CRAN = 'https://cran.r-project.org')); BiocManager::install(ask=FALSE)"

RUN Rscript -e "options(repos = c(CRAN = 'https://cran.r-project.org')); devtools::install('.', dependencies=TRUE, build_vignettes=TRUE, repos = BiocManager::repositories())"
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: Sean Davis
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2020 Sean Davis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by roxygen2: do not edit by hand

52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# BuildABiocWorkshop

This package is a template for building a Bioconductor workshop. The package
includes Github actions to:

1. Set up bioconductor/bioconductor_docker:devel on Github resources
2. Install package dependencies for your package (based on the `DESCRIPTION` file)
3. Run `rcmdcheck::rcmdcheck`
4. Build a pkgdown website and push it to github pages
5. Build a docker image with the installed package and dependencies and deploy to [the Github Container Repository](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#pulling-container-images) at the name `ghcr.io/gihub_user/repo_name`, all lowercase.

## Responsibilities

Package authors are primarily responsible for:

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`.
2. Creating a docker 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.

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.

## Details

For detailed instructions, see the `How to build a workshop` article/vignette.

## Results of successful deployment

- A working docker image that contains the installed package and dependencies.
- An up-to-date `pkgdown` website at https://YOURUSERNAME.github.io/YOURREPOSITORYNAME/
- Docker image will be tagged with `latest`, `sha-XXXXXX` where `XXXXXX` is the hash of the current `master` commit, and `master`.

## To use the resulting image:

```sh
docker run -e PASSWORD=<choose_a_password_for_rstudio> -p 8787:8787 YOURDOCKERIMAGENAME
```
Once running, navigate to http://localhost:8787/ and then login with `rstudio`:`yourchosenpassword`.

To try with **this** repository docker image:

```sh
docker run -e PASSWORD=abc -p 8787:8787 ghcr.io/bioconductor/buildabiocworkshop
```

*NOTE*: Running docker that uses the password in plain text like above exposes the password to others
in a multi-user system (like a shared workstation or compute node). In practice, consider using an environment
variable instead of plain text to pass along passwords and other secrets in docker command lines.


## Whatcha get

- https://bioconductor.github.io/BuildABiocWorkshop
- A Docker image that you can run locally, in the cloud, or (usually) even as a singularity container on HPC systems.
18 changes: 18 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
url: https://seandavi.github.io/BuildABiocWorkshop

template:
params:
bootswatch: flatly
#ganalytics: UA-99999999-9

home:
title: "BuildABiocWorkshop"
type: inverse


navbar:
right:
- icon: fa-github
href: https://github.com/seandavi/BuildABiocWorkshop


Binary file added inst/images/dockerhub_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
85 changes: 85 additions & 0 deletions vignettes/HOWTO_BUILD_WORKSHOP.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: "How To Build A Workshop Package"
subtitle: "In other words, how do I use what's here"
author: Sean Davis^[[email protected]]
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{How to Use this Package to Build a Bioc Workshop}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

First, this package doesn't do much except add a template Github Action to
build all the pieces necessary for a workshop.

## Quickstart

- [ ] Create a repo from this template and rename it (do not fork the repository).
- [ ] Ensure that "Read and Write Permissions" is checked under [General > Workflow permissions](https://github.com/seandavi/BuildABiocWorkshop/settings/actions).
- [ ] Edit `DESCRIPTION` file
- [ ] Change package name
- [ ] Change title and description
- [ ] Change authors
- [ ] Check dependencies
- [ ] Change DockerImage tag
- [ ] Edit '_pkgdown.yml' (and `.github/workflows yaml file` as needed)
- [ ] Write a normal R package that can be installed
- [ ] Include one or more vignettes that will constitute the workshop materials

## Details

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 will create for you:

- the pkgdown website
- the docker image

### 1. Clone this repo

Clone this repo, fork and **rename** it,

OR

(PREFERRED) create a repo from this template

### 2. Edit `DESCRIPTION` file

- Change the package name to something identifiable and descriptive, ideally
something that will be somewhat unique.
- Edit the title and description as per any normal R package.
- Update authors (unless you want me to get credit for your work).
- 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;

Depends:
Biobase
Suggests:
knitr,
rmarkdown,
pkgdown
If your packages depend on a github R repos, be sure to specify the correct repo `username/reponame`. Installation will deal with this.

- Edit the last 3 lines of the DESCRIPTION FILE, URL, BugReports and DockerImage (described in more detail below)

### 3. Set up a website (Github Pages)

In your repository, click on settings or url https://github.com/*GITHUB_USERNAME*/*REPO_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.

In the DESCRIPTION file, update the URL: to the website url eg https://seandavi.github.io/BuildABiocWorkshop/ (but substitute your own repo, etc.)

### 4. Edit _pkgdown.yml

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

### 5. Edit `.github/workflows yaml` as needed (likely no need)


You do not need to create a docker image manually. Github actions will read Dockerfile located in this template, and using the yaml files will create, build and push to the Github Container Registry an image with the name (default) `ghcr.io/yourgithubuser/yourgithubreponame`, all lowercase.


In the DESCRIPTION file, the **DockerImage: should match your the docker image name (should be lowercase)**.


### 6. Edit README.md, add vignettes to vignettes folder

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.


Loading

0 comments on commit 84490d8

Please sign in to comment.