Skip to content
Snippets Groups Projects
Commit 65e7f0bf authored by Marc-Olivier Andrez's avatar Marc-Olivier Andrez
Browse files

ci: fix Go tests that internally check the version of a component

The CI job `test-services-linux-debug` executes the tests using CMake,
including the Go tests. The command used to execute the Go tests is
defined in `CMakeModules/testing_go.cmake` Ln14: `go test ${test_source_files}`.
The `go test` command first compiles the tests and then run them.
Compiling the tests needs the file
`common/go/src/asapo_common/version/version_lib.go` to correctly define
 the versions of the different communication protocols and components:

```go
package version

// Default build-time variable for library-import.
// This file is overridden on build with build-time informations.
func init(){
	version   = "100.0.wip-fix-tests, build 5100fbee"
	consumerProtocolVersion = "v0.6"
	producerProtocolVersion = "v0.6"
	discoveryApiVersion = "v0.1"
	authorizerApiVersion = "v0.2"
	ftsApiVersion = "v0.2"
	brokerApiVersion = "v0.6"
}
```

The file `common/go/src/asapo_common/version/version_lib.go` is
generated when running CMake. So the file is generated in the CI job
`build-services-linux-debug`, not in `test-services-linux-debug`.

This commit ensures that the file is copied from the CI job
`build-services-linux-debug` to the CI job `test-services-linux-debug`
so that `go test` can use it when compiling and running the tests. If
the file does not exist, `go test` won't be able to compile the tests.
parent e7140bcb
Branches
Tags
No related merge requests found
......@@ -3,6 +3,9 @@ workflow:
rules:
- if: $CI_COMMIT_BRANCH
variables:
GO_VERSION_FILE: $CI_PROJECT_DIR/common/go/src/asapo_common/version/version_lib.go
include:
- local: deploy/build_env/services-linux/gitlab-ci-build-docker.yml
- local: deploy/build_env/services-windows/gitlab-ci-build-docker.yml
......@@ -97,6 +100,8 @@ build-services-linux-debug:
- cd $CI_PROJECT_DIR/build
- cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_INTEGRATION_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_CONSUMER_TOOLS=ON -DENABLE_LIBFABRIC=ON -DENABLE_LIBFABRIC_LOCALHOST=ON -DBUILD_EVENT_MONITOR_PRODUCER=ON -DSTOP_BUILD_ON_WARNINGS=ON -DENABLE_NEW_RECEIVER_MONITORING=ON ..
- make -j 4
# Ensures that the definition of versions of Go packages is present and will be uploaded.
- cat "$GO_VERSION_FILE"
tags:
- kubernetes-executor
rules:
......@@ -104,6 +109,7 @@ build-services-linux-debug:
artifacts:
paths:
- build
- "$GO_VERSION_FILE"
exclude:
- build/**/CMakeFiles/**/*.o
- build/**/CMakeFiles/**/*.gcno
......
......@@ -6,15 +6,6 @@ import (
"io"
)
var version string
var consumerProtocolVersion string
var producerProtocolVersion string
var discoveryApiVersion string
var authorizerApiVersion string
var ftsApiVersion string
var brokerApiVersion string
func GetDiscoveryApiVersion() string {
return discoveryApiVersion
}
......
......@@ -2,12 +2,12 @@ package version
// Default build-time variable for library-import.
// This file is overridden on build with build-time informations.
func init(){
version = "@ASAPO_VERSION@@ASAPO_VERSION_COMMIT@"
const (
version = "@ASAPO_VERSION@@ASAPO_VERSION_COMMIT@"
consumerProtocolVersion = "@ASAPO_CONSUMER_PROTOCOL@"
producerProtocolVersion = "@ASAPO_PRODUCER_PROTOCOL@"
discoveryApiVersion = "@ASAPO_DISCOVERY_API_VER@"
authorizerApiVersion = "@ASAPO_AUTHORIZER_API_VER@"
ftsApiVersion = "@ASAPO_FILE_TRANSFER_SERVICE_API_VER@"
brokerApiVersion = "@ASAPO_BROKER_API_VER@"
}
producerProtocolVersion = "@ASAPO_PRODUCER_PROTOCOL@"
discoveryApiVersion = "@ASAPO_DISCOVERY_API_VER@"
authorizerApiVersion = "@ASAPO_AUTHORIZER_API_VER@"
ftsApiVersion = "@ASAPO_FILE_TRANSFER_SERVICE_API_VER@"
brokerApiVersion = "@ASAPO_BROKER_API_VER@"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment