Skip to content

Commit

Permalink
fix: NBS_MATRIX_ variable must not be overwritten by the declare command
Browse files Browse the repository at this point in the history
  • Loading branch information
RedLeader962 committed Jan 4, 2024
1 parent 216ff43 commit 1aae4f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Expand Up @@ -12,7 +12,7 @@ NBS_EXECUTE_BUILD_MATRIX_OVER_COMPOSE_FILE=docker-compose.dependencies.yaml
# Superproject version
#
# 'latest' is the latest push to the repository master branch
#NBS_MATRIX_REPOSITORY_VERSIONS=( 'latest' 'v2.0.test' )
#NBS_MATRIX_REPOSITORY_VERSIONS=( 'latest' 'v0.0.1' )
NBS_MATRIX_REPOSITORY_VERSIONS=( 'latest' )

#
Expand Down
2 changes: 1 addition & 1 deletion build_system_templates/.env.build_matrix.project.template
Expand Up @@ -12,7 +12,7 @@ NBS_EXECUTE_BUILD_MATRIX_OVER_COMPOSE_FILE=docker-compose.project_core.yaml
# Superproject version
#
# 'latest' is the latest push to the repository master branch
#NBS_MATRIX_REPOSITORY_VERSIONS=( 'latest' 'v2.0.test' )
#NBS_MATRIX_REPOSITORY_VERSIONS=( 'latest' 'v0.0.1' )
NBS_MATRIX_REPOSITORY_VERSIONS=( 'latest' )

#
Expand Down
10 changes: 5 additions & 5 deletions src/utility_scripts/nbs_execute_compose_over_build_matrix.bash
Expand Up @@ -216,11 +216,11 @@ print_msg "Build images specified in ${MSG_DIMMED_FORMAT}'${NBS_EXECUTE_BUILD_MA

# Freeze build matrix env variable to prevent accidental override
# Note: declare -r ==> set as read-only, declare -a ==> set as an array
declare -ra NBS_MATRIX_REPOSITORY_VERSIONS
declare -ra NBS_MATRIX_CMAKE_BUILD_TYPE
declare -ra NBS_MATRIX_SUPPORTED_OS
declare -ra NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS
declare -ra NBS_MATRIX_OSX_SUPPORTED_VERSIONS
declare -ra NBS_MATRIX_REPOSITORY_VERSIONS=(${NBS_MATRIX_REPOSITORY_VERSIONS[@]})
declare -ra NBS_MATRIX_CMAKE_BUILD_TYPE=(${NBS_MATRIX_CMAKE_BUILD_TYPE[@]})
declare -ra NBS_MATRIX_SUPPORTED_OS=(${NBS_MATRIX_SUPPORTED_OS[@]})
declare -ra NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=(${NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS[@]})
declare -ra NBS_MATRIX_OSX_SUPPORTED_VERSIONS=(${NBS_MATRIX_OSX_SUPPORTED_VERSIONS[@]})

print_msg "Environment variables ${MSG_EMPH_FORMAT}(build matrix)${MSG_END_FORMAT} set for compose:\n
${MSG_DIMMED_FORMAT} NBS_MATRIX_REPOSITORY_VERSIONS=(${NBS_MATRIX_REPOSITORY_VERSIONS[*]}) ${MSG_END_FORMAT}
Expand Down
Expand Up @@ -92,6 +92,16 @@ function setup_dotenv_build_matrix_superproject() {
assert_output --regexp "\[NBS done\]".*"FINAL › Build matrix completed with command".*"Completed".*"${TESTED_FILE}".*
}

# ....Dotenv related...............................................................................
@test "${TESTED_FILE} › env var from dotenv file exported › expect pass" {

setup_dotenv_build_matrix_dependencies

run bash "${TESTED_FILE}" "${DOTENV_BUILD_MATRIX}" --fail-fast -- config --quiet
assert_output --regexp .*"\[NBS\]".*"Environment variables".*"(build matrix)".*"set for compose:".*"NBS_MATRIX_REPOSITORY_VERSIONS=\(latest\)".*"NBS_MATRIX_UBUNTU_SUPPORTED_VERSIONS=\(bionic focal jammy\)"

}

# ....Flag related tests...........................................................................
@test "${TESTED_FILE} › flags are passed across script and function as expected › expect pass" {

Expand Down

0 comments on commit 1aae4f6

Please sign in to comment.