diff --git a/.github/workflows/snakemake.yml b/.github/workflows/snakemake.yml new file mode 100644 index 0000000..a2286e4 --- /dev/null +++ b/.github/workflows/snakemake.yml @@ -0,0 +1,60 @@ +name: Run Snakemake Workflow + +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + snakemake: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Miniforge + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-variant: Miniforge3 + miniforge-version: latest + activate-environment: snakemake + use-mamba: true + + - name: Install mamba + shell: bash -el {0} + run: | + conda install -n base -c conda-forge mamba + + - name: Install Snakemake + shell: bash -el {0} + run: | + mamba install -c conda-forge -c bioconda snakemake + + - name: Run Snakemake workflow + shell: bash -el {0} + run: | + cd workflow + snakemake --use-conda --cores 1 + + - name: Check logs + shell: bash -el {0} + run: | + tail -1000 log/*log + # cat workflow/output/hello_output.txt + # if [ "$(cat workflow/output/hello_output.txt)" = "Hello World!" ]; then + # echo "✓ Output verified successfully!" + # else + # echo "✗ Output verification failed!" + # exit 1 + # fi + + - name: Upload output artifact + uses: actions/upload-artifact@v4 + if: always() + with: + name: workflow-output + path: workflow/output/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2e21b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build/ +output/ +.snakemake/ +_codeql_detected_source_root +src/_codeql_build_dir/ diff --git a/README.md b/README.md index 69082c7..0aa4b4c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,39 @@ # drab + RNA-seq count tables, revisited + +### Structure + +- `src/`: Contains C++ source code and CMakeLists.txt +- `env/`: Contains Conda environment specifications +- `workflow/`: Contains Snakefile for build automation + +### Running with snmk + +To build and run the example using Snakemake: + +```bash +cd workflow +snakemake --use-conda --cores 1 +``` + +This will: +1. Create a conda environment with cmake and g++ +2. Compile the C++ code +3. Run the executable and save output to `output/hello_output.txt` + +### Building `src` + +To build manually without Snakemake: + +```bash +mkdir -p build +cd build +cmake ../src +cmake --build . +./hello +``` + +### CI/CD + +- `snakemake.yml` to run the workflow (serially) diff --git a/env/build.yaml b/env/build.yaml new file mode 100644 index 0000000..ba76db2 --- /dev/null +++ b/env/build.yaml @@ -0,0 +1,7 @@ +channels: + - conda-forge + - bioconda + - nodefaults +dependencies: + - cmake>=4.1 + - cxx-compiler diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..9e27484 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.10) + +project(HelloWorld) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +add_executable(hello hello.cpp) diff --git a/src/hello.cpp b/src/hello.cpp new file mode 100644 index 0000000..ff68290 --- /dev/null +++ b/src/hello.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello World!" << std::endl; + return 0; +} diff --git a/workflow/Snakefile b/workflow/Snakefile new file mode 100644 index 0000000..a2d7e7d --- /dev/null +++ b/workflow/Snakefile @@ -0,0 +1,38 @@ +#!/usr/bin/env snakemake -s + +rule all: + input: + "output/hello_output.txt" + +rule compile: + conda: + "../env/build.yaml" + input: + cpp="src/hello.cpp", + cmake="src/CMakeLists.txt" + log: + "../log/compile.log" + output: + "build/hello" + shell: + """ + mkdir -p build log + cd build + cmake ../src &> {log} + cmake --build . &>> {log} + """ + +rule run: + conda: + "../env/build.yaml" + input: + "build/hello" + output: + "output/hello_output.txt" + log: + "log/run.log" + shell: + """ + mkdir -p output + {input} > {output} &> {log} + """ diff --git a/workflow/src b/workflow/src new file mode 120000 index 0000000..e057607 --- /dev/null +++ b/workflow/src @@ -0,0 +1 @@ +../src/ \ No newline at end of file