Skip to content

Commit 8ae8d99

Browse files
committed
Use build tags for selecting e2e test mode
Signed-off-by: Ulysses Souza <[email protected]>
1 parent a97a736 commit 8ae8d99

File tree

6 files changed

+89
-25
lines changed

6 files changed

+89
-25
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959
- name: Build packages
6060
run: make -f builder.Makefile cross
6161

62-
build:
63-
name: Build
62+
build-plugin:
63+
name: Build and tests in plugin mode
6464
runs-on: ubuntu-latest
6565
env:
6666
GO111MODULE: "on"
@@ -71,10 +71,6 @@ jobs:
7171
go-version: 1.17
7272
id: go
7373

74-
- name: Set up gosum
75-
run: |
76-
go get -u gotest.tools/gotestsum
77-
7874
- name: Setup docker CLI
7975
run: |
8076
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
@@ -89,14 +85,45 @@ jobs:
8985
key: go-${{ hashFiles('**/go.sum') }}
9086

9187
- name: Test
92-
env:
93-
BUILD_TAGS: kube
9488
run: make -f builder.Makefile test
9589

9690
- name: Build for local E2E
9791
env:
9892
BUILD_TAGS: e2e
9993
run: make -f builder.Makefile compose-plugin
10094

101-
- name: E2E Test
95+
- name: E2E Test in plugin mode
10296
run: make e2e-compose
97+
98+
build-standalone:
99+
name: Build and tests in standalone mode
100+
runs-on: ubuntu-latest
101+
env:
102+
GO111MODULE: "on"
103+
steps:
104+
- name: Set up Go 1.17
105+
uses: actions/setup-go@v2
106+
with:
107+
go-version: 1.17
108+
id: go
109+
110+
- name: Setup docker CLI
111+
run: |
112+
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
113+
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
114+
115+
- name: Checkout code into the Go module directory
116+
uses: actions/checkout@v2
117+
118+
- uses: actions/cache@v2
119+
with:
120+
path: ~/go/pkg/mod
121+
key: go-${{ hashFiles('**/go.sum') }}
122+
123+
- name: Build for local E2E
124+
env:
125+
BUILD_TAGS: e2e
126+
run: make -f builder.Makefile compose-plugin
127+
128+
- name: E2E Test in standalone mode
129+
run: make e2e-compose-standalone

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,16 @@ compose-plugin: ## Compile the compose cli-plugin
4242
--output ./bin
4343

4444
.PHONY: e2e-compose
45-
e2e-compose: ## Run End to end local tests. Set E2E_TEST=TestName to run a single test
46-
gotestsum $(TEST_FLAGS) ./pkg/e2e -- -count=1
45+
e2e-compose: ## Run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
46+
go test $(TEST_FLAGS) -count=1 ./pkg/e2e
47+
48+
.PHONY: e2e-compose-standalone
49+
e2e-compose-standalone: ## Run End to end local tests in standalone mode. Set E2E_TEST=TestName to run a single test
50+
go test $(TEST_FLAGS) -count=1 --tags=standalone ./pkg/e2e
51+
52+
53+
.PHONY: e2e
54+
e2e: e2e-compose e2e-compose-standalone ## Run end to end local tests in both modes. Set E2E_TEST=TestName to run a single test
4755

4856
.PHONY: cross
4957
cross: ## Compile the CLI for linux, darwin and windows

pkg/e2e/e2e_config_plugin.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build !standalone
2+
3+
/*
4+
Copyright 2020 Docker Compose CLI authors
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package e2e
20+
21+
const composeStandaloneMode = false

pkg/e2e/e2e_config_standalone.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build standalone
2+
3+
/*
4+
Copyright 2020 Docker Compose CLI authors
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package e2e
20+
21+
const composeStandaloneMode = true

pkg/e2e/framework.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,9 @@ func (c *E2eCLI) RunDockerCmd(args ...string) *icmd.Result {
202202
return res
203203
}
204204

205-
const composeStandaloneEnvVar = "COMPOSE_STANDALONE_MODE"
206-
207205
// RunDockerComposeCmd runs a docker compose command, expects no error and returns a result
208206
func (c *E2eCLI) RunDockerComposeCmd(args ...string) *icmd.Result {
209-
composeStandaloneMode := os.Getenv(composeStandaloneEnvVar)
210-
if composeStandaloneMode == "true" || composeStandaloneMode == "1" {
207+
if composeStandaloneMode {
211208
composeBinary, err := findExecutable(DockerComposeExecutableName, []string{"../../bin", "../../../bin"})
212209
assert.NilError(c.test, err)
213210
res := icmd.RunCmd(c.NewCmd(composeBinary, args...))

pkg/e2e/main_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,9 @@ package e2e
1919
import (
2020
"os"
2121
"testing"
22-
23-
"github.com/sirupsen/logrus"
2422
)
2523

2624
func TestMain(m *testing.M) {
27-
logrus.Info("Running tests on COMPOSE_STANDALONE_MODE=true")
28-
_ = os.Setenv(composeStandaloneEnvVar, "true")
2925
exitCode := m.Run()
30-
if exitCode != 0 {
31-
os.Exit(exitCode)
32-
}
33-
logrus.Info("Running tests on COMPOSE_STANDALONE_MODE=false")
34-
_ = os.Setenv(composeStandaloneEnvVar, "false")
35-
exitCode = m.Run()
3626
os.Exit(exitCode)
3727
}

0 commit comments

Comments
 (0)