-
Notifications
You must be signed in to change notification settings - Fork 33
161 lines (135 loc) · 4.05 KB
/
ci.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Hegel
on:
push:
branches:
- "*"
tags-ignore:
- "v*"
pull_request:
env:
REGISTRY: quay.io
IMAGE: quay.io/${{ github.repository }}
CGO_ENABLED: 0
GO_VERSION: "1.21"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- run: make lint
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Run tests
run: go test -coverprofile=coverage.txt ./...
- name: Upload codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
integration:
name: Test - Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Run integration tests
run: make test-integration
- name: Upload codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build
strategy:
matrix:
platform: [amd64, arm64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Build linux/${{ matrix.platform }}
run: make build GOARCH=${{ matrix.platform }}
- name: Upload linux/${{ matrix.platform }} binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
retention-days: 1
path: hegel-linux-${{ matrix.platform }}
e2e:
name: Test - E2E
runs-on: ubuntu-latest
needs: [test, integration]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
- uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Run end-to-end tests
run: make test-e2e
- name: Upload codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
package:
name: Package
runs-on: ubuntu-latest
needs: [lint, build, test, e2e]
steps:
- uses: actions/checkout@v4
# We need to specify a name for the download action else artifacts are downloaded with
# whatever name they were uploaded with. Its required because the Dockerfile expects
# the filenames to be formatted appropriately for the platform.
- name: Download all binaries
uses: actions/download-artifact@v4
with:
merge-multiple: true
# The upload/download actions do not preserve permissions so they need explicitly setting.
- name: Fix binary permissions
run: chmod +x hegel-linux-*
- name: Generate image tags
uses: docker/metadata-action@v5
id: meta
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: ${{ env.IMAGE }}
flavor: latest=false
tags: |
type=sha
- name: Login to quay.io
uses: docker/login-action@v3
if: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- uses: docker/setup-buildx-action@v3
- name: Build images and push
uses: docker/build-push-action@v6
with:
context: ./
cache-from: type=registry,ref=${{ env.IMAGE }}:latest
push: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64