-
Notifications
You must be signed in to change notification settings - Fork 4
183 lines (154 loc) · 4.9 KB
/
pipeline.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
name: Build and test
on:
merge_group:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: # Handy for testing
jobs:
quesma-test-and-compile:
strategy:
matrix:
module: [ "quesma" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- name: Set up Go
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
- name: gofmt
working-directory: ${{ matrix.module }}
run: gofmt -l -d . | (! grep . -q) || (gofmt -l -d .;exit 1)
- name: License Header Verification
working-directory: ${{ matrix.module }}
run: |
LICENSE_COMMENT="// Copyright Quesma, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0"
failed=false
while IFS= read -r -d '' file; do
file_content=$(< "$file")
if [[ "$file_content" != "$LICENSE_COMMENT"* ]]; then
echo "License header missing or incorrect in file: $file"
failed=true
fi
done < <(find . -type f -name "*.go" -print0)
if [ "$failed" = true ]; then
exit 1
fi
- name: Go Vet
working-directory: ${{ matrix.module }}
run: go vet ./...
- uses: dominikh/[email protected]
with:
version: "2023.1.6"
install-go: false
working-directory: ${{ matrix.module }}
- name: Build
working-directory: ${{ matrix.module }}
run: go build -v ./...
- name: Test (without race detection)
working-directory: ${{ matrix.module }}
run: go run gotest.tools/gotestsum@latest --format pkgname-and-test-fails ./...
build-quesma-docker-image:
strategy:
matrix:
module: [ "quesma" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
- name: Build and export
uses: docker/build-push-action@v6
with:
context: ${{ matrix.module }}/.
tags: ${{ matrix.module }}:latest
outputs: type=docker,dest=/tmp/image.tar
cache-from: type=gha
cache-to: type=gha,mode=max
env:
DOCKER_BUILD_SUMMARY: false
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.module }}
path: /tmp/image.tar
retention-days: 1
build-log-generator:
strategy:
matrix:
module: [ "log-generator" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
- name: Build and export
uses: docker/build-push-action@v6
with:
context: ci/${{ matrix.module }}/.
tags: ${{ matrix.module }}:latest
outputs: type=docker,dest=/tmp/image.tar
cache-from: type=gha
cache-to: type=gha,mode=max
env:
DOCKER_BUILD_SUMMARY: false
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.module }}
path: /tmp/image.tar
retention-days: 1
smoke-test:
runs-on: ubuntu-latest
needs: [build-log-generator, build-quesma-docker-image]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
cache-dependency-path: smoke-test/go.sum
go-version: '1.22'
- name: Download images
uses: actions/download-artifact@v4
with:
path: /tmp/images
- name: Load images
run: |
for file in /tmp/images/*/*.tar; do
docker load --input $file
done
docker image ls -a
- name: Build and start docker-compose
timeout-minutes: 10
run: docker-compose -f ci/ci.yml up -d
- name: Wait until services are healthy
timeout-minutes: 6
working-directory: smoke-test
run: go run . --wait-for-start
- name: Verify if data is flowing
working-directory: smoke-test
env:
GITHUB_ACTIONS: true
run: go run .
- name: Print docker status
if: failure()
run: docker-compose -f ci/ci.yml ps
- name: Print docker-compose logs
if: failure()
run: docker-compose -f ci/ci.yml logs