-
Notifications
You must be signed in to change notification settings - Fork 66
145 lines (136 loc) · 4.31 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
143
144
145
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@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: golangci/golangci-lint-action@v4
with:
##https://github.com/golangci/golangci-lint-action/issues/807
skip-pkg-cache: true
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@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- 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
id: e2e_test
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)
echo "filename=${filename}" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: coverprofile-${{ steps.e2e_test.outputs.filename }}
path: |
*.out
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: make test
- uses: actions/upload-artifact@v4
with:
name: coverprofile-unit-test
path: |
*.out
codecov:
runs-on: ubuntu-latest
needs:
- e2e-test
- unit-test
steps:
- uses: actions/download-artifact@v4
with:
pattern: coverprofile-*
- name: Get cover files
id: files
run: |
files="$(find . -type f -name '*.out' -exec readlink -f '{}' ';' | tr '\n' ',' | sed 's/,$//g')"
echo "files=$files" >> $GITHUB_OUTPUT
- uses: codecov/codecov-action@v4
with:
files: ${{ steps.files.outputs.files }} # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }} # required
- uses: geekyeggo/delete-artifact@v5
with:
name: coverprofile-*