cache netcdf-c and cpptraj #285
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python Package using Conda | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
# Enable bash login shell to activate conda environment | |
shell: bash -l {0} | |
strategy: | |
max-parallel: 5 | |
matrix: | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache conda | |
uses: actions/cache@v4 | |
env: | |
CACHE_NUMBER: 1 # Increase this value to reset cache if environment.yml has changed | |
with: | |
path: ~/conda_pkgs_dir | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
- name: Install prerequisite packages | |
run: | | |
sudo apt-get install -y gfortran libbz2-dev libblas-dev liblapack-dev libfftw3-dev clang cmake-data cmake | |
- name: Get latest cpptraj commit hash | |
id: get-hash | |
run: | | |
latest_hash=$(git ls-remote https://github.com/Amber-MD/cpptraj.git refs/heads/master | awk '{print $1}') | |
echo "::set-output name=hash::$latest_hash" | |
- name: Cache cpptraj | |
uses: actions/cache@v4 | |
with: | |
path: ~/cpptraj | |
key: ${{ runner.os }}-cpptraj-${{ steps.get-hash.outputs.hash }} | |
restore-keys: | | |
${{ runner.os }}-cpptraj- | |
- name: Cache netcdf-c | |
uses: actions/cache@v4 | |
with: | |
path: ~/netcdf-c | |
key: ${{ runner.os }}-netcdf-c-${{ steps.get-hash.outputs.hash }} | |
restore-keys: | | |
${{ runner.os }}-netcdf-c- | |
- name: Install CPPTRAJ dependencies | |
run: | | |
if [ ! -d "$HOME/netcdf-c" ]; then | |
curl -OL https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | |
tar -zxf v4.9.2.tar.gz | |
cd netcdf-c-4.9.2 | |
./configure --disable-byterange --disable-libxml2 --disable-netcdf-4 --disable-dap --disable-doxygen --prefix=$HOME/netcdf-c | |
make -j2 | |
make install | |
cd .. | |
fi | |
export PATH=$HOME/netcdf-c/bin:$PATH | |
- name: Install cpptraj | |
run: | | |
if [ ! -d "$HOME/cpptraj" ]; then | |
CWD=$(pwd) | |
git clone https://github.com/Amber-MD/cpptraj $HOME/cpptraj | |
cd $HOME/cpptraj | |
export CPPTRAJHOME=`pwd` | |
yes | ./configure -shared -openmp gnu | |
make libcpptraj | |
cd $CWD | |
fi | |
- name: Set up Miniconda # Do this after installing cpptraj to avoid "yes: standard output: Broken pipe" error | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
auto-activate-base: false | |
activate-environment: pytraj-gha | |
environment-file: environment.yml | |
mamba-version: "*" | |
channels: conda-forge | |
channel-priority: true | |
python-version: ${{ matrix.python-version }} | |
- name: Check conda environment | |
run: | | |
conda --version | |
which conda | |
which python | |
which python3 | |
- name: Install pytraj | |
run: | | |
which python3 | |
python3 setup.py install | |
- name: Test with pytest | |
run: | | |
export CPPTRAJHOME=$HOME/cpptraj && cd tests && pytest -vs --ignore=test_parallel_pmap --ignore=test_run_mpi.py --ignore=test_energy/test_pmap_sander.py --ignore=test_parallel_mpi --ignore=test_actionlist.py |