-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathaction.yml
More file actions
120 lines (109 loc) · 3.78 KB
/
action.yml
File metadata and controls
120 lines (109 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: snakemake
description: Run Snakemake on the repository
branding:
icon: git-pull-request
color: green
inputs:
directory:
description: Working directory for the execution
required: true
default: .test
snakefile:
description: Snakefile containing the workflow description
default: Snakefile
args:
description: Additional Snakemake arguments to use
required: false
default: ""
stagein:
description: Additional steps to prepare the workflow for execution
required: false
default: ""
task:
description: Whether to run Snakemake or to generate a container image specification.
required: false
default: "run"
show-disk-usage-on-error:
description: Whether to return the used disk space on failing.
required: false
default: "false"
snakemake-version:
description: |
Snakemake version to use. If not specified, uses latest version. Pin a specific version (e.g., '8.25.5') for reproducibility.
required: false
default: "*"
snakemake-branch:
description: |
Optional Snakemake git branch to install from https://github.com/snakemake/snakemake.
If set, this takes precedence over snakemake-version and Snakemake is installed via pip.
required: false
default: ""
install-apptainer:
description: Install Apptainer (true/false)
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Validate inputs
if: ${{ ! (inputs.task == 'containerize' || inputs.task == 'run' )}}
shell: bash -el {0}
run: |
echo 'Invalid value for "task": "${{ inputs.task }}". Options: "containerize", "run".'
exit 1
- name: Install Apptainer
if: ${{ inputs.install-apptainer == 'true' }}
shell: bash -el {0}
run: |
if ! command -v apt-get &> /dev/null; then
echo "Error: This action currently supports Apptainer installation only on Ubuntu runners"
exit 1
fi
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt-get update
sudo apt-get install -y apptainer
- name: Prepare .snakemake.environment.yaml
shell: bash -el {0}
run: |
cat <<EOF > .snakemake.environment.yaml
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- snakemake ==${{ inputs.snakemake-version }}
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
channels: conda-forge,bioconda
channel-priority: strict
miniforge-version: latest
environment-file: .snakemake.environment.yaml
activate-environment: snakemake
- name: Install snakemake from git branch
if: ${{ inputs.snakemake-branch != '' }}
shell: bash -el {0}
run: |
pip install "git+https://github.com/snakemake/snakemake@${{ inputs.snakemake-branch }}"
- name: Display snakemake version
shell: bash -el {0}
run: snakemake --version
- name: Run snakemake
if: ${{ inputs.task == 'run' }}
shell: bash -el {0}
run: |
${{ inputs.stagein }}
snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}
if [[ "$?" -ne 0 ]]; then
if [[ ${{ inputs.show-disk-usage-on-error }} = true ]]; then
# return disk usage and space on failing
df -h
printf "disk usage working directory"
du -h -d3 ${{ inputs.directory }}
fi
exit 1
fi
- name: Containerize snakemake
if: ${{ inputs.task == 'containerize' }}
shell: bash -el {0}
run: snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }} --containerize > Dockerfile