Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Let a job start service containers beside it

c1929d2fceb5e9e65204d5eef907d0781b9a5391 · Keenan Nemetz · 5d ago · parent 1d06b008

ci/container/container_test.go +74

@@ -222,3 +222,77 @@ func TestASecretsFileMustBeAContainerPath(t *testing.T) {
222 222 t.Fatalf("a container path was refused: %v", err)
223 223 }
224 224 }
225
226 // A service gets the job's isolation and nothing of the job's data: no workspace,
227 // no cache, no secrets file, and no entrypoint override, so the image's own command
228 // is what runs.
229 func TestServiceRunArgsAreClosed(t *testing.T) {
230 t.Parallel()
231 cfg := Config{
232 Runtime: "podman",
233 Network: "vole-runner1-run1-1-net",
234 Pull: "missing",
235 User: "1000:1000",
236 Userns: "keep-id",
237 Memory: "2g",
238 CPUs: "2",
239 PIDs: 512,
240 }
241 args := strings.Join(ServiceRunArgs(cfg, ServiceSpec{
242 Name: "vole-runner1-run1-1-svc-db",
243 Alias: "db",
244 Image: "postgres:17@sha256:abc",
245 Env: map[string]string{"POSTGRES_PASSWORD": "test"},
246 Labels: map[string]string{"vole.runner.id": "runner1"},
247 }), " ")
248
249 for _, want := range []string{
250 "run -d",
251 "--name vole-runner1-run1-1-svc-db",
252 "--label vole.runner.id=runner1",
253 "--user 1000:1000",
254 "--userns keep-id",
255 "--network-alias db",
256 "--env POSTGRES_PASSWORD=test",
257 "--tmpfs /tmp:rw,nosuid,nodev,exec,mode=1777",
258 "--cap-drop ALL",
259 "--security-opt no-new-privileges",
260 "--network vole-runner1-run1-1-net",
261 "--pull missing",
262 "--pids-limit 512",
263 "--memory 2g",
264 "--cpus 2",
265 "postgres:17@sha256:abc",
266 } {
267 if !strings.Contains(args, want) {
268 t.Fatalf("service arguments do not contain %q:\n%s", want, args)
269 }
270 }
271 for _, unwanted := range []string{
272 "--rm",
273 "--workdir",
274 "--volume",
275 "--entrypoint",
276 "--cap-add",
277 "--privileged",
278 "/workspace",
279 } {
280 if strings.Contains(args, unwanted) {
281 t.Fatalf("service arguments contain %q:\n%s", unwanted, args)
282 }
283 }
284 }
285
286 func TestTailBufferKeepsTheEnd(t *testing.T) {
287 t.Parallel()
288 b := &tailBuffer{max: 5}
289 _, _ = b.Write([]byte("1234"))
290 _, _ = b.Write([]byte("5678"))
291 if got := string(b.Bytes()); got != "45678" {
292 t.Fatalf("tail = %q, want 45678", got)
293 }
294 _, _ = b.Write([]byte("abcdefgh"))
295 if got := string(b.Bytes()); got != "defgh" {
296 t.Fatalf("tail after a long write = %q, want defgh", got)
297 }
298 }