From d2d4aae34873359e0256dcec75dc79d7243afc6f Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
Date: Fri, 19 Nov 2021 15:36:16 +0100
Subject: [PATCH] .gitlab-ci.yml: test against Go 1.14 and latest

SystemOTA tries to stay compatible with Yocto Dunfell which currently
provides Go 1.14. The test pipeline was following latest version of Go.
We should test against 1.14 and later versions equally.

Fixes: https://booting.oniroproject.org/distro/components/sysota/-/issues/57
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com>
---
 .gitlab-ci.yml | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a78a06f..c0e9fe7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -22,9 +22,10 @@ reuse:
   extends: .reuse
 
 .go:
-  image: golang:latest
+  image: golang:$CI_GO_VERSION
   variables:
     GOPATH: /tmp/go
+    CI_GO_VERSION: "1.14"
   before_script:
     # Restore cache from place it is deposited to
     - mkdir -p $(go env GOPATH)/pkg/mod
@@ -65,10 +66,13 @@ cross-build:
     matrix:
       - GOOS: linux
         GOARCH: ["386", amd64, arm, arm64, riscv64]
+        CI_GO_VERSION: ["1.14", "latest"]
       - GOOS: windows
         GOARCH: [amd64, arm64]
+        CI_GO_VERSION: ["latest"]
       - GOOS: darwin
       - GOARCH: [amd64, arm64]
+        CI_GO_VERSION: ["latest"]
   script:
     - GOOS=$GOOS GOARCH=$GOARCH go build ./...
   cache:
@@ -81,6 +85,10 @@ unit-tests:
   needs: [static-checks]
   extends: .go
   stage: test
+  parallel:
+    matrix:
+      - GOOS: linux
+        CI_GO_VERSION: ["1.14", "latest"]
   before_script:
     - !reference [.go, before_script]
     # Install dbus-daemon and squashfs-tools which are used by dbus and
@@ -88,7 +96,13 @@ unit-tests:
     # can just apt-get install it.
     - apt-get update && apt-get install -y dbus squashfs-tools
     # Install go package for emitting GitLab friendly coverage information.
-    - go install github.com/boumenot/gocover-cobertura@latest
+    - |
+      case "$CI_GO_VERSION" in
+        1.14)
+          go get github.com/boumenot/gocover-cobertura ;;
+        latest)
+          go install github.com/boumenot/gocover-cobertura@latest ;;
+      esac
   script:
     - go test -coverprofile=coverage.txt -covermode count ./...
     - go tool cover -func=coverage.txt
@@ -107,6 +121,11 @@ static-checks:
   interruptible: true
   needs: [spell, format]
   extends: .go
+  variables:
+    # Static checks should catch as much as we can, even at the price of running
+    # on the version of Go that is more recent than what the project promises as
+    # the required dependency.
+    CI_GO_VERSION: latest
   stage: static
   before_script:
     - !reference [.go, before_script]
-- 
GitLab