Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrey-utkin/6f5cecedb268b8d40c08f23aae63f565 to your computer and use it in GitHub Desktop.
Save andrey-utkin/6f5cecedb268b8d40c08f23aae63f565 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
set -x
# Replicating cvmfs .github/workflows/ci.yml .
# It runs Ubuntu 24.04 VM in Github Actions.
# That VM invokes docker (via compose),
# builds cvmfs in a CentOS 9 container,
# then installs RPM packages in a AlmaLinux 9 container and runs tests in it.
# We're in the workcopy
[[ -f cvmfs/cvmfs.cc ]]
# We're in a *complete* workcopy (otherwise inside the container the mount will be incomplete)
if [[ -e .git/objects/info/alternates ]]; then
exit 1
fi
VM_NAME=local:cvmfs-ci
incus create --vm images:ubuntu/24.04 "${VM_NAME}" -c security.nesting=true -c security.privileged=true -c limits.memory=8GiB -d root,size=50GiB
incus config device add "${VM_NAME}" cvmfs_workcopy disk source="$PWD" path=/usr/local/src/cvmfs shift=true readonly=false required=true
incus start "$VM_NAME"
# Wait for ipv4 IP
while ! incus list --format json "${VM_NAME}" | jq --raw-output .[0].state.network.enp5s0.addresses[0].address | grep -F . >/dev/null; do echo -n .; sleep 1; done
incus exec "${VM_NAME}" -- bash <<EOF
# Add Docker's official GPG key:
apt-get update
apt-get install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu noble stable" | tee /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
EOF
# We clone as we cannot directly use the mounted directory, because we get:
#running CernVM-FS client test cases...
#test.sh: ./run.sh: /bin/bash: bad interpreter: Bad address
#running CernVM-FS server test cases...
#test.sh: ./run.sh: /bin/bash: bad interpreter: Bad address
incus exec "${VM_NAME}" -- bash <<EOF
cd /usr/local/src
apt install -y git
git clone --single-branch cvmfs cvmfs-checkout \
|| git clone --single-branch --branch=local-ci-struggle https://github.com/andrey-utkin/cvmfs.git cvmfs-checkout
cd /usr/local/src/cvmfs-checkout
cd test/common/container
docker compose down
docker compose up --build -d cvmfs-dev
docker exec -u sftnight -t cvmfs-dev bash -c "sudo cvmfs_config setup && cd /home/sftnight/cvmfs/test/common/container && CVMFS_TEST_PROXY=DIRECT bash test.sh"
docker exec cvmfs-dev tar caf /tmp/tests-output.tar /tmp/cvmfs-{server,client}-test.log
docker cp cvmfs-dev:/tmp/tests-output.tar /tmp/
EOF
incus file pull "${VM_NAME}"/tmp/tests-output.tar tests-output.$(date +%F__%H_%M_%S).tar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment