forked from minekube/gate
-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (216 loc) · 8.21 KB
/
Copy pathci.yml
File metadata and controls
242 lines (216 loc) · 8.21 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: ci
on:
push:
workflow_dispatch:
pull_request:
types: [opened, reopened]
env:
REGISTRY: ghcr.io
permissions:
contents: write
packages: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
- name: golangci-lint
run: golangci-lint run --timeout 3m0s
test:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Go with cache
uses: actions/setup-go@v6
with:
cache: true
go-version-file: go.mod
- name: Test
run: make test
- name: Smoke test - Geyserlite Windows auto-download starts
if: matrix.platform == 'windows-latest'
run: go test ./pkg/edition/bedrock/geyser -tags=geyserlite_smoke -run TestLiteManagedRunnerWindowsAutoDownloadSmoke -count=1 -timeout 6m -v
# Regression test for https://github.com/minekube/gate/issues/697:
# The published images crashed with "exec /gate: no such file or directory"
# because the gate binary is dynamically linked (the geyserlite dependency
# pulls in github.com/ebitengine/purego, which imports libdl.so.2 via
# //go:cgo_import_dynamic even with CGO_ENABLED=0) but the runtime base image
# had no glibc dynamic loader. This job builds the actual images and runs the
# binary and starts managed Bedrock on both architectures so broken runtime
# dependencies or cache paths fail CI instead of shipping.
docker-smoke:
strategy:
fail-fast: false
matrix:
runner: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up docker buildx
uses: docker/setup-buildx-action@v4
- name: Build gate image (host arch, load)
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
load: true
target: gate
build-args: |
VERSION=smoke-test
tags: gate:smoke
- name: Smoke test - gate binary execs in distroless image
run: |
out="$(docker run --rm gate:smoke --version)"
echo "$out"
echo "$out" | grep -q "gate version smoke-test"
- name: Smoke test - managed Bedrock starts in read-only distroless image
run: |
cid=$(docker run -d --read-only --tmpfs /tmp \
-v "$PWD/.github/testdata/managed-bedrock.yml:/config.yml:ro" \
gate:smoke --config /config.yml)
trap 'docker logs "$cid" 2>&1 || true; docker rm -f "$cid" >/dev/null 2>&1 || true' EXIT
for _ in $(seq 1 180); do
logs=$(docker logs "$cid" 2>&1)
if grep -q "geyser integration started" <<<"$logs"; then
exit 0
fi
if [ "$(docker inspect -f '{{.State.Running}}' "$cid")" != "true" ]; then
exit 1
fi
sleep 1
done
exit 1
- name: Build jre variant image (host arch, load)
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
load: true
target: jre
build-args: |
VERSION=smoke-test
tags: gate-jre:smoke
- name: Smoke test - gate binary execs in jre image
run: |
out="$(docker run --rm gate-jre:smoke --version)"
echo "$out"
echo "$out" | grep -q "gate version smoke-test"
build:
if: ( github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/') ) || ( github.event_name == 'push' && ( github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') ) )
needs:
- lint
- test
- docker-smoke
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image-ref.outputs.image }}
image_latest: ${{ steps.image-ref.outputs.image_latest }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up docker buildx
uses: docker/setup-buildx-action@v4
- name: Login to Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create image ref and version
id: image-ref
run: |
REF=$(git rev-parse --short $GITHUB_SHA)
# Get version from git tags or use commit-based version
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev-${REF}")
IMAGE=${{ env.REGISTRY }}/${{ github.repository }}:${REF}
IMAGE_LATEST=${{ env.REGISTRY }}/${{ github.repository }}:latest
IMAGE_JRE=${{ env.REGISTRY }}/${{ github.repository }}/jre:${REF}
IMAGE_JRE_LATEST=${{ env.REGISTRY }}/${{ github.repository }}/jre:latest
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
echo "image_latest=${IMAGE_LATEST}" >> $GITHUB_OUTPUT
echo "image_jre=${IMAGE_JRE}" >> $GITHUB_OUTPUT
echo "image_jre_latest=${IMAGE_JRE_LATEST}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
# If building from a tag, extract the version tag for docker tagging
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION_TAG=${GITHUB_REF#refs/tags/}
IMAGE_VERSION=${{ env.REGISTRY }}/${{ github.repository }}:${VERSION_TAG}
IMAGE_JRE_VERSION=${{ env.REGISTRY }}/${{ github.repository }}/jre:${VERSION_TAG}
echo "image_version=${IMAGE_VERSION}" >> $GITHUB_OUTPUT
echo "image_jre_version=${IMAGE_JRE_VERSION}" >> $GITHUB_OUTPUT
echo "version_tag=${VERSION_TAG}" >> $GITHUB_OUTPUT
echo "Building images with version tag:" >> $GITHUB_STEP_SUMMARY
echo "- ${IMAGE_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "- ${IMAGE_JRE_VERSION}" >> $GITHUB_STEP_SUMMARY
fi
echo "Building images:" >> $GITHUB_STEP_SUMMARY
echo "- ${IMAGE}" >> $GITHUB_STEP_SUMMARY
echo "- ${IMAGE_JRE}" >> $GITHUB_STEP_SUMMARY
echo "Version: ${VERSION}" >> $GITHUB_STEP_SUMMARY
- name: Build and push docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=${{ steps.image-ref.outputs.image_latest }}
cache-to: type=inline
build-args: |
VERSION=${{ steps.image-ref.outputs.version }}
target: gate
tags: |
${{ steps.image-ref.outputs.image }}
${{ steps.image-ref.outputs.image_latest }}
${{ steps.image-ref.outputs.image_version }}
- name: Build and push docker image (jre variant)
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=${{ steps.image-ref.outputs.image_jre_latest }}
cache-to: type=inline
build-args: |
VERSION=${{ steps.image-ref.outputs.version }}
target: jre
tags: |
${{ steps.image-ref.outputs.image_jre }}
${{ steps.image-ref.outputs.image_jre_latest }}
${{ steps.image-ref.outputs.image_jre_version }}
releaser:
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
cache: true
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}