Skip to content

Commit

Permalink
Merge pull request #892 from kjsanger/feature/anaconda-to-miniforge
Browse files Browse the repository at this point in the history
Move from Miniconda to Miniforge
  • Loading branch information
mksanger authored Nov 26, 2024
2 parents 9c3d68b + 3943855 commit 1283251
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 26 deletions.
53 changes: 27 additions & 26 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ jobs:
shell: bash -l -e -o pipefail {0}

env:
PERL_CACHE: ~/perl5 # Perlbrew and CPAN modules installed here, cached
NPG_LIB: ~/perl5npg # NPG modules installed here, not cached
WSI_CONDA_CHANNEL: "https://dnap.cog.sanger.ac.uk/npg/conda/devel/generic"
PERL_CACHE: $HOME/perl5 # Perlbrew and CPAN modules installed here, cached
NPG_LIB: $HOME/perl5npg # NPG modules installed here, not cached
WSI_CONDA_CHANNEL: https://dnap.cog.sanger.ac.uk/npg/conda/devel/generic
CONDA_TEST_ENV: test-environment
NPM_CONFIG_PREFIX: "$HOME/.npm-global"
CONDA_HOME: $HOME/conda
NPM_CONFIG_PREFIX: $HOME/.npm-global
WTSI_NPG_GITHUB_URL: https://github.com/wtsi-npg
WTSI_NPG_BUILD_BRANCH: ${GITHUB_HEAD_REF}
WTSI_NPG_BUILD_BRANCH: ${{ github.base_ref || github.ref }}

strategy:
fail-fast: false
Expand All @@ -35,35 +36,34 @@ jobs:
sudo apt-get remove -y nginx libgd3
sudo apt-get install -y libgd-dev uuid-dev libgd-text-perl
- name: "Initialize Miniconda"
- name: "Install Miniforge"
run: |
echo 'source $CONDA/etc/profile.d/conda.sh' >> "$HOME/.bash_profile"
CONDA_HOME=${{ env.CONDA_HOME }} ./scripts/install_miniforge.sh
echo 'source "${{ env.CONDA_HOME }}/etc/profile.d/conda.sh"' >> "$HOME/.bash_profile"
- name: "Cache Conda"
id: minicondaCache
id: miniforgeCache
uses: actions/cache@v4
with:
path: |
~/conda/pkgs
~/conda/envs
key: ${{ runner.os }}-build-miniconda
${{ env.CONDA_HOME }}/pkgs
${{ env.CONDA_HOME }}/envs
key: ${{ runner.os }}-build-miniforge

- name: "Install Conda packages"
env:
CONDA_TEST_ENV: test-environment
run: |
conda config --prepend pkgs_dirs ~/conda/pkgs
conda config --prepend envs_dirs ~/conda/envs
conda config --prepend pkgs_dirs ${{ env.CONDA_HOME }}/pkgs
conda config --prepend envs_dirs ${{ env.CONDA_HOME }}/envs
conda config --set auto_update_conda False
conda config --prepend channels "$WSI_CONDA_CHANNEL"
conda config --append channels conda-forge
conda config --prepend channels "${{ env.WSI_CONDA_CHANNEL }}"
conda info
conda create -y -n "$CONDA_TEST_ENV"
conda install -y -n "$CONDA_TEST_ENV" nodejs=="${{ matrix.node }}"
conda install -y -n "$CONDA_TEST_ENV" npg_qc_utils
conda install -y -n "$CONDA_TEST_ENV" baton
conda create -y -n "${{ env.CONDA_TEST_ENV }}"
conda install -y -n "${{ env.CONDA_TEST_ENV }}" nodejs=="${{ matrix.node }}"
conda install -y -n "${{ env.CONDA_TEST_ENV }}" npg_qc_utils
conda install -y -n "${{ env.CONDA_TEST_ENV }}" baton
- name: "Cache Perl"
id: cache-perl
Expand Down Expand Up @@ -92,18 +92,18 @@ jobs:
- name: "NPM"
run: |
mkdir -p "$NPM_CONFIG_PREFIX"
mkdir -p "${{ env.NPM_CONFIG_PREFIX }}"
- name: "Install Perl dependencies"
run: |
cpanm --local-lib=${{ env.PERL_CACHE }} local::lib
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="$NPG_LIB")
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="${{ env.NPG_LIB }}")
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib)
cpanm --quiet --notest LWP::Protocol::https
cpanm --quiet --notest https://github.com/chapmanb/vcftools-cpan/archive/v0.953.tar.gz
./scripts/install_wsi_dependencies.sh "$NPG_LIB" \
./scripts/install_wsi_dependencies.sh "${{ env.NPG_LIB }}" \
perl-dnap-utilities \
ml_warehouse \
npg_tracking \
Expand All @@ -119,14 +119,14 @@ jobs:
- name: "Log install failure"
if: ${{ failure() }}
run: |
find ~/.cpanm/work -cmin -1 -name '*.log' -exec tail -n20 {} \;
find $HOME/.cpanm/work -cmin -1 -name '*.log' -exec tail -n20 {} \;
- name: "Archive CPAN logs on failure"
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: cpan_log
path: ~/.cpanm/work/*/build.log
path: $HOME/.cpanm/work/*/build.log
retention-days: 5

- name: "Run tests"
Expand All @@ -135,7 +135,7 @@ jobs:
conda info --envs
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib)
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="$NPG_LIB")
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib="${{ env.NPG_LIB }}")
export PATH=$HOME/.nvm/versions/node/v${{ matrix.node }}/bin:$PATH
export TEST_AUTHOR=1
Expand All @@ -148,6 +148,7 @@ jobs:
pushd npg_qc_viewer
export PERL5LIB="$PERL5LIB:../lib"

perl Build.PL --installjsdeps
./Build
./Build test --verbose
Expand Down
33 changes: 33 additions & 0 deletions scripts/install_miniforge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
#
# Once installed, the Conda environment can be activated by running:
#
# source $CONDA_HOME/etc/profile.d/conda.sh
#
# conda activate

set -ex

MINIFORGE_VERSION="24.9.0-0"
MINIFORGE_SHA256="77fb505f6266ffa1b5d59604cf6ba25948627e908928cbff148813957b1c28af"

CONDA_HOME=${CONDA_HOME:="$HOME/conda"}
export CONDA_HOME

CONDARC="$HOME/.condarc"
export CONDARC

cat <<EOF > "$CONDARC"
auto_update_conda: false
always_yes: true
ssl_verify: true
show_channel_urls: true
channels:
- conda-forge
EOF

curl -sSL "https://github.com/conda-forge/miniforge/releases/download/${MINIFORGE_VERSION}/Mambaforge-${MINIFORGE_VERSION}-Linux-x86_64.sh" -o ./miniforge.sh
sha256sum ./miniforge.sh | grep "$MINIFORGE_SHA256"
/bin/bash ./miniforge.sh -b -p "$CONDA_HOME"
rm ./miniforge.sh

0 comments on commit 1283251

Please sign in to comment.