variables:
  # renovate: datasource=docker depName=golang allowedVersions=/1\.21\..+/
  # When updating GO_VERSION, update Go versions in docs/development/index.md
  # or the 'docs:check development docs Go version' job will fail
  GO_VERSION: "1.23.2"
  RUNNER_IMAGES_REGISTRY: registry.gitlab.com/gitlab-org/ci-cd/runner-tools/base-images
  RUNNER_IMAGES_VERSION: "0.0.3"
  RUNNER_IMAGES_WINDOWS_GO_URL: https://gitlab.com/api/v4/projects/gitlab-org%2fci-cd%2frunner-tools%2fbase-images/packages/generic/runner-images/v${RUNNER_IMAGES_VERSION}/golang-windows-amd64.zip
  CI_IMAGE: "${RUNNER_IMAGES_REGISTRY}/ci:${RUNNER_IMAGES_VERSION}"
  # Feature flags
  FF_SCRIPT_SECTIONS: "true"
  FF_USE_FASTZIP: "true"
  FF_USE_NEW_BASH_EVAL_STRATEGY: "true"
  FF_TIMESTAMPS: "true"
  # Following variables are used in some jobs to install specified software
  RELEASE_INDEX_GEN_VERSION: "latest"
  DOCKER_VERSION: 27.3.1
  LICENSE_MANAGEMENT_SETUP_CMD: echo "Skip setup. Dependency already vendored"
  DOCS_GITLAB_REPO_SUFFIX: "runner"
  # We're overriding rules for the jobs that we want to run.
  # This will disable all other rules.
  DEPENDENCY_SCANNING_DISABLED: "true"
  TRANSFER_METER_FREQUENCY: "5s"
  CACHE_COMPRESSION_FORMAT: tarzstd
  GO111MODULE: "on"
  # renovate: datasource=docker depName=redhat/ubi9-micro versioning=redhat allowedVersions=/9\.4-[0-9]+/
  PACKAGES_ITERATION: "1"

default:
  image: $CI_IMAGE
  tags:
    - !reference [.instance-default]
  retry:
    max: 2
    when:
      - runner_system_failure

.no_cache:
  cache: {}

.no_dependencies:
  dependencies: []

.no_cache_and_dependencies:
  extends:
    - .no_cache
    - .no_dependencies

.docker:
  services:
    - docker:${DOCKER_VERSION}-dind
  variables:
    DOCKER_HOST: "unix:///certs/client/docker.sock"
  tags:
    - !reference [.instance-default-docker]

.go-cache:
  variables:
    GODEBUG: gocachetest=1
    GOCACHE: $CI_PROJECT_DIR/.gocache-$CI_COMMIT_REF_PROTECTED
  before_script:
    - mkdir -p "$GOCACHE"
    - ./ci/touch_git
  cache:
    paths:
      - $CI_PROJECT_DIR/.gocache-false/
    key: "${CI_JOB_NAME}-${CI_COMMIT_REF_SLUG}"

.go-cache-windows:
  variables:
    GODEBUG: gocachetest=1
    GOCACHE: $CI_PROJECT_DIR\.gocache-$CI_COMMIT_REF_PROTECTED
  before_script:
    - New-Item -Path "$Env:GOCACHE" -Type Directory -Force
    - $env:GOCACHE = (Resolve-Path $env:GOCACHE).Path
    - ./ci/touch_git.ps1
  cache:
    paths:
      - $CI_PROJECT_DIR\.gocache-false\
    key: "${CI_JOB_NAME}-${CI_COMMIT_REF_SLUG}"

.windows-dependency-checksums:
  variables:
    GIT_WINDOWS_AMD64_CHECKSUM: "36498716572394918625476ca207df3d5f8b535a669e9aad7a99919d0179848c"
    GIT_LFS_WINDOWS_AMD64_CHECKSUM: "94435072f6b3a6f9064b277760c8340e432b5ede0db8205d369468b9be52c6b6"
    PWSH_WINDOWS_AMD64_CHECKSUM: "ED331A04679B83D4C013705282D1F3F8D8300485EB04C081F36E11EAF1148BD0"

.windows1809_variables:
  variables:
    WINDOWS_VERSION: servercore1809

.windows1809:
  extends:
    - .windows1809_variables
  tags:
    - !reference [.instance-windows-2019]

.windows1809_nano:
  extends:
    - .windows1809
  variables:
    WINDOWS_VERSION: nanoserver1809

.windows21H2_variables:
  variables:
    WINDOWS_VERSION: servercore21H2

.windows21H2:
  extends:
    - .windows21H2_variables
  tags:
    - !reference [.instance-windows-2022]

.windows21H2_nano:
  extends:
    - .windows21H2
  variables:
    WINDOWS_VERSION: nanoserver21H2

# .stage_done is used as a sentinel at stage n for stage n-1 completion, so we can kick off builds in later stages
# without explicitly waiting for the completion of the n-1 stage
.stage_done:
  extends:
    - .no_cache_and_dependencies
    - .rules:merge_request_pipelines
  image: alpine:latest
  variables:
    GIT_STRATEGY: none
  script:
    - exit 0
