Skip to content

`GO_TEST_IMAGE` is never `null`

Describe the bug

with new version (>4.7.0) using components, go-build-test and go-test steps launch are not working as expected.

Expected behavior

"default" should launch go-build-test step and not go-test (as per default go test image is set to '').

Actual behavior

go-test is launched (but not go-build) and go-build-test step is not launched. also, it uses "default" image from the runner (busybox in our case)...

Logs and/or screenshots

Running with gitlab-runner 16.6.2 (63105255)
  on gr-gitlab-tech-orange-gitlab-runner gHa5b1j7F, system ID: r_PQYJdBHk6Tkt
  feature flags: FF_RETRIEVE_POD_WARNING_EVENTS:true
Preparing the "kubernetes" executor 00:00
Using Kubernetes namespace: gitlab-tech-orange
Using Kubernetes executor with image busybox ...
Using attach strategy to execute scripts...

Context & Configuration

Link to a project, pipeline or job facing the bug: internal only sorry :/

The issue was reproduced using:

  • Version of the template: 4.8.1
  • GitLab server(s): Gitlab CE 16.7.4
  • GitLab runner(s): kubernetes executor using 16.6.2 version

Here is the .gitlab-ci.yml file:

---
stages:
- build
- test
- package-build
- package-test
- infra
- deploy
- acceptance
- publish
- infra-prod
- production

variables:
  DOCKER_PROD_PUBLISH_STRATEGY: 'auto'
  ORT_AUTO_ON_MASTER_AND_DEV_ENABLED: "true"

  # to-be-continuous/semantic-release
  GITLAB_TOKEN: $BOT_TOKEN
  SEMREL_AUTO_RELEASE_ENABLED: "true"
  SEMREL_TAG_FORMAT: "$${version}"
  SEMREL_GPG_SIGNKEY: "$BOT_GIT_PRIVATE_KEY_FILE"

  # golang stuff
  ACK_GINKGO_DEPRECATIONS: "1.16.5"
  GO_IMAGE: golang:1.21-bullseye

include:
  - file: /templates/gitlab-ci-docker.yml
    project: to-be-continuous/docker
    ref: '5.7.1'
  - project: "to-be-continuous/custom/fossology"
    ref: "1.0.0"
    file: "templates/gitlab-ci-fossology.yml"
  - file: /templates/gitlab-ci-gitleaks.yml
    project: to-be-continuous/gitleaks
    ref: '2.3.0'
  - project: 'to-be-continuous/golang'
    ref: '4.8.1'
    file: '/templates/gitlab-ci-golang.yml'
  - project: 'to-be-continuous/semantic-release'
    ref: '3.7.1'
    file: '/templates/gitlab-ci-semrel.yml'
  - remote:
      https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/markdown.tbc.gitlab-ci.yml
  - remote:
      https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/markdown-link-check.tbc.gitlab-ci.yml
  - remote:
      https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/git.signed.tbc.gitlab-ci.yml
  - remote:
      "https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/commit-lint.gitlab-ci.yml"

.go-test-script: &go-test-script |
  # BEGSCRIPT
  set -e
  function go_operator_test() {
    mkdir -p -m 777 reports
    local go_text_report="reports/go-test.native.txt"
    set +e
    echo "*** launch tests"
    make test
    test_rc=$?
    set -e

    # compute and dump code coverage in the console
    echo "*** coverage"
    output_coverage

    # produce JUnit report (for GitLab)
    echo "*** gitlab junit report"
    install_go_junit_report
    "$GOBIN/go-junit-report" < "$go_text_report" > reports/go-test.xunit.xml

    # produce JSON report (for SonarQube)
    echo "*** sonar json report"
    go tool test2json < "$go_text_report" > reports/go-test.native.json

    # maybe fail
    if [[ "$test_rc" != "0" ]]; then echo "** tests have failed"; exit "$test_rc"; fi
    echo "*** end"
  }
  # ENDSCRIPT

go-build-test:
  variables:
    HTTPBIN_SERVER_URL: http://httpbin
  services:
    - name: kennethreitz/httpbin
      alias: httpbin
  script:
    - *go-test-script
    - go_build
    - go_operator_test