Skip to content

Commit

Permalink
feat!: Use composite action with conda instead of docker action (#39)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Jan 21, 2025
1 parent 8fe6e99 commit e8018d7
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 39 deletions.
4 changes: 0 additions & 4 deletions Dockerfile

This file was deleted.

83 changes: 73 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,80 @@ inputs:
required: false
default: 'run'
show-disk-usage-on-error:
descriptions: Whether to return the used disk space on failing.
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: '*'
install-apptainer:
description: Install Apptainer (true/false)
required: false
default: false

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.directory }}
- ${{ inputs.snakefile }}
- ${{ inputs.args }}
- ${{ inputs.stagein }}
- ${{ inputs.task }}
- ${{ inputs.show-disk-usage-on-error }}
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 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 }}
EOF
- 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: Display snakemake version
shell: bash -el {0}
run: snakemake --version

- name: Run snakemake
if: ${{ inputs.task == 'run' }}
shell: bash -el {0}
run: |
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

25 changes: 0 additions & 25 deletions entrypoint.sh

This file was deleted.

0 comments on commit e8018d7

Please sign in to comment.