-
Notifications
You must be signed in to change notification settings - Fork 2
195 lines (189 loc) · 5.96 KB
/
ci.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: CI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
jobs:
formatting-check:
name: Check code format
runs-on: ubuntu-latest
steps:
-
name: Checkout hermes repo
uses: actions/checkout@v2
-
name: Run clang format
run: |
find . -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\|c\|hh\)' -exec clang-format -style=file -i {} \;
git diff --exit-code
compile-and-unit-tests:
name: Compile and run unit tests
runs-on: ubuntu-latest
container:
image: ghcr.io/jgomezselles/hermes_base:0.0.3
options: "--entrypoint sh"
steps:
-
name: Checkout hermes repo
uses: actions/checkout@v2
-
name: Run cmake with debug and coverage flags
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug .
-
name: Compile code and unit tests
run: make -j -C build
-
name: Install and setup lcov base
run: |
dnf install -y lcov
lcov -i --capture --directory "./build/src/" --output-file base-coverage.info --no-external --directory "./" --exclude "*/ut/*" --exclude "*/main*"
-
name: Run unit tests
run: ./build/ut/unit-test
-
name: Capture and merge coverage info
run: |
lcov --capture --directory "./build/src/" --output-file test-coverage.info --no-external --directory "./" --exclude "*/ut/*" --exclude "*/main*"
lcov -a base-coverage.info -a test-coverage.info -o total-coverage.info
-
name: Upload coverage to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: total-coverage.info
build-release-image:
name: Build hermes release image and push it to artifacts
runs-on: ubuntu-latest
env:
COMMIT_ID: ${{ github.sha }}
steps:
-
name: Set commit id
run: echo COMMIT_ID=${COMMIT_ID::7} >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile
tags: ghcr.io/jgomezselles/hermes:${{ env.COMMIT_ID }}
outputs: type=docker,dest=/tmp/hermes-image-${{ env.COMMIT_ID }}.tar
-
name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: hermes-image-${{ env.COMMIT_ID }}
path: /tmp/hermes-image-${{ env.COMMIT_ID }}.tar
retention-days: 1
build-server-mock-image:
name: Build server-mock image and push it to artifacts
runs-on: ubuntu-latest
env:
COMMIT_ID: ${{ github.sha }}
steps:
-
name: Set commit id
run: echo COMMIT_ID=${COMMIT_ID::7} >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/server-mock/Dockerfile
tags: ghcr.io/jgomezselles/server-mock:${{ env.COMMIT_ID }}
outputs: type=docker,dest=/tmp/server-mock-image-${{ env.COMMIT_ID }}.tar
-
name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: server-mock-image-${{ env.COMMIT_ID }}
path: /tmp/server-mock-image-${{ env.COMMIT_ID }}.tar
retention-days: 1
test-example-hermes:
needs: [ build-release-image, build-server-mock-image]
runs-on: ubuntu-latest
env:
COMMIT_ID: ${{ github.sha }}
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Trim commit id
run: echo COMMIT_ID=${COMMIT_ID::7} >> $GITHUB_ENV
-
name: Install KinD
uses: helm/kind-action@2a525709fd0874b75d7ae842d257981b0e0f557d
with:
cluster_name: "kind"
kubectl_version: "v1.22.1"
-
name: Download server-mock
uses: actions/download-artifact@v2
with:
name: server-mock-image-${{ env.COMMIT_ID }}
path: /tmp
-
name: Download hermes image
uses: actions/download-artifact@v2
with:
name: hermes-image-${{ env.COMMIT_ID }}
path: /tmp
-
name: Load images to KinD
run: |
kind load image-archive /tmp/server-mock-image-${{ env.COMMIT_ID }}.tar ghcr.io/jgomezselles/server-mock:${{ env.COMMIT_ID }} --name kind
kind load image-archive /tmp/hermes-image-${{ env.COMMIT_ID }}.tar ghcr.io/jgomezselles/hermes:${{ env.COMMIT_ID }} --name kind
-
name: Check previous steps
run: |
docker exec kind-control-plane crictl images
kubectl get pods -A
kubectl version
-
name: Lint hermes helmchart
run: |
helm lint helm/hermes
-
name: Update example-hermes dependencies
run: |
helm dep update helm/example-hermes
-
name: Lint example-hermes helmchart
run: |
helm lint helm/example-hermes
-
name: Template example-hermes
run: |
helm template helm/example-hermes/ --set serverMock.image.tag=${{ env.COMMIT_ID }} --set hermes.image.tag=${{ env.COMMIT_ID }} --set hermes.image.pullPolicy=Never
-
name: Install example-hermes
run: |
helm install hermes-example-${{ env.COMMIT_ID }} helm/example-hermes/ --set serverMock.image.tag=${{ env.COMMIT_ID }} --set hermes.image.tag=${{ env.COMMIT_ID }} --set hermes.image.pullPolicy=Never --wait --timeout=30s
-
name: Check pods
run: |
kubectl describe pods
-
name: Run helm tests
run: |
helm test hermes-example-${{ env.COMMIT_ID }}
-
name: Run hermes
run: |
HERMES_POD=$(kubectl get pod -l app.kubernetes.io/name=hermes -o jsonpath="{.items[0].metadata.name}")
kubectl exec $HERMES_POD -- hermes -p1 -t10 -r1000