Skip to content

Commit e8018d7

Browse files
tedilcoderabbitai[bot]johanneskoester
authored
feat!: Use composite action with conda instead of docker action (#39)
* feat: Use composite action instead of docker action * fix indentation * swap quotes * include shell * move check for containerize/run to top * check show-disk-usage-on-error * fix du for directory * rename env to 'snakemake' * Update action.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * simply use '*' as default for snakemake version * show installed snakemake version by default * add apptainer installation option * add missing 'shell: …' * use here string * I guess the yaml parser does not support |8 notation * Delete environment.yaml.template * Update action.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Johannes Köster <[email protected]>
1 parent 8fe6e99 commit e8018d7

File tree

3 files changed

+73
-39
lines changed

3 files changed

+73
-39
lines changed

Dockerfile

Lines changed: 0 additions & 4 deletions
This file was deleted.

action.yml

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,80 @@ inputs:
2727
required: false
2828
default: 'run'
2929
show-disk-usage-on-error:
30-
descriptions: Whether to return the used disk space on failing.
30+
description: Whether to return the used disk space on failing.
31+
required: false
32+
default: false
33+
snakemake-version:
34+
description: Snakemake version to use. If not specified, uses latest version. Pin a specific version (e.g., '8.25.5') for reproducibility.
35+
required: false
36+
default: '*'
37+
install-apptainer:
38+
description: Install Apptainer (true/false)
3139
required: false
3240
default: false
3341

3442
runs:
35-
using: 'docker'
36-
image: 'Dockerfile'
37-
args:
38-
- ${{ inputs.directory }}
39-
- ${{ inputs.snakefile }}
40-
- ${{ inputs.args }}
41-
- ${{ inputs.stagein }}
42-
- ${{ inputs.task }}
43-
- ${{ inputs.show-disk-usage-on-error }}
43+
using: 'composite'
44+
steps:
45+
- name: Validate inputs
46+
if: ${{ ! (inputs.task == 'containerize' || inputs.task == 'run' )}}
47+
shell: bash -el {0}
48+
run: |
49+
echo 'Invalid value for "task": "${{ inputs.task }}". Options: "containerize", "run".'
50+
exit 1
51+
52+
- name: Install Apptainer
53+
if: ${{ inputs.install-apptainer == 'true' }}
54+
shell: bash -el {0}
55+
run: |
56+
if ! command -v apt-get &> /dev/null; then
57+
echo "Error: This action currently supports Apptainer installation only on Ubuntu runners"
58+
exit 1
59+
fi
60+
sudo apt-get update
61+
sudo apt-get install -y apptainer
62+
- name: Prepare .snakemake.environment.yaml
63+
shell: bash -el {0}
64+
run: |
65+
cat <<EOF > .snakemake.environment.yaml
66+
channels:
67+
- conda-forge
68+
- bioconda
69+
- nodefaults
70+
dependencies:
71+
- snakemake ==${{ inputs.snakemake-version }}
72+
EOF
73+
74+
- name: Setup conda
75+
uses: conda-incubator/setup-miniconda@v3
76+
with:
77+
channels: conda-forge,bioconda
78+
channel-priority: strict
79+
miniforge-version: latest
80+
environment-file: .snakemake.environment.yaml
81+
activate-environment: snakemake
82+
83+
- name: Display snakemake version
84+
shell: bash -el {0}
85+
run: snakemake --version
86+
87+
- name: Run snakemake
88+
if: ${{ inputs.task == 'run' }}
89+
shell: bash -el {0}
90+
run: |
91+
snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}
92+
if [[ "$?" -ne 0 ]]; then
93+
if [[ ${{ inputs.show-disk-usage-on-error }} = true ]]; then
94+
# return disk usage and space on failing
95+
df -h
96+
printf "disk usage working directory"
97+
du -h -d3 ${{ inputs.directory }}
98+
fi
99+
exit 1
100+
fi
101+
102+
- name: Containerize snakemake
103+
if: ${{ inputs.task == 'containerize' }}
104+
shell: bash -el {0}
105+
run: snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }} --containerize > Dockerfile
106+

entrypoint.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)