github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/contrib/cirrus/container_test.sh (about) 1 #!/bin/bash 2 set -xeo pipefail 3 4 export GOPATH=/var/tmp/go 5 export PATH=$HOME/gopath/bin:$PATH:$GOPATH/bin 6 export GOSRC=$GOPATH/src/github.com/containers/libpod 7 8 DIST=${DIST:=""} 9 CONTAINER_RUNTIME=${DIST:=""} 10 11 source /etc/os-release 12 13 INTEGRATION_TEST_ENVS="" 14 15 # For all distributions not Fedora, we need to skip USERNS tests 16 # for now. 17 if [ "${ID}" != "fedora" ] || [ "${CONTAINER_RUNTIME}" != "" ]; then 18 INTEGRATION_TEST_ENVS="SKIP_USERNS=1" 19 fi 20 21 pwd 22 23 # -i install 24 # -b build 25 # -t integration test 26 # -u unit test 27 # -v validate 28 29 build=0 30 install=0 31 integrationtest=0 32 unittest=0 33 validate=0 34 options=0 35 remote=0 36 install_tools_made=0 37 38 while getopts "bituv" opt; do 39 case "$opt" in 40 b) build=1 41 options=1 42 ;; 43 i) install=1 44 options=1 45 ;; 46 t) integrationtest=1 47 options=1 48 ;; 49 u) unittest=1 50 options=1 51 ;; 52 v) validate=1 53 options=1 54 ;; 55 esac 56 done 57 58 # The TEST_REMOTE_CLIENT environment variable decides whether 59 # to test varlinke 60 if [[ "$TEST_REMOTE_CLIENT" == "true" ]]; then 61 remote=1 62 fi 63 64 # If no options are passed, do everything 65 if [ $options -eq 0 ]; then 66 build=1 67 install=1 68 integrationtest=1 69 unittest=1 70 validate=1 71 fi 72 73 # Make Install tools function used by multiple sections below 74 make_install_tools () { 75 # Only make the install tools once 76 if [ $install_tools_made -eq 0 ]; then 77 make install.tools TAGS="${TAGS}" 78 fi 79 install_tools_made=1 80 } 81 82 CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-none} 83 84 if [ "${CONTAINER_RUNTIME}" == "none" ]; then 85 mkdir -p /$GOPATH/src/github.com/containers/ 86 mv /var/tmp/checkout $GOSRC 87 cd $GOSRC 88 pwd 89 fi 90 91 92 export TAGS="seccomp $($GOSRC/hack/btrfs_tag.sh) $($GOSRC/hack/libdm_tag.sh) $($GOSRC/hack/btrfs_installed_tag.sh) $($GOSRC/hack/selinux_tag.sh)" 93 94 # Validate 95 if [ $validate -eq 1 ]; then 96 make_install_tools 97 # PAPR adds a merge commit, for testing, which fails the 98 # short-commit-subject validation test, so tell git-validate.sh to only check 99 # up to, but not including, the merge commit. 100 export GITVALIDATE_TIP=$(cd $GOSRC; git log -2 --pretty='%H' | tail -n 1) 101 make gofmt TAGS="${TAGS}" 102 103 # Only check lint and gitvalidation on more recent 104 # distros with updated git and tooling 105 if [[ ${DIST} == "Fedora" ]]; then 106 HEAD=$GITVALIDATE_TIP make -C $GOSRC .gitvalidation TAGS="${TAGS}" 107 make lint 108 fi 109 fi 110 111 # Unit tests 112 if [ $unittest -eq 1 ]; then 113 make localunit TAGS="${TAGS}" 114 fi 115 116 # Make Podman 117 if [ $build -eq 1 ]; then 118 make_install_tools 119 make TAGS="${TAGS}" GOPATH=$GOPATH 120 make podman-remote TAGS="${TAGS}" GOPATH=$GOPATH 121 fi 122 123 # Install Podman 124 if [ $install -eq 1 ]; then 125 make_install_tools 126 make TAGS="${TAGS}" install.bin PREFIX=/usr ETCDIR=/etc 127 make TAGS="${TAGS}" install.man PREFIX=/usr ETCDIR=/etc 128 make TAGS="${TAGS}" install.cni PREFIX=/usr ETCDIR=/etc 129 make TAGS="${TAGS}" install.config PREFIX=/usr ETCDIR=/etc 130 make TAGS="${TAGS}" install.systemd PREFIX=/usr ETCDIR=/etc 131 fi 132 133 # Run integration tests 134 if [ $integrationtest -eq 1 ]; then 135 make TAGS="${TAGS}" test-binaries 136 make varlink_generate 137 make localintegration $INTEGRATION_TEST_ENVS 138 if [ $remote -eq 1 ]; then 139 make remoteintegration $INTEGRATION_TEST_ENVS 140 fi 141 fi