Skip to content

Commit 536cea3

Browse files
authored
Move from Miniconda to Miniforge (wtsi-npg#868)
* Move from Miniconda to Miniforge * Move from Miniconda to Miniforge
1 parent dbbb6e8 commit 536cea3

File tree

2 files changed

+63
-17
lines changed

2 files changed

+63
-17
lines changed

.github/workflows/run-tests.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ jobs:
1111
shell: bash -l -e -o pipefail {0}
1212

1313
env:
14-
PERL_CACHE: ~/perl5 # Perlbrew and CPAN modules installed here, cached
15-
NPG_LIB: ~/perl5npg # NPG modules installed here, not cached
16-
WSI_CONDA_CHANNEL: "https://dnap.cog.sanger.ac.uk/npg/conda/devel/generic"
14+
PERL_CACHE: $HOME/perl5 # Perlbrew and CPAN modules installed here, cached
15+
NPG_LIB: $HOME/perl5npg # NPG modules installed here, not cached
16+
WSI_CONDA_CHANNEL: https://dnap.cog.sanger.ac.uk/npg/conda/devel/generic
17+
CONDA_HOME: $HOME/conda
1718
CONDA_TEST_ENV: test-environment
1819
WTSI_NPG_GITHUB_URL: https://github.com/wtsi-npg
1920
WTSI_NPG_BUILD_BRANCH: ${{ github.base_ref || github.ref }}
@@ -24,6 +25,8 @@ jobs:
2425

2526
steps:
2627
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: '0'
2730

2831
- name: "Install OS dependencies"
2932
run: |
@@ -32,22 +35,32 @@ jobs:
3235
sudo apt-get remove -y nginx libgd3
3336
sudo apt-get install -y libgd-dev uuid-dev libgd-text-perl
3437
35-
- name: "Initialize Miniconda"
38+
- name: "Install Miniforge"
3639
run: |
37-
echo 'source $CONDA/etc/profile.d/conda.sh' >> "$HOME/.bash_profile"
40+
CONDA_HOME=${{ env.CONDA_HOME }} ./scripts/install_miniforge.sh
41+
echo 'source "${{ env.CONDA_HOME }}/etc/profile.d/conda.sh"' >> "$HOME/.bash_profile"
42+
43+
- name: "Cache Conda"
44+
id: miniforgeCache
45+
uses: actions/cache@v4
46+
with:
47+
path: |
48+
${{ env.CONDA_HOME }}/pkgs
49+
${{ env.CONDA_HOME }}/envs
50+
key: ${{ runner.os }}-build-miniforge
3851

3952
- name: "Install Conda packages"
4053
run: |
41-
conda config --prepend pkgs_dirs ~/conda/pkgs
42-
conda config --prepend envs_dirs ~/conda/envs
54+
conda config --prepend pkgs_dirs ${{ env.CONDA_HOME }}/pkgs
55+
conda config --prepend envs_dirs ${{ env.CONDA_HOME }}/envs
4356
4457
conda config --set auto_update_conda False
45-
conda config --prepend channels "$WSI_CONDA_CHANNEL"
58+
conda config --prepend channels "${{ env.WSI_CONDA_CHANNEL }}"
4659
conda info
4760
48-
conda create -y -n "$CONDA_TEST_ENV"
49-
conda install -y -n "$CONDA_TEST_ENV" baton
50-
conda install -y -n "$CONDA_TEST_ENV" samtools
61+
conda create -y -n "${{ env.CONDA_TEST_ENV }}"
62+
conda install -y -n "${{ env.CONDA_TEST_ENV }}" baton
63+
conda install -y -n "${{ env.CONDA_TEST_ENV }}" samtools
5164
5265
- name: "Cache Perl"
5366
id: cache-perl
@@ -77,14 +90,14 @@ jobs:
7790
- name: "Install Perl dependencies"
7891
run: |
7992
cpanm --local-lib=${{ env.PERL_CACHE }} local::lib
80-
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="$NPG_LIB")
93+
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="${{ env.NPG_LIB }}")
8194
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib)
8295
8396
cpanm --quiet --notest Module::Build
8497
cpanm --quiet --notest Net::SSLeay
8598
cpanm --quiet --notest https://github.com/chapmanb/vcftools-cpan/archive/v0.953.tar.gz
8699
87-
./scripts/install_wsi_dependencies.sh "$NPG_LIB" \
100+
./scripts/install_wsi_dependencies.sh "${{ env.NPG_LIB }}" \
88101
perl-dnap-utilities \
89102
perl-irods-wrap \
90103
ml_warehouse \
@@ -98,23 +111,23 @@ jobs:
98111
- name: "Log install failure"
99112
if: ${{ failure() }}
100113
run: |
101-
find ~/.cpanm/work -cmin -1 -name '*.log' -exec tail -n20 {} \;
114+
find $HOME/.cpanm/work -cmin -1 -name '*.log' -exec tail -n20 {} \;
102115
103116
- name: "Archive CPAN logs on failure"
104117
if: ${{ failure() }}
105118
uses: actions/upload-artifact@v4
106119
with:
107120
name: cpan_log
108-
path: ~/.cpanm/work/*/build.log
121+
path: $HOME/.cpanm/work/*/build.log
109122
retention-days: 5
110123

111124
- name: "Run tests"
112125
run: |
113-
conda activate "$CONDA_TEST_ENV"
126+
conda activate "${{ env.CONDA_TEST_ENV }}"
114127
conda info --envs
115128
116129
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib)
117-
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="$NPG_LIB")
130+
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="${{ env.NPG_LIB }}")
118131
119132
export TEST_AUTHOR=1
120133
perl Build.PL

scripts/install_miniforge.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
#
3+
# Once installed, the Conda environment can be activated by running:
4+
#
5+
# source $CONDA_HOME/etc/profile.d/conda.sh
6+
#
7+
# conda activate
8+
9+
set -ex
10+
11+
MINIFORGE_VERSION="24.9.0-0"
12+
MINIFORGE_SHA256="77fb505f6266ffa1b5d59604cf6ba25948627e908928cbff148813957b1c28af"
13+
14+
CONDA_HOME=${CONDA_HOME:="$HOME/conda"}
15+
export CONDA_HOME
16+
17+
CONDARC="$HOME/.condarc"
18+
export CONDARC
19+
20+
cat <<EOF > "$CONDARC"
21+
auto_update_conda: false
22+
always_yes: true
23+
ssl_verify: true
24+
show_channel_urls: true
25+
26+
channels:
27+
- conda-forge
28+
EOF
29+
30+
curl -sSL "https://github.com/conda-forge/miniforge/releases/download/${MINIFORGE_VERSION}/Mambaforge-${MINIFORGE_VERSION}-Linux-x86_64.sh" -o ./miniforge.sh
31+
sha256sum ./miniforge.sh | grep "$MINIFORGE_SHA256"
32+
/bin/bash ./miniforge.sh -b -p "$CONDA_HOME"
33+
rm ./miniforge.sh

0 commit comments

Comments
 (0)