From 5f40a0588e0716ec7145b5236e11465c4790d9ad Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Quang Date: Fri, 5 Jan 2024 22:58:39 +0700 Subject: [PATCH] :rocket: generate `runtimes.yml` when building images --- .github/workflows/build.yml | 2 +- Dockerfile | 7 +++++++ worker/worker.go | 3 --- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee03230..c0017ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: type=ref,event=pr,prefix=pr-,suffix=suffix=-${{ matrix.variant }} type=pep440,pattern={{version}},suffix=-${{ matrix.variant }} type=raw,${{ matrix.variant }} - type=sha,prefix=,suffix=-${{ matrix.variant }} + type=sha,prefix=,suffix=_${{ matrix.variant }} - name: Setup QEMU uses: docker/setup-qemu-action@v2 - name: Setup Docker BuildX diff --git a/Dockerfile b/Dockerfile index 040e403..ec6d5a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,15 @@ RUN go mod download COPY .. . RUN --mount=type=cache,target=/go/pkg/mod for variant in tier1 tier2 tier3; do GOOS=${TARGETOS} GOARCH=${TARGETARCH} make release OUT="./out/igloo.${variant}" VARIANT=${variant}; done +RUN --mount=type=cache,target=/go/pkg/mod GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o ./out/gen_runtimes ./cmd/gen_runtimes FROM --platform=${BUILDPLATFORM} alphanecron/judge-env:tier-1 AS tier-1 WORKDIR /igloo COPY --from=builder /usr/src/app/out/igloo.tier1 ./igloo +COPY --from=builder /usr/src/app/out/gen_runtimes ./gen_runtimes + +RUN ./gen_runtimes ENTRYPOINT ["/igloo/igloo"] @@ -26,6 +30,9 @@ FROM --platform=${BUILDPLATFORM} alphanecron/judge-env:tier-2 AS tier-2 WORKDIR /igloo COPY --from=builder /usr/src/app/out/igloo.tier2 ./igloo +COPY --from=builder /usr/src/app/out/gen_runtimes ./gen_runtimes + +RUN ./gen_runtimes ENTRYPOINT ["/igloo/igloo"] diff --git a/worker/worker.go b/worker/worker.go index 23b668a..0af7aab 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -14,7 +14,6 @@ import ( "math" "runtime" "slices" - "strings" "sync/atomic" ) @@ -141,8 +140,6 @@ func (w *JudgeWorker) Judge(r *_runner, sub types.Submission) { }) finalResult := judge() if finalResult != nil { - // replace actual new line characters with \\n to avoid shattered payloads when serializing response with msgpack - finalResult.CompilerOutput = strings.ReplaceAll(finalResult.CompilerOutput, "\n", "\\n") logger.Logger.Debug().Interface("result", finalResult).Interface("submission", sub).Msg("final result") } prod.Report(types.ResultFinal, finalResult)