Skip to content

Commit

Permalink
some cleaning, adding dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel committed Aug 29, 2024
1 parent 2719e18 commit f732431
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ jobs:
steps:
- name : install plumed
uses: Iximiel/install-plumed@main
with:
modules: 'reset'
dependency_path: '$GITHUB_WORKSPACE/_data/'
id: plumed
- name: run plumed
run: |
echo ${{ steps.plumed.outputs.path }}
head ${{ steps.plumed.outputs.dependency_path }}
plumed --version
test_Stable:
Expand Down
17 changes: 10 additions & 7 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ inputs:
description: 'The version of plumed to install (default to master)'
required: false
default: ''
program_name:
description: 'The name of the program to install'
required: false
default: 'plumed'
suffix:
description: 'Suffix for the program name'
required: false
default: ''
prefix:
description: 'The installation prefix'
required: false
default: '~/opt/'
default: '~/opt'
extra_options:
description: 'Extra options for installing plumed'
required: false
Expand All @@ -37,10 +33,17 @@ inputs:
description: 'C++ compiler'
required: false
default: 'g++'
dependency_path:
description: 'Path where to store "extradeps$version.json"'
required: false
default: ''
outputs:
path:
plumed_prefx:
description: "Plumed executable path"
value: ${{ steps.installation.outputs.plumed_path }}
depencies:
description: "Plumed dependency json file"
value: ${{ steps.installation.outputs.depencies }}
runs:
using: "composite"
steps:
Expand All @@ -59,10 +62,10 @@ runs:
env:
REPO: ${{ inputs.repository }}
VERSION: ${{ inputs.version }}
PROGRAM_NAME: ${{ inputs.program_name }}
SUFFIX: ${{ inputs.suffix }}
PREFIX: ${{ inputs.prefix }}
EXTRA_OPTIONS: ${{ inputs.extra_options }}
MODULES: ${{ inputs.modules }}
CC: ${{ inputs.CC }}
CXX: ${{ inputs.CXX }}
DEPPATH: ${{ inputs.dependency_path }}
48 changes: 29 additions & 19 deletions install-plumed.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
#! /bin/bash

# To me: the enviromental variable I am using as input are in CAPS,
# if I modify a variable is in lower case

cat <<EOF
REPO="$REPO"
VERSION="$VERSION"
PROGRAM_NAME="$PROGRAM_NAME"
SUFFIX="$SUFFIX"
PREFIX="$PREFIX"
EOF

cd "$(mktemp -dt plumed.XXXXXX)" || {
echo "Failed to create tempdir"
exit 1
}

git clone $REPO
cd plumed2
git clone "$REPO" >>/dev/null
cd plumed2 || {
echo "Failed to cd into plumed2"
exit 1
}

version=$VERSION

if [[ -n "$VERSION" ]]; then
echo "installing plumed $VERSION"
if [[ -n "$version" ]]; then
echo "installing plumed $version"
else
VERSION=$(git tag --sort=version:refname |
version=$(git tag --sort=version:refname |
grep '^v2\.[0-9][0-9]*\.[0-9][0-9]*' |
tail -n 1)
echo "installing latest stable plumed $VERSION"
echo "installing latest stable plumed $version"
fi

plumed_options="$EXTRA_OPTIONS"
program_name=plumed
if [[ -n "$SUFFIX" ]]; then
plumed_options="$plumed_options --program-suffix=\"$SUFFIX\""
program_name=$program_name$SUFFIX
fi

if [[ -n "$PREFIX" ]]; then
Expand All @@ -37,10 +45,11 @@ if [[ -n "$MODULES" ]]; then
plumed_options="$plumed_options --enable-modules=$MODULES"
fi

#cheking out to $VERSION before compiling the dependency json for this $VERSION
git checkout $VERSION
#cheking out to $version before compiling the dependency json for this $version
git checkout $version

if [[ $SETDEPENDENCIES ]]; then
if [[ -n $DEPPATH ]]; then
depencies_file="${DEPPATH}/_data/extradeps$version.json"
# This gets all the dependency information in plumed
{
firstline=""
Expand Down Expand Up @@ -71,18 +80,19 @@ if [[ $SETDEPENDENCIES ]]; then
firstline=",\n"
done
echo -e '\n}'
} >"$GITHUB_WORKSPACE/_data/extradeps$VERSION.json"
} >"$depencies_file"
echo "depencies=$depencies_file" >>$GITHUB_OUTPUT
fi
hash=$(git rev-parse HEAD)

if [[ -f $HOME/opt/lib/$PROGRAM_NAME/$hash ]]; then
if [[ -f ${PREFIX}/lib/$program_name/$hash ]]; then
echo "ALREADY AVAILABLE, NO NEED TO REINSTALL"
else
#remove the conflicting old installation
rm -fr "$PREFIX/lib/$PROGRAM_NAME"
rm -fr "$PREFIX/opt/bin/$PROGRAM_NAME"
rm -fr "$PREFIX/opt/include/$PROGRAM_NAME"
rm -fr "$PREFIX"/opt/lib/lib$PROGRAM_NAME.so*
rm -fr "$PREFIX/lib/$program_name"
rm -fr "$PREFIX/bin/$program_name"
rm -fr "$PREFIX/include/$program_name"
rm -fr "$PREFIX"/lib/lib$program_name.so*

cat <<EOF
./configure --prefix="$HOME/opt" \
Expand All @@ -95,8 +105,8 @@ else
make -j 5
make install
touch "$HOME/opt/lib/$PROGRAM_NAME/$hash"
touch "${PREFIX}/lib/$program_name/$hash"
EOF
fi

echo "plumed_path=${PREFIX}/bin" >>$GITHUB_OUTPUT
echo "plumed_path=${PREFIX}" >>$GITHUB_OUTPUT

0 comments on commit f732431

Please sign in to comment.