Skip to content

Provide early build setting validation

Arran Walker requested to merge ajwalker/refactor-build-settings into main

What does this MR do?

Consolidates user provided control knob variables into one place to validate them early, rather than on use.

image

Why was this MR needed?

  • We were not consistently warning on bad values for these settings.
  • Sometimes a warning could occur more than once (as it was printed on use)
  • This provides a convenient warning at the top of the job about any bad values used.
  • In Implement timestamped logs (!4591 - merged), the logger setup is delayed, and when each of these functions were printing a warning on use, there's a chance it could occur before the logger was ready.

What's the best way to test this MR?

# check includes: "WARNING: GIT_STRATEGY: expected either 'clone', 'fetch' or 'none' got \"blammo\", using default value 'clone'"
build_setting/incorrect_GIT_STRATEGY:
    variables:
        GIT_STRATEGY: blammo
    script:
        - "echo \U0001F91E"

# set project's Git shallow clone value to: 20
# check includes: "WARNING: GIT_SUBMODULE_DEPTH: expected int got \"blammo\", using default value: 20"
build_setting/incorrect_GIT_SUBMODULE_DEPTH:
    variables:
        GIT_SUBMODULE_DEPTH: blammo
    script:
        - echo "Submodule depth should be 20, because it uses the default from the project setting"

What are the relevant issue numbers?

Part of #36888 (closed)

Merge request reports