Do not depend on bc being installed #2
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
--- | |
# Check commits and incoming PRs that change scripts under cvmfs/. | |
name: Check CVMFS scripts | |
'on': | |
push: | |
paths: | |
- 'cvmfs/**' | |
pull_request: | |
paths: | |
- 'cvmfs/**' | |
types: | |
- opened | |
- reopened | |
- edited | |
- ready_for_review | |
- synchronize | |
permissions: {} | |
jobs: | |
alienv: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install prerequisites | |
run: | | |
sudo apt update -y | |
# python-ldap needs lib{ldap,sasl}2-dev | |
sudo apt install -y libldap2-dev libsasl2-dev \ | |
build-essential bison texinfo environment-modules \ | |
python3-dev python3-pip python3-setuptools python3-wheel | |
python3 -m pip install -r requirements.txt | |
- name: Install an old bash | |
run: | | |
# Install and configure an old bash | |
rm -rf ~/cached ~/scratch | |
mkdir -p ~/cached ~/scratch | |
curl -fSsL https://ftp.gnu.org/gnu/bash/bash-3.2.48.tar.gz | | |
tar -xzC ~/scratch | |
pushd ~/scratch/bash-3.2.48 | |
./configure "--prefix=$HOME/cached" | |
make -j4 | |
make install | |
popd | |
# Patch alienv and make it use our own, old, bash | |
sed -i "1s|^#\!/bin/bash|#\!$HOME/cached/bin/bash|" cvmfs/alienv | |
git --no-pager diff | |
- name: Install CVMFS | |
run: | | |
# Install and configure CVMFS | |
url=https://ecsft.cern.ch/dist/cvmfs/cvmfs-release/cvmfs-release-latest_all.deb | |
wget -q "$url" || case $? in | |
5) wget --no-check-certificate -q "$url";; | |
*) exit 1;; | |
esac | |
unset url | |
sudo dpkg -i cvmfs-release-latest_all.deb | |
rm -f cvmfs-release-latest_all.deb | |
sudo apt update -y | |
sudo apt install -y cvmfs-dev cvmfs libtcl8.6 libx11-6 | |
sudo mkdir -p /cvmfs/alice.cern.ch | |
sudo chown -R cvmfs:cvmfs /cvmfs | |
echo CVMFS_HTTP_PROXY=DIRECT | sudo tee /etc/cvmfs/default.local | |
sudo mount alice.cern.ch /cvmfs/alice.cern.ch -t cvmfs -o allow_other,grab_mountpoint | |
ls -l /cvmfs/alice.cern.ch | |
# Override remote alienv with ours | |
md5sum /cvmfs/alice.cern.ch/bin/alienv | |
md5sum "$PWD/cvmfs/alienv" | |
sudo mount --bind "$PWD/cvmfs/alienv" /cvmfs/alice.cern.ch/bin/alienv | |
md5sum /cvmfs/alice.cern.ch/bin/alienv | |
cmp /cvmfs/alice.cern.ch/bin/alienv "$PWD/cvmfs/alienv" | |
- name: Test alienv script | |
run: | | |
# Run the actual test | |
set -exo pipefail | |
pe () { printf '\033[31mERROR:\033[m %s\n' "$@" >&2; exit 1; } | |
pi () { printf '\033[34mINFO:\033[m %s\n' "$@" >&2; } | |
pt () { printf '\n\033[35m*** TEST: %s ***\033[m\n' "$@" >&2; } | |
pg () { printf '\033[32mSUCCESS:\033[m %s\n' "$@" >&2; } | |
# Check if required conditions to run the test are met | |
[ -d .git ] || pe "you must run from the Git repository root" | |
# We normally test `alienv` faked as being on CVMFS. For local tests | |
# we might want to override it | |
ALIENV=/cvmfs/alice.cern.ch/bin/alienv | |
pi "Testing alienv from $ALIENV" | |
# Overriding platform (not important for our tests) | |
export ALIENV_OVERRIDE_PLATFORM=el6-x86_64 | |
pi "Overriding platform to $ALIENV_OVERRIDE_PLATFORM" | |
for np in /tmp/alienv_bin /tmp/alienv_path/bin; do | |
pt "run alienv from a non-standard path ($np) with full symlink" | |
( mkdir -p "$np" | |
ln -nfs "$ALIENV" "$np/alienv" | |
# shellcheck disable=SC2030 | |
export PATH=$np:$PATH | |
ALIENV_DEBUG=1 alienv printenv AliPhysics/v5-09-59o-01_O2-1 | |
) || exit $? | |
done | |
np=/tmp/alienv_symlink/bin | |
pt "run alienv from a non-standard path ($np) with relative symlink" | |
( mkdir -p "$np" | |
ln -nfs "$(dn=$(dirname "$ALIENV"); while [ "$dn" != / ]; do dn=$(dirname "$dn"); printf ../; done)$ALIENV" "$np/alienv" | |
# shellcheck disable=SC2030,SC2031 | |
export PATH=$np:$PATH | |
ALIENV_DEBUG=1 alienv printenv AliPhysics/v5-09-59o-01_O2-1 | |
) || exit $? | |
unset np | |
# shellcheck disable=SC2031 | |
PATH=$(dirname "$ALIENV"):$PATH | |
export PATH | |
[ "$(command -v alienv)" = "$ALIENV" ] | |
pt "test package reordering" | |
(ALIENV_DEBUG=1 alienv setenv VO_ALICE@AliEn-Runtime::v2-19-le-21,VO_ALICE@ROOT::v5-34-30-alice7-2,VO_ALICE@AliPhysics::vAN-20170301-1 -c true 2>&1 || :) | | |
tee /dev/stderr | | |
grep 'normalized to AliPhysics/vAN-20170301-1 ROOT/v5-34-30-alice7-2 AliEn-Runtime/v2-19-le-21' | |
pt "test checkenv command with a successful combination" | |
alienv checkenv AliPhysics/vAN-20170301-1,AliRoot/v5-08-22-1 || | |
pe "expected 0, returned $?" | |
pt "test checkenv command with a faulty combination" | |
alienv checkenv AliPhysics/vAN-20170301-1,AliPhysics/vAN-20170201-1 2>&1 | tee log.txt && : | |
ec=$? | |
[ $ec -eq 1 ] || pe "expected 1, returned $ec" | |
unset ec | |
grep -q 'conflicting version' log.txt || | |
pe "could not find expected output message" | |
rm -f log.txt | |
pt "test checkenv command with dependencies from multiple platforms" | |
alienv checkenv AliGenerators/v20180424-1 || | |
pe "expected 0, returned $?" | |
# "alienv q" takes too long in a GitHub workflow (>45 min). | |
# pt "list AliPhysics packages" | |
# alienv q | grep AliPhysics | tail -n5 | |
alienv_test () { | |
local method=$1 package=$2 command=$3 | |
case $method in | |
setenv) alienv setenv "$package" -c "$command";; | |
printenv) (eval "$(alienv printenv "$package")"; $command);; | |
enter) (echo 'echo TEST=`'"$command"'`' | alienv enter "$package" | | |
grep '^TEST=' | cut -d= -f2-);; | |
esac | |
} | |
# Define an "old" and "new" version of AliPhysics to check for. "new" has AliEn | |
# as dependency, "old" does not | |
OLD_VER=AliPhysics/vAN-20150131 NEW_VER=AliPhysics/vAN-20170301-1 | |
pt "check that the legacy AliEn package can be loaded" | |
for method in setenv printenv enter; do | |
[[ $(alienv_test $method AliEn 'which aliensh') == */AliEn/* ]] | |
done | |
for ALIENV_OVERRIDE_PLATFORM in el6 el7 ubuntu1404; do | |
export ALIENV_OVERRIDE_PLATFORM | |
for method in setenv printenv enter; do | |
for ver in "$NEW_VER" "$OLD_VER"; do | |
pt "check g++ with $ver on $ALIENV_OVERRIDE_PLATFORM" | |
[ "$ver" = "$NEW_VER" ] && EXPECT="/cvmfs/alice.cern.ch/$ALIENV_OVERRIDE_PLATFORM" || EXPECT=/usr/ | |
[[ $(alienv_test $method $ver 'which g++') == "$EXPECT"* ]] | |
pt "check aliroot with $ver on $ALIENV_OVERRIDE_PLATFORM" | |
[[ $(alienv_test $method $ver 'which aliroot') == /cvmfs/alice.cern.ch/*bin/aliroot ]] | |
pt "check AliEn-Runtime with $ver on $ALIENV_OVERRIDE_PLATFORM" | |
[ "$ver" = "$NEW_VER" ] && EXPECT=/AliEn-Runtime/ || EXPECT=/AliEn/ | |
[[ $(alienv_test $method $ver 'which aliensh') == /cvmfs/alice.cern.ch/*"$EXPECT"* ]] | |
done | |
done | |
done | |
pg "all tests successful" |