-
Notifications
You must be signed in to change notification settings - Fork 64
142 lines (133 loc) · 4.1 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Run EMQX Operator Test Case
concurrency:
group: test-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
push:
## For update codecov.io
branches:
- main**
jobs:
lint:
runs-on: ubuntu-latest
outputs:
e2e: ${{ steps.e2e.outputs.e2e }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- uses: golangci/golangci-lint-action@v3
with:
## TODO: https://github.com/golangci/golangci-lint-action/issues/759
version: v1.52.2
args: --timeout=5m
- run: go install github.com/google/go-licenses@latest
- run: $(go env GOPATH)/bin/go-licenses check . --disallowed_types forbidden,restricted,unknown
- name: Check manifests
run: |
make manifests
if ! git diff --quiet; then
echo "Need run make manifests"
exit 1
fi
- name: Check generate
run: |
make generate
if ! git diff --quiet; then
echo "Need run make generate"
exit 1
fi
- name: Check helm crds
run: |
make helm-crds
if ! git diff --quiet; then
echo "Need run make helm-crds"
exit 1
fi
- name: Check line-break at EOF
run: ./scripts/check-nl-at-eof.sh
- name: Check space at EOL
run: ./scripts/check-space-at-eol.sh
- name: Run shellcheck
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends shellcheck
./scripts/shellcheck.sh
- name: Output e2e test cases
id: e2e
run: |
e2e=$(find e2e -type f ! -name "suite_test.go" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "e2e test cases: $e2e"
echo "e2e=$e2e" >> $GITHUB_OUTPUT
e2e-test:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
file: ${{fromJSON(needs.lint.outputs.e2e)}}
steps:
- run: minikube start
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- run: go install github.com/onsi/ginkgo/v2/ginkgo@latest
- name: Install Telepresence
env:
TELEPRESENCE_VERSION: 2.13.3
run: |
sudo curl -fL https://app.getambassador.io/download/tel2/linux/amd64/${TELEPRESENCE_VERSION}/telepresence -o /usr/local/bin/telepresence
sudo chmod a+x /usr/local/bin/telepresence
- run: telepresence helm install
- run: telepresence connect
- name: Run e2e test cases
env:
FILE: ${{ matrix.file }}
run: |
echo "Run e2e test cases: $FILE"
filename="$(basename $FILE)"
filename="${filename%.*}"
$(go env GOPATH)/bin/ginkgo -v --cover -covermode=atomic -coverpkg=./... -coverprofile=${filename}.out --focus-file=${filename} $(dirname $FILE)
- uses: actions/upload-artifact@v3
with:
name: coverprofile
path: |
*.out
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- run: make test
- uses: actions/upload-artifact@v3
with:
name: coverprofile
path: |
*.out
codecov:
runs-on: ubuntu-latest
needs:
- e2e-test
- unit-test
steps:
- uses: actions/download-artifact@v3
with:
name: coverprofile
- name: Get cover files
id: files
run: |
files="$(find -maxdepth 1 -name '*.out' -exec readlink -f '{}' ';' | tr '\n' ',' | sed 's/,$//g')"
echo "files=$files" >> $GITHUB_OUTPUT
- uses: codecov/codecov-action@v3
with:
files: ${{ steps.files.outputs.files }} # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
- uses: geekyeggo/delete-artifact@v2
with:
name: coverprofile