Skip to content

Commit

Permalink
CI: improve script utils
Browse files Browse the repository at this point in the history
fix and improve loading utility function in CI bash scripts
- create `setup_utilities.sh` script to bundle several CI tools in one script
- call `set` command in each script -> before if script was executed instead source `set -e` was not active and the script did not exit, if a failure happened
- install sudo instead use fake_sudo.sh script, because it is more robust -> if an environment variable was directly set before the sudo command, fake_sudo.sh could not handle this
- move installation of agc-manager to extra script, that will be also install on GitHub Actions (was not installed before, therefore using agc-manager always returns false)
- suppress bash trace output, if `setup_utilities.sh` is sourced because it does not provide a benefit but spam the job output
  • Loading branch information
SimeonEhrig committed Jul 24, 2024
1 parent 01d123e commit 8ea7e38
Show file tree
Hide file tree
Showing 35 changed files with 137 additions and 105 deletions.
3 changes: 2 additions & 1 deletion script/after_failure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
then
Expand Down
4 changes: 2 additions & 2 deletions script/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Copyright 2022 Benjamin Worpitz, Bernhard Manfred Gruber, Jan Stephan, Simeon Ehrig
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

# because of the strict abort conditions, a variable needs to be defined, if we read from
# this statement avoids additional checks later in the scripts
Expand Down
3 changes: 2 additions & 1 deletion script/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

./script/print_env.sh
source ./script/before_install.sh
Expand Down
10 changes: 9 additions & 1 deletion script/docker_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
# Launch an extra docker container on GitHub Actions with a default ubuntu image.
# The Ubuntu image provided by GitHub contains already a lot of installed software
# and does not provide a clean environment. Therefore unexpected behavior at
# configuring the alpaka build is possible.

https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md

set +xv
source ./script/setup_utilities/set.sh
source ./script/docker_retry.sh

ALPAKA_CI_BOOST_BRANCH="boost-${ALPAKA_BOOST_VERSION}"
Expand Down
2 changes: 2 additions & 0 deletions script/docker_retry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

ANSI_RED="\033[31m"
ANSI_RESET="\033[0m"
set +xv
source ./script/setup_utilities.sh

# rerun docker command if error 125 (
# - triggered by image download problems
Expand Down
11 changes: 2 additions & 9 deletions script/gitlab_ci_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh

# inside the agc-container, the user is root and does not require sudo
# to compatibility to other container, fake the missing sudo command
if ! command -v sudo &> /dev/null
then
cp ${CI_PROJECT_DIR}/script/gitlabci/fake_sudo.sh /usr/bin/sudo
chmod +x /usr/bin/sudo
fi
set +xv
source ./script/setup_utilities/set.sh

source ./script/before_install.sh
source ./script/install.sh
Expand Down
10 changes: 0 additions & 10 deletions script/gitlabci/fake_sudo.sh

This file was deleted.

4 changes: 4 additions & 0 deletions script/gitlabci/print_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# SPDX-License-Identifier: MPL-2.0
#

# set exit on error manually instead using setup_utilities because
# otherwise the begin of the job log looks not helpful
set -e

# display output with yellow color
echo -e "\033[0;33mSteps to setup containter locally"

Expand Down
36 changes: 2 additions & 34 deletions script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,17 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: ${ALPAKA_CI_ANALYSIS?"ALPAKA_CI_ANALYSIS must be specified"}
: ${ALPAKA_CI_INSTALL_CUDA?"ALPAKA_CI_INSTALL_CUDA must be specified"}
: ${ALPAKA_CI_INSTALL_HIP?"ALPAKA_CI_INSTALL_HIP must be specified"}
: ${ALPAKA_CI_INSTALL_TBB?"ALPAKA_CI_INSTALL_TBB must be specified"}

# the agc-manager only exists in the agc-container
# set alias to false, so each time if we ask the agc-manager if a software is installed, it will
# return false and the installation of software will be triggered
if [ "$ALPAKA_CI_OS_NAME" != "Linux" ] || [ ! -f "/usr/bin/agc-manager" ]
then
echo "agc-manager is not installed"

echo '#!/bin/bash' > agc-manager
echo 'exit 1' >> agc-manager

if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
then
sudo chmod +x agc-manager
sudo mv agc-manager /usr/bin/agc-manager
elif [ "$ALPAKA_CI_OS_NAME" = "Windows" ]
then
chmod +x agc-manager
mv agc-manager /usr/bin
elif [ "$ALPAKA_CI_OS_NAME" = "macOS" ]
then
sudo chmod +x agc-manager
sudo mv agc-manager /usr/local/bin
else
echo "unknown operation system: ${ALPAKA_CI_OS_NAME}"
exit 1
fi
else
echo "found agc-manager"
fi

if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
then
travis_retry apt-get -y --quiet update
travis_retry apt-get -y install sudo

# tzdata is installed by software-properties-common but it requires some special handling
if [[ "$(cat /etc/os-release)" == *"20.04"* ]]
Expand Down
5 changes: 2 additions & 3 deletions script/install_analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
then
Expand Down
4 changes: 2 additions & 2 deletions script/install_boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh
source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${BOOST_ROOT?'BOOST_ROOT must be specified'}"
: "${ALPAKA_BOOST_VERSION?'ALPAKA_BOOST_VERSION must be specified'}"
Expand Down
5 changes: 2 additions & 3 deletions script/install_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${ALPAKA_CI_CLANG_VER?'ALPAKA_CI_CLANG_VER must be specified'}"
: "${ALPAKA_CI_STDLIB?'ALPAKA_CI_STDLIB must be specified'}"
Expand Down
5 changes: 2 additions & 3 deletions script/install_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${ALPAKA_CI_CMAKE_DIR?'ALPAKA_CI_CMAKE_DIR must be specified'}"
: "${ALPAKA_CI_CMAKE_VER?'ALPAKA_CI_CMAKE_VER must be specified'}"
Expand Down
5 changes: 2 additions & 3 deletions script/install_cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${ALPAKA_CI_CUDA_VERSION?'ALPAKA_CI_CUDA_VERSION must be specified'}"

Expand Down
5 changes: 2 additions & 3 deletions script/install_doxygen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

travis_retry sudo apt-get -y --quiet install --no-install-recommends doxygen graphviz
5 changes: 2 additions & 3 deletions script/install_gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${ALPAKA_CI_GCC_VER?'ALPAKA_CI_GCC_VER must be specified'}"
: "${ALPAKA_CI_SANITIZERS?'ALPAKA_CI_SANITIZERS must be specified'}"
Expand Down
5 changes: 2 additions & 3 deletions script/install_hip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${ALPAKA_CI_HIP_ROOT_DIR?'ALPAKA_CI_HIP_ROOT_DIR must be specified'}"
: "${ALPAKA_CI_HIP_VERSION?'ALPAKA_CI_HIP_VERSION must be specified'}"
Expand Down
5 changes: 2 additions & 3 deletions script/install_omp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

if [ "$ALPAKA_CI_OS_NAME" = "macOS" ]
then
Expand Down
5 changes: 2 additions & 3 deletions script/install_oneapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${CXX?'CXX must be specified'}"

Expand Down
5 changes: 2 additions & 3 deletions script/install_tbb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${ALPAKA_CI_TBB_VERSION?'ALPAKA_CI_TBB_VERSION must be specified'}"

Expand Down
3 changes: 2 additions & 1 deletion script/prepare_sanitizers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

#-------------------------------------------------------------------------------
# Exports the CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS to enable the sanitizers listed in ALPAKA_CI_SANITIZERS.
Expand Down
5 changes: 2 additions & 3 deletions script/print_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

#-------------------------------------------------------------------------------
if [ "$alpaka_CI" = "GITHUB" ]
Expand Down
5 changes: 2 additions & 3 deletions script/push_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/travis_retry.sh

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

cd docs/doxygen/html

Expand Down
3 changes: 2 additions & 1 deletion script/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${ALPAKA_CI_CMAKE_DIR?'ALPAKA_CI_CMAKE_DIR must be specified'}"
echo "ALPAKA_CI_CMAKE_DIR: ${ALPAKA_CI_CMAKE_DIR}"
Expand Down
3 changes: 2 additions & 1 deletion script/run_analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

if [ "$ALPAKA_CI_OS_NAME" = "Linux" ] || [ "$ALPAKA_CI_OS_NAME" = "macOS" ]
then
Expand Down
4 changes: 2 additions & 2 deletions script/run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Copyright 2014-2021 Benjamin Worpitz, Simeon Ehrig
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

cd build/

Expand Down
3 changes: 2 additions & 1 deletion script/run_doxygen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

#To deploy the doxygen documentation a copy of the repository is created inside the deployed folder.
#This copy is always in the gh-pages branch consisting only of the containing files.
Expand Down
3 changes: 2 additions & 1 deletion script/run_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

# TODO(SimeonEhrig): should use CMAKE_C_COMPILER and CMAKE_CXX_COMPILER instead update-alternatives because it
# is more relastic use case and less error prone approach
Expand Down
3 changes: 2 additions & 1 deletion script/run_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

ALPAKA_CI_CMAKE_EXECUTABLE=cmake
if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
Expand Down
3 changes: 2 additions & 1 deletion script/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# SPDX-License-Identifier: MPL-2.0
#

source ./script/set.sh
set +xv
source ./script/setup_utilities.sh

: "${alpaka_ACC_GPU_CUDA_ENABLE?'alpaka_ACC_GPU_CUDA_ENABLE must be specified'}"
: "${alpaka_ACC_GPU_HIP_ENABLE?'alpaka_ACC_GPU_HIP_ENABLE must be specified'}"
Expand Down
Loading

0 comments on commit 8ea7e38

Please sign in to comment.