Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests before Docker builds, general clean up #2

Merged
merged 30 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
15dde33
- clean up requirements
thomas-enzlein May 22, 2024
99dd00c
test github action
thomas-enzlein May 22, 2024
2eecbce
Merge branch 'main' into dev
thomas-enzlein May 22, 2024
a6ed1dc
- clean up lasso experiment remnants
thomas-enzlein May 22, 2024
d57c56d
- fix checkInstalledPackages
thomas-enzlein May 22, 2024
d6181cc
- clean up redudant code to check and install packages
thomas-enzlein May 22, 2024
3d55480
- update dockerfile to fix config errors when building
thomas-enzlein May 22, 2024
7b783c8
- clean up server.R
thomas-enzlein May 23, 2024
012bb98
- cleaned req.txt
thomas-enzlein May 23, 2024
d419534
- set up tests for mzML and Bruker file loading
thomas-enzlein May 24, 2024
cbcf5e1
- activate GHA caching
thomas-enzlein May 27, 2024
22b37cc
fix for last commit
thomas-enzlein May 27, 2024
14bbb49
- fix `zoo` dependency problem
thomas-enzlein May 27, 2024
5999633
- remove browser() for debugging pca plots.
thomas-enzlein May 27, 2024
5dc3142
- append last commit
thomas-enzlein May 27, 2024
be79a06
- update GHA to use versions instead of hashes
thomas-enzlein May 27, 2024
70eae8a
- fix caching
thomas-enzlein May 27, 2024
772dde0
- add tests to GHA
thomas-enzlein May 27, 2024
711c12f
- fix tests
thomas-enzlein May 27, 2024
aa63fb6
- futher fix to tests
thomas-enzlein May 27, 2024
690bba0
- again...
thomas-enzlein May 27, 2024
c2717e3
- next try
thomas-enzlein May 27, 2024
ff60340
- add system requirements for devtools
thomas-enzlein May 27, 2024
b6f747c
- fix last commit
thomas-enzlein May 27, 2024
7a96285
- next try
thomas-enzlein May 27, 2024
c39574b
- add libcurl4-openssl-dev as system dependency
thomas-enzlein May 27, 2024
4c85896
- add github pat
thomas-enzlein May 27, 2024
dc8fac3
- remove library() calls from individual functions
thomas-enzlein May 27, 2024
7abcaf7
- fix tests
thomas-enzlein May 28, 2024
a3250d4
- add test that checks if processing was sucessful
thomas-enzlein May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
78 changes: 46 additions & 32 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches:
branches:
- main
- dev
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches:
branches:
- main
- dev

env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: thomasenzlein/m2ara

GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
Expand All @@ -31,51 +23,73 @@ jobs:
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@v4

# 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@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
# Set up R environment
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
cosign-release: 'v2.1.1'
r-version: '4.4.0'

# Install system dependencies for R packages
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get -y install libcurl4-openssl-dev libssl-dev libxml2-dev build-essential libxml2-dev libgit2-dev libudunits2-dev librsvg2-dev tk libharfbuzz-dev libfribidi-dev

# Install R package dependencies from req.txt
- name: Install R packages from req.txt
run: |
R -e "install.packages('devtools')"
R -e "devtools::install_github('CeMOS-Mannheim/MALDIcellassay')"
R -e "packages <- readLines('req.txt'); install.packages(packages)"

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
# Install testthat if it's not listed in req.txt
- name: Install testthat
run: R -e "if (!require('testthat')) install.packages('testthat')"

# Run tests
- name: Run tests
run: R -e "source('tests/testthat.R')"

# This step will be skipped if the tests fail
# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
uses: docker/setup-buildx-action@v3.3.0

# 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@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
uses: docker/login-action@v3.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.dockeriouser }}
password: ${{ secrets.dockeriopwd }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Create cache directory
run: mkdir -p /tmp/.buildx-cache

- name: Cache Docker layers
id: cache-docker-layers
uses: actions/cache@v4.0.2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# 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@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
uses: docker/build-push-action@v5.3.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
Expand Down
28 changes: 13 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# Base image https://hub.docker.com/u/rocker/
FROM rocker/shiny-verse:latest

# copy necessary files
## renv.lock file
#COPY ./renv.lock ./renv.lock
## app folder
COPY ./ ./app
RUN apt-get update && apt-get install -y \
sudo \
libudunits2-dev \
librsvg2-dev \
tk

# install renv
#RUN Rscript -e 'install.packages("renv")'
# Copy the req.txt file to the Docker image
COPY req.txt /req.txt

# set renv library path
#ENV RENV_PATHS_LIBRARY renv/library
# Install R packages from req.txt
RUN R -e "packages <- readLines('/req.txt'); install.packages(packages)"

# restore packages
#RUN Rscript -e 'renv::restore()'
# Install the MALDIcellassay from GitHub
RUN R -e "devtools::install_github('CeMOS-Mannheim/MALDIcellassay')"

# install main package
RUN Rscript -e 'install.packages("devtools")'
RUN Rscript -e 'devtools::install_github("CeMOS-Mannheim/MALDIcellassay")'
RUN Rscript -e 'source("/app/install_packages.R")'
## copy app folder into container
COPY ./ ./app

# expose port
EXPOSE 3838
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img src="M2ara_Logo.png" alt="M²ara overview" width="100" height="100">
<img src="figures/M2ara_Logo.png" alt="M²ara overview" width="100" height="100">

# M²ara - MALDI MS Bioassays Evaluation and Classification App

Expand Down
Binary file removed Workflow_figure.png
Binary file not shown.
44 changes: 1 addition & 43 deletions app.R
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
(function(req_file, install = T, update = F, silent = F) {

# Read text file containing required packages
if(!file.exists("req.txt")) {
warning("req.txt was not found. No packages installed or checked.")
return()
}

req <- scan(req_file, character(), quiet = T)

# Update packages
if (update) {
update.packages(repos = "https://cloud.r-project.org", ask = F)
}

# Install missing packages
if (length(req) > 0 & install) {
missing_packages <- req[!(req %in% installed.packages()[,"Package"])]
if (length(missing_packages) > 0) {
install.packages(
missing_packages,
repos = "https://cloud.r-project.org",
dependencies = T,
clean = T
)
}
}



# Load packages
if (silent) {
suppressPackageStartupMessages(invisible(lapply(req, library, character.only = T)))
} else {
lapply(req, library, character.only = T)
}


})("req.txt", silent = F)


# check if all required packages are installed

source("functions/checkInstalledPackages.R")
checkInstalledPackages()
checkInstalledPackages(req_file = "req.txt")

knit("manual.Rmd", quiet = TRUE)

Expand Down
67 changes: 0 additions & 67 deletions components/lassoTab.R

This file was deleted.

1 change: 0 additions & 1 deletion components/mainpanel.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source("components/mainTab.R")
source("components/qcTab.R")
source("components/pcaTab.R")
source("components/lassoTab.R")
source("components/hcTab.R")

appMainPanel <- function(defaults) {
Expand Down
1 change: 0 additions & 1 deletion components/qcTab.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ qcTab <- function() {
"Selected-mz",
"PC-x",
"PC-y",
"LASSO-error",
"Outlier-mz",
"Outlier-all"),
multiple = FALSE,
Expand Down
Loading