Skip to content

Commit

Permalink
fix: snakemake and mamba deployment (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Jan 19, 2023
1 parent 1bd2694 commit 4c64b96
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 28 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/main.yml
Expand Up @@ -34,28 +34,30 @@ jobs:
submodules: recursive
fetch-depth: 0

- name: Setup mamba
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: snakemake
channels: "conda-forge, bioconda"
miniforge-variant: Mambaforge
miniforge-version: latest

- name: Setup Snakemake environment
shell: bash -el {0}
run: |
# ensure that mamba is happy to write into the cache
sudo chown -R runner:docker /usr/share/miniconda/pkgs/cache
conda install -c conda-forge mamba --quiet
export PATH="/usr/share/miniconda/bin:$PATH"
mamba create -c bioconda -c conda-forge --quiet -y --name snakemake snakemake-minimal pytest
conda config --set channel_priority strict
mamba install -n snakemake -y snakemake-minimal pytest
- name: Fetch master
if: github.ref != 'refs/heads/master'
run: |
git fetch origin master
- name: Run tests
shell: bash -el {0}
env:
DIFF_MASTER: ${{ github.event_name == 'pull_request' }}
DIFF_LAST_COMMIT: ${{ github.ref == 'refs/heads/master' }}
run: |
# activate conda env
export PATH="/usr/share/miniconda/bin:$PATH"
source activate snakemake
# run tests
pytest test.py -v
43 changes: 29 additions & 14 deletions .github/workflows/qc.yml
Expand Up @@ -8,45 +8,60 @@ jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Setup mamba
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: fmt
channels: "conda-forge, bioconda"
miniforge-variant: Mambaforge
miniforge-version: latest

- name: Setup environment
run: conda create --quiet -c bioconda -c conda-forge --name fmt black snakefmt
shell: bash -el {0}
run: |
conda config --set channel_priority strict
mamba install -n fmt -y black snakefmt
- name: Check Python formatting
shell: bash -el {0}
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate fmt
black --check */*/*/wrapper.py */*/wrapper.py
# TODO reactivate once comment errors are fixed
# - name: Check Snakemake formatting
# run: |
# export PATH="/usr/share/miniconda/bin:$PATH"
# source activate fmt
# snakefmt --check $(git diff origin/master --name-only | grep Snakefile)

linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Setup mamba
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: snakemake
channels: "conda-forge, bioconda"
miniforge-variant: Mambaforge
miniforge-version: latest

- name: Setup Snakemake environment
shell: bash -el {0}
run: |
# ensure that mamba is happy to write into the cache
sudo chown -R runner:docker /usr/share/miniconda/pkgs/cache
conda install -c conda-forge mamba --quiet
export PATH="/usr/share/miniconda/bin:$PATH"
mamba create -c bioconda -c conda-forge --quiet -y --name snakemake snakemake-minimal
conda config --set channel_priority strict
mamba install -n snakemake -y snakemake-minimal snakemake
- name: Fetch master
run: |
git fetch origin master
- name: Linting
shell: bash -el {0}
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate snakemake
declare -i ERRORS=0
# get all modified and added files, not those that are deleted
for f in $(git diff origin/master --name-only --diff-filter=d | grep Snakefile)
Expand Down
8 changes: 3 additions & 5 deletions test.py
Expand Up @@ -3169,18 +3169,16 @@ def test_star_align():
os.makedirs("bio/star/align/test/index", exist_ok=True)
try:
subprocess.check_call(
"conda env create " "--file bio/star/align/environment.yaml " "-n star-env",
"mamba env create --file bio/star/align/environment.yaml -n star-env",
shell=True,
executable="/bin/bash",
)
subprocess.check_call(
"source activate star-env; STAR --genomeDir "
"bash -l -c 'source $(dirname $(dirname $(which mamba)))/bin/activate star-env; STAR --genomeDir "
"bio/star/align/test/index "
"--genomeFastaFiles bio/star/align/test/genome.fasta "
"--runMode genomeGenerate "
"--genomeSAindexNbases 8",
"--genomeSAindexNbases 8'",
shell=True,
executable="/bin/bash",
)
finally:
shutil.rmtree("star-env", ignore_errors=True)
Expand Down

0 comments on commit 4c64b96

Please sign in to comment.