Skip to content

Commit 9975fbe

Browse files
Copilotimallona
andauthored
Init with a dummy C++ code + associated Snakefile, with a bundled action
* Initial plan * Add C++ hello world with Snakemake workflow and conda environment Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> * Fix Snakefile build logic and update README with usage documentation Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> * Add GitHub Actions workflow for Snakemake execution Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> * Add explicit permissions to GitHub workflow for security Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> * Remove CodeQL build artifacts and update .gitignore Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> * Fix paths * Fix CI/CD workflow to use Mambaforge for mamba availability Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> * Use Miniforge3 instead of deprecated Mambaforge and explicitly install mamba Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> * Remove verification --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: imallona <8280371+imallona@users.noreply.github.com> Co-authored-by: Izaskun Mallona <izaskun.mallona@gmail.com>
1 parent 1d10b99 commit 9975fbe

8 files changed

Lines changed: 162 additions & 0 deletions

File tree

.github/workflows/snakemake.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Run Snakemake Workflow
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
snakemake:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Miniforge
20+
uses: conda-incubator/setup-miniconda@v3
21+
with:
22+
miniforge-variant: Miniforge3
23+
miniforge-version: latest
24+
activate-environment: snakemake
25+
use-mamba: true
26+
27+
- name: Install mamba
28+
shell: bash -el {0}
29+
run: |
30+
conda install -n base -c conda-forge mamba
31+
32+
- name: Install Snakemake
33+
shell: bash -el {0}
34+
run: |
35+
mamba install -c conda-forge -c bioconda snakemake
36+
37+
- name: Run Snakemake workflow
38+
shell: bash -el {0}
39+
run: |
40+
cd workflow
41+
snakemake --use-conda --cores 1
42+
43+
- name: Check logs
44+
shell: bash -el {0}
45+
run: |
46+
tail -1000 log/*log
47+
# cat workflow/output/hello_output.txt
48+
# if [ "$(cat workflow/output/hello_output.txt)" = "Hello World!" ]; then
49+
# echo "✓ Output verified successfully!"
50+
# else
51+
# echo "✗ Output verification failed!"
52+
# exit 1
53+
# fi
54+
55+
- name: Upload output artifact
56+
uses: actions/upload-artifact@v4
57+
if: always()
58+
with:
59+
name: workflow-output
60+
path: workflow/output/

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
output/
3+
.snakemake/
4+
_codeql_detected_source_root
5+
src/_codeql_build_dir/

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
11
# drab
2+
23
RNA-seq count tables, revisited
4+
5+
### Structure
6+
7+
- `src/`: Contains C++ source code and CMakeLists.txt
8+
- `env/`: Contains Conda environment specifications
9+
- `workflow/`: Contains Snakefile for build automation
10+
11+
### Running with snmk
12+
13+
To build and run the example using Snakemake:
14+
15+
```bash
16+
cd workflow
17+
snakemake --use-conda --cores 1
18+
```
19+
20+
This will:
21+
1. Create a conda environment with cmake and g++
22+
2. Compile the C++ code
23+
3. Run the executable and save output to `output/hello_output.txt`
24+
25+
### Building `src`
26+
27+
To build manually without Snakemake:
28+
29+
```bash
30+
mkdir -p build
31+
cd build
32+
cmake ../src
33+
cmake --build .
34+
./hello
35+
```
36+
37+
### CI/CD
38+
39+
- `snakemake.yml` to run the workflow (serially)

env/build.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
channels:
2+
- conda-forge
3+
- bioconda
4+
- nodefaults
5+
dependencies:
6+
- cmake>=4.1
7+
- cxx-compiler

src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project(HelloWorld)
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_STANDARD_REQUIRED True)
7+
8+
add_executable(hello hello.cpp)

src/hello.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iostream>
2+
3+
int main() {
4+
std::cout << "Hello World!" << std::endl;
5+
return 0;
6+
}

workflow/Snakefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env snakemake -s
2+
3+
rule all:
4+
input:
5+
"output/hello_output.txt"
6+
7+
rule compile:
8+
conda:
9+
"../env/build.yaml"
10+
input:
11+
cpp="src/hello.cpp",
12+
cmake="src/CMakeLists.txt"
13+
log:
14+
"../log/compile.log"
15+
output:
16+
"build/hello"
17+
shell:
18+
"""
19+
mkdir -p build log
20+
cd build
21+
cmake ../src &> {log}
22+
cmake --build . &>> {log}
23+
"""
24+
25+
rule run:
26+
conda:
27+
"../env/build.yaml"
28+
input:
29+
"build/hello"
30+
output:
31+
"output/hello_output.txt"
32+
log:
33+
"log/run.log"
34+
shell:
35+
"""
36+
mkdir -p output
37+
{input} > {output} &> {log}
38+
"""

workflow/src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../src/

0 commit comments

Comments
 (0)