Cleanup alienv file #26
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
--- | |
# 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@v4 | |
- 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" | |
tag=AliPhysics/v5-09-59r-01_O2-1 | |
# Overriding platform (not important for our tests) | |
export ALIENV_OVERRIDE_PLATFORM=el7 | |
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 "$tag" | |
) || 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 "$tag" | |
) || 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-143,VO_ALICE@ROOT::v6-28-04-alice3-5,$tag" -c true 2>&1 || :) | | |
tee /dev/stderr | | |
grep 'normalized to AliPhysics/v5-09-59r-01_O2-1 ROOT/v6-28-04-alice3-5 AliEn-Runtime/v2-19-le-143' | |
pt "test checkenv command with a successful combination" | |
alienv checkenv "$tag,AliRoot/$(basename "$tag" | sed 's/-01//')" || | |
pe "expected 0, returned $?" | |
pt "test checkenv command with a faulty combination" | |
if alienv checkenv "$tag,AliPhysics/vAN-20240214_O2-1" 2>&1; then | |
pe "expected failure, returned $?" | |
fi | grep -q 'conflicting version' || | |
pe "could not find expected output message" | |
# "alienv q" takes too long in a GitHub workflow (>45 min). | |
# pt "list AliPhysics packages" | |
# alienv q | grep AliPhysics | tail -n5 | |
pg "all tests successful" |