Skip to content

Commit eb4d179

Browse files
authored
chore/integration test (#123)
* chore: make prompt optional for delete * chore: add initial integration test for macos * fix ci * fix ci * chore: add image building to integration * add integration test status badge to readme * chore: add kubernetes to integration test
1 parent bb73f1c commit eb4d179

File tree

6 files changed

+135
-6
lines changed

6 files changed

+135
-6
lines changed

.github/workflows/golang-ci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
tags: [v*]
5+
branches: [main]
6+
pull_request:
7+
jobs:
8+
golangci:
9+
name: lint
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: golangci-lint
14+
uses: golangci/golangci-lint-action@v2
15+
with:
16+
version: v1.43.0
17+
args: --timeout 3m0s

.github/workflows/integration.yml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Integration
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
docker:
12+
runs-on: macos-11
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.17
20+
21+
- name: Install CLI deps
22+
run: |
23+
brew install kubectl docker coreutils lima
24+
25+
- name: Build and Install Colima
26+
run: make && sudo make install
27+
28+
- name: Start Colima
29+
run: colima start --runtime docker
30+
31+
- name: Delay
32+
run: sleep 5
33+
34+
- name: Validate Docker
35+
run: docker ps && docker info
36+
37+
- name: Build Image
38+
run: docker build integration
39+
40+
- name: Stop
41+
run: colima stop
42+
43+
- name: Kubernetes
44+
run: colima start --runtime docker --with-kubernetes
45+
46+
- name: Delay
47+
run: sleep 5
48+
49+
- name: Validate Kubernetes
50+
run: kubectl cluster-info && kubectl version && kubectl get nodes -o wide
51+
52+
- name: Teardown
53+
run: colima delete -f
54+
55+
containerd:
56+
runs-on: macos-11
57+
steps:
58+
- uses: actions/checkout@v2
59+
60+
- name: Set up Go
61+
uses: actions/setup-go@v2
62+
with:
63+
go-version: 1.17
64+
65+
- name: Install CLI deps
66+
run: |
67+
brew install kubectl docker coreutils lima
68+
69+
- name: Build and Install Colima
70+
run: make && sudo make install
71+
72+
- name: Start Colima
73+
run: colima start --runtime containerd
74+
75+
- name: Delay
76+
run: sleep 5
77+
78+
- name: Validate Containerd
79+
run: colima nerdctl ps && colima nerdctl info
80+
81+
- name: Build Image
82+
run: colima nerdctl -- build integration
83+
84+
- name: Stop
85+
run: colima stop
86+
87+
- name: Kubernetes
88+
run: colima start --runtime containerd --with-kubernetes
89+
90+
- name: Delay
91+
run: sleep 5
92+
93+
- name: Validate Kubernetes
94+
run: kubectl cluster-info && kubectl version && kubectl get nodes -o wide
95+
96+
- name: Teardown
97+
run: colima delete -f

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Colima
22

33
[![Go](https://github.com/abiosoft/colima/actions/workflows/go.yml/badge.svg)](https://github.com/abiosoft/colima/actions/workflows/go.yml)
4+
[![Integration](https://github.com/abiosoft/colima/actions/workflows/integration.yml/badge.svg)](https://github.com/abiosoft/colima/actions/workflows/integration.yml)
45

56
Container runtimes on macOS (and Linux) with minimal setup.
67

app/app.go

-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"strconv"
66

7-
"github.com/abiosoft/colima/cli"
87
"github.com/abiosoft/colima/config"
98
"github.com/abiosoft/colima/environment"
109
"github.com/abiosoft/colima/environment/container/kubernetes"
@@ -134,11 +133,6 @@ func (c colimaApp) Stop() error {
134133
}
135134

136135
func (c colimaApp) Delete() error {
137-
y := cli.Prompt("are you sure you want to delete " + config.Profile().DisplayName + " and all settings")
138-
if !y {
139-
return nil
140-
}
141-
142136
log.Println("deleting", config.Profile().DisplayName)
143137

144138
// the order for teardown is:

cmd/delete.go

+15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package cmd
22

33
import (
4+
"github.com/abiosoft/colima/cli"
45
"github.com/abiosoft/colima/cmd/root"
6+
"github.com/abiosoft/colima/config"
57
"github.com/spf13/cobra"
68
)
79

10+
var deleteCmdArgs struct {
11+
force bool
12+
}
13+
814
// deleteCmd represents the delete command
915
var deleteCmd = &cobra.Command{
1016
Use: "delete",
@@ -16,10 +22,19 @@ initial startup of Colima.
1622
1723
If you simply want to reset the Kubernetes cluster, run 'colima kubernetes reset'.`,
1824
RunE: func(cmd *cobra.Command, args []string) error {
25+
if !deleteCmdArgs.force {
26+
y := cli.Prompt("are you sure you want to delete " + config.Profile().DisplayName + " and all settings")
27+
if !y {
28+
return nil
29+
}
30+
}
31+
1932
return newApp().Delete()
2033
},
2134
}
2235

2336
func init() {
2437
root.Cmd().AddCommand(deleteCmd)
38+
39+
deleteCmd.Flags().BoolVarP(&deleteCmdArgs.force, "force", "f", false, "do not prompt for yes/no")
2540
}

integration/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# sample dockerfile to test image building
2+
# without pulling from docker hub
3+
FROM scratch
4+
5+
COPY . /files

0 commit comments

Comments
 (0)