mirror of https://github.com/docker/compose.git
use go 1.20 -cover support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
6a0398d786
commit
85ddfde5d6
|
@ -158,7 +158,7 @@ jobs:
|
||||||
name: Build
|
name: Build
|
||||||
uses: docker/bake-action@v2
|
uses: docker/bake-action@v2
|
||||||
with:
|
with:
|
||||||
targets: binary
|
targets: binary-with-coverage
|
||||||
set: |
|
set: |
|
||||||
*.cache-from=type=gha,scope=binary-linux-amd64
|
*.cache-from=type=gha,scope=binary-linux-amd64
|
||||||
*.cache-from=type=gha,scope=binary-e2e-${{ matrix.mode }}
|
*.cache-from=type=gha,scope=binary-e2e-${{ matrix.mode }}
|
||||||
|
@ -177,9 +177,6 @@ jobs:
|
||||||
if: ${{ matrix.mode == 'plugin' }}
|
if: ${{ matrix.mode == 'plugin' }}
|
||||||
run: |
|
run: |
|
||||||
make e2e-compose
|
make e2e-compose
|
||||||
-
|
|
||||||
name: Upload coverage to Codecov
|
|
||||||
uses: codecov/codecov-action@v3
|
|
||||||
-
|
-
|
||||||
name: Test standalone mode
|
name: Test standalone mode
|
||||||
if: ${{ matrix.mode == 'standalone' }}
|
if: ${{ matrix.mode == 'standalone' }}
|
||||||
|
@ -192,6 +189,9 @@ jobs:
|
||||||
if: ${{ matrix.mode == 'cucumber'}}
|
if: ${{ matrix.mode == 'cucumber'}}
|
||||||
run: |
|
run: |
|
||||||
make test-cucumber
|
make test-cucumber
|
||||||
|
-
|
||||||
|
name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
|
||||||
release:
|
release:
|
||||||
permissions:
|
permissions:
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
bin/
|
bin/
|
||||||
/.vscode/
|
/.vscode/
|
||||||
coverage.out
|
coverage.out
|
||||||
|
covdatafiles/
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -76,6 +76,7 @@ EOT
|
||||||
|
|
||||||
FROM build-base AS build
|
FROM build-base AS build
|
||||||
ARG BUILD_TAGS
|
ARG BUILD_TAGS
|
||||||
|
ARG BUILD_FLAGS
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
RUN --mount=type=bind,target=. \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=type=cache,target=/root/.cache \
|
--mount=type=cache,target=/root/.cache \
|
||||||
|
|
12
Makefile
12
Makefile
|
@ -39,6 +39,7 @@ ifneq ($(DETECTED_OS),Windows)
|
||||||
# https://github.com/golang/go/issues/27089
|
# https://github.com/golang/go/issues/27089
|
||||||
TEST_COVERAGE_FLAGS += -race
|
TEST_COVERAGE_FLAGS += -race
|
||||||
endif
|
endif
|
||||||
|
BUILD_FLAGS?=
|
||||||
TEST_FLAGS?=
|
TEST_FLAGS?=
|
||||||
E2E_TEST?=
|
E2E_TEST?=
|
||||||
ifeq ($(E2E_TEST),)
|
ifeq ($(E2E_TEST),)
|
||||||
|
@ -53,12 +54,16 @@ all: build
|
||||||
|
|
||||||
.PHONY: build ## Build the compose cli-plugin
|
.PHONY: build ## Build the compose cli-plugin
|
||||||
build:
|
build:
|
||||||
GO111MODULE=on go build -trimpath -tags "$(GO_BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" -o "$(DESTDIR)/docker-compose$(BINARY_EXT)" ./cmd
|
GO111MODULE=on go build $(BUILD_FLAGS) -trimpath -tags "$(GO_BUILDTAGS)" -ldflags "$(GO_LDFLAGS)" -o "$(DESTDIR)/docker-compose$(BINARY_EXT)" ./cmd
|
||||||
|
|
||||||
.PHONY: binary
|
.PHONY: binary
|
||||||
binary:
|
binary:
|
||||||
$(BUILDX_CMD) bake binary
|
$(BUILDX_CMD) bake binary
|
||||||
|
|
||||||
|
.PHONY: binary-with-coverage
|
||||||
|
binary-with-coverage:
|
||||||
|
$(BUILDX_CMD) bake binary-with-coverage
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: binary
|
install: binary
|
||||||
mkdir -p ~/.docker/cli-plugins
|
mkdir -p ~/.docker/cli-plugins
|
||||||
|
@ -66,7 +71,10 @@ install: binary
|
||||||
|
|
||||||
.PHONY: e2e-compose
|
.PHONY: e2e-compose
|
||||||
e2e-compose: ## Run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
|
e2e-compose: ## Run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
|
||||||
go test $(TEST_FLAGS) $(TEST_COVERAGE_FLAGS) -count=1 ./pkg/e2e
|
rm -rf covdatafiles
|
||||||
|
mkdir covdatafiles
|
||||||
|
GOCOVERDIR=covdatafiles go test $(TEST_FLAGS) -count=1 ./pkg/e2e
|
||||||
|
go tool covdata textfmt -i=covdatafiles -o=coverage.out
|
||||||
|
|
||||||
.PHONY: e2e-compose-standalone
|
.PHONY: e2e-compose-standalone
|
||||||
e2e-compose-standalone: ## Run End to end local tests in standalone mode. Set E2E_TEST=TestName to run a single test
|
e2e-compose-standalone: ## Run End to end local tests in standalone mode. Set E2E_TEST=TestName to run a single test
|
||||||
|
|
|
@ -83,6 +83,16 @@ target "test" {
|
||||||
output = [bindir("coverage")]
|
output = [bindir("coverage")]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target "binary-with-coverage" {
|
||||||
|
inherits = ["_common"]
|
||||||
|
target = "binary"
|
||||||
|
args = {
|
||||||
|
BUILD_FLAGS = "-cover"
|
||||||
|
}
|
||||||
|
output = [bindir("build")]
|
||||||
|
platforms = ["local"]
|
||||||
|
}
|
||||||
|
|
||||||
target "binary" {
|
target "binary" {
|
||||||
inherits = ["_common"]
|
inherits = ["_common"]
|
||||||
target = "binary"
|
target = "binary"
|
||||||
|
|
|
@ -214,12 +214,19 @@ func CopyFile(t testing.TB, sourceFile string, destinationFile string) {
|
||||||
// BaseEnvironment provides the minimal environment variables used across all
|
// BaseEnvironment provides the minimal environment variables used across all
|
||||||
// Docker / Compose commands.
|
// Docker / Compose commands.
|
||||||
func (c *CLI) BaseEnvironment() []string {
|
func (c *CLI) BaseEnvironment() []string {
|
||||||
return []string{
|
env := []string{
|
||||||
"HOME=" + c.HomeDir,
|
"HOME=" + c.HomeDir,
|
||||||
"USER=" + os.Getenv("USER"),
|
"USER=" + os.Getenv("USER"),
|
||||||
"DOCKER_CONFIG=" + c.ConfigDir,
|
"DOCKER_CONFIG=" + c.ConfigDir,
|
||||||
"KUBECONFIG=invalid",
|
"KUBECONFIG=invalid",
|
||||||
}
|
}
|
||||||
|
if coverdir, ok := os.LookupEnv("GOCOVERDIR"); ok {
|
||||||
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
|
root := filepath.Join(filepath.Dir(filename), "..", "..")
|
||||||
|
coverdir = filepath.Join(root, coverdir)
|
||||||
|
env = append(env, fmt.Sprintf("GOCOVERDIR=%s", coverdir))
|
||||||
|
}
|
||||||
|
return env
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCmd creates a cmd object configured with the test environment set
|
// NewCmd creates a cmd object configured with the test environment set
|
||||||
|
|
Loading…
Reference in New Issue