Skip to content

Commit

Permalink
Merge pull request #5 from sunbeam-labs/4-containerize-and-version
Browse files Browse the repository at this point in the history
Containerize and version
  • Loading branch information
Ulthran authored Mar 5, 2024
2 parents 85e463b + 7510c0a commit 63ef925
Show file tree
Hide file tree
Showing 17 changed files with 323 additions and 100 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/conda_env_check.yml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Push to DockerHub

on:
workflow_call:

workflow_dispatch:

jobs:
build-and-push-to-dockerhub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get sbx version
shell: bash
run: |
SBX_VER=$(cat VERSION)
echo "SBX_VER=$SBX_VER" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: sunbeamlabs/sbx_assembly

- name: Build and push Docker image for annotation
uses: docker/build-push-action@v5
with:
context: .
file: envs/sbx_annotation.Dockerfile
push: true
tags: sunbeamlabs/sbx_assembly:${{ env.SBX_VER }}-annotation
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image for assembly
uses: docker/build-push-action@v5
with:
context: .
file: envs/sbx_assembly.Dockerfile
push: true
tags: sunbeamlabs/sbx_assembly:${{ env.SBX_VER }}-assembly
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image for coverage
uses: docker/build-push-action@v5
with:
context: .
file: envs/sbx_coverage.Dockerfile
push: true
tags: sunbeamlabs/sbx_assembly:${{ env.SBX_VER }}-coverage
labels: ${{ steps.meta.outputs.labels }}
25 changes: 0 additions & 25 deletions .github/workflows/linter.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Tests

on:
pull_request:
branches:
- main

jobs:
run-tests:
uses: ./.github/workflows/tests.yml
secrets: inherit

79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Release

on:
release:
types: [published]

workflow_dispatch:

jobs:
run-tests:
uses: ./.github/workflows/tests.yml
secrets: inherit

check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get sbx version
shell: bash
run: |
SBX_VER=$(cat VERSION)
echo "SBX_VER=$SBX_VER" >> $GITHUB_ENV
- id: get_version
uses: battila7/get-version-action@v2

- name: Check version
shell: bash
run: |
RELEASE_VERSION=${{ steps.get_version.outputs.version-without-v }}
echo "Release version: ${RELEASE_VERSION}"
echo "Sbx version: ${{ env.SBX_VER }}"
if [[ $RELEASE_VERSION == ${{ env.SBX_VER }} ]]; then
echo "Versions match, continuing..."
else
echo "Versions don't match, exiting..."
exit 1
fi
push-to-dockerhub:
uses: ./.github/workflows/docker.yml
secrets: inherit
needs:
- run-tests
- check-version

test-apptainer:
name: Apptainer Test
runs-on: ubuntu-latest
needs: push-to-dockerhub

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set test env
run: echo "SUNBEAM_TEST_PROFILE=apptainer" >> $GITHUB_ENV

- uses: eWaterCycle/setup-apptainer@v2
with:
apptainer-version: 1.1.2

- name: Test with Sunbeam
uses: sunbeam-labs/sbx_test_action@v1
with:
test-directory: ".tests/e2e/"

- name: Dump Logs
shell: bash
if: always()
run: tail -n +1 logs/*

- name: Dump Stats
shell: bash
if: always()
run: cat stats/*
68 changes: 55 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,73 @@
name: Tests

on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]
workflow_call:
workflow_dispatch:
schedule:
- cron: "0 13 * * 1"

jobs:
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Dependencies
run: pip install black snakefmt

- name: Run Linter
run: |
black --check .
snakefmt --check *.smk
test-unit:
name: Run Extension Unit Tests
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Dependencies
run: pip install pytest

- name: Run Unit Tests
run: true #pytest .tests/unit/
# This'll require having a lib within scripts with internal tests

test-e2e:
name: Test Extension with Sunbeam
runs-on: ubuntu-latest
needs:
- test-unit
- lint

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Test with Sunbeam
uses: sunbeam-labs/sbx_test_action@v1
- name: Dump Logs
shell: bash
if: always()
run: tail -n +1 logs/*

#- name: Dump Logs
# shell: bash
# if: always()
# run: tail -n +1 logs/*

- name: Dump Stats
shell: bash
if: always()
run: cat stats/*
#- name: Dump Stats
# shell: bash
# if: always()
# run: cat stats/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
33 changes: 0 additions & 33 deletions .tests/test_megahit.sh

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!-- Begin badges -->
[![Tests](https://github.com/sunbeam-labs/sbx_assembly/actions/workflows/tests.yml/badge.svg)](https://github.com/sunbeam-labs/sbx_assembly/actions/workflows/tests.yml)
[![Super-Linter](https://github.com/sunbeam-labs/sbx_assembly/actions/workflows/linter.yml/badge.svg)](https://github.com/sunbeam-labs/sbx_assembly/actions/workflows/linter.yml)
[![DockerHub](https://img.shields.io/docker/pulls/sunbeamlabs/sbx_assembly)](https://hub.docker.com/repository/docker/sunbeamlabs/sbx_assembly/)
<!-- End badges -->

A [Sunbeam](https://github.com/sunbeam-labs/sunbeam) extension for assembly of contigs using Megahit, gene annotation using Prodigal, and annotation using [Blast](https://blast.ncbi.nlm.nih.gov/Blast.cgi) and [Diamond](https://github.com/bbuchfink/diamond). It can also map reads to contigs and calculat per-base coverage using [Minimap2](https://github.com/lh3/minimap2) and [samtools](https://github.com/samtools/samtools).
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0
17 changes: 17 additions & 0 deletions envs/sbx_annotation.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM condaforge/mambaforge:latest

# Setup
WORKDIR /home/sbx_assembly_env

COPY envs/sbx_annotation.yml ./

# Install environment
RUN mamba env create --file sbx_annotation.yml --name sbx_annotation

ENV PATH="/opt/conda/envs/sbx_annotation/bin/:${PATH}"

# "Activate" the environment
SHELL ["conda", "run", "-n", "sbx_annotation", "/bin/bash", "-c"]

# Run
CMD "bash"
17 changes: 17 additions & 0 deletions envs/sbx_assembly.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM condaforge/mambaforge:latest

# Setup
WORKDIR /home/sbx_assembly_env

COPY envs/sbx_assembly.yml ./

# Install environment
RUN mamba env create --file sbx_assembly.yml --name sbx_assembly

ENV PATH="/opt/conda/envs/sbx_assembly/bin/:${PATH}"

# "Activate" the environment
SHELL ["conda", "run", "-n", "sbx_assembly", "/bin/bash", "-c"]

# Run
CMD "bash"
Loading

0 comments on commit 63ef925

Please sign in to comment.