Skip to content

Commit

Permalink
set default environment variables in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonEhrig committed Nov 18, 2024
1 parent af5ed36 commit f34dcfa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
env:
ALPAKA_CI_OS_NAME: ${{runner.os}}
shell: bash
run: cd ${GITHUB_WORKSPACE} && ./script/ci.sh
run: cd ${GITHUB_WORKSPACE} && source ./script/set_default_env_vars.sh && ./script/ci.sh
- name: build + test
if: (runner.os == 'Linux' || runner.os == 'macOS')
env:
Expand Down
1 change: 1 addition & 0 deletions script/job_generator/generate_job_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def create_job(job: Dict[str, Tuple[str, str]], container_version: float, gitlab
job_yaml["image"] = job_image(job, container_version, gitlab_images)
job_yaml["variables"] = job_variables(job)
job_yaml["script"] = [
"source ./script/set_default_env_vars.sh",
"source ./script/gitlabci/print_env.sh",
"source ./script/gitlab_ci_run.sh",
]
Expand Down
12 changes: 11 additions & 1 deletion script/run_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ echo_green "<SCRIPT: run_generate>"
#
# @param $1 cmake/environment variable name
#
# @result if $1 exists cmake variable definition else nothing is returned
# @result if $1 exists cmake variable definition else nothing is returned. If variable is not
# defined, the script will be exited.
#
# @code{.bash}
# FOO=ON
# BAR=""
# echo "$(env2cmake FOO)" # returns "-DFOO=ON"
# echo "$(env2cmake BAR)" # returns nothing
# echo "$(env2cmake FOOBAR)" # exit 1
# @endcode
function env2cmake()
{
# check if variable is defined
# TODO(SimeonEhrig): bring me back before merge
# if [ -z ${!1+x} ]; then
# kill -SIGTERM $$
# fi

# return only content of variable is not empty
if [ ! -z "${!1}" ] ; then
echo -n "-D$1=${!1}"
fi
Expand Down
5 changes: 5 additions & 0 deletions script/set_default_env_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#/usr/bin/env bash

# set default values for unset environment variables

export CMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS:="ON"}

0 comments on commit f34dcfa

Please sign in to comment.