Skip to content

Commit

Permalink
fix: fixed build errors on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurkengewuerz committed Nov 4, 2024
1 parent 520567f commit 6e21aa3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
4 changes: 4 additions & 0 deletions docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
image: ghcr.io/gurkengewuerz/gitcodejudge-server:latest
restart: unless-stopped
networks: [traefik]

volumes:
- ${CONTAINER_DIR}/judge/tests:/test_cases
- ${CONTAINER_DIR}/judge/db:/db
Expand All @@ -18,6 +19,9 @@ services:
- DB_PATH=/db
- PDF_FOOTER_COPYRIGHT=Copyright by Gurkengewuerz
- LEADERBOARD_ENABLED=true
- OAUTH2_ISSUER=${OAUTH2_ISSUER:-}
- OAUTH2_CLIENT_ID=${OAUTH2_CLIENT_ID:-}
- OAUTH2_SECRET=${OAUTH2_SECRET:-}
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
Expand Down
8 changes: 8 additions & 0 deletions docker/judge/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env ash
set -e

trim() {
local s2 s="$*"
until s2="${s#[[:space:]]}"; [ "$s2" = "$s" ]; do s="$s2"; done
until s2="${s%[[:space:]]}"; [ "$s2" = "$s" ]; do s="$s2"; done
echo "$s"
}

# Check if required environment variables are set
if [ -z "$JUDGE_WORKSHOP" ] || [ -z "$JUDGE_TASK" ]; then
>&2 echo "Error: JUDGE_WORKSHOP and JUDGE_TASK environment variables must be set"
Expand All @@ -9,6 +16,7 @@ fi

# Define the solutions directory
SOLUTIONS_DIR="/repo/${JUDGE_WORKSHOP}/${JUDGE_TASK}"
SOLUTIONS_DIR=$(trim "$SOLUTIONS_DIR")
INPUT_FILE="/judge/input.txt"

# Check if solutions directory exists
Expand Down
34 changes: 17 additions & 17 deletions internal/judge/docker.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package judge

import (
"bytes"
"context"
"fmt"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/pkg/stdcopy"
"github.com/gurkengewuerz/GitCodeJudge/internal/config"
"github.com/gurkengewuerz/GitCodeJudge/internal/models"
log "github.com/sirupsen/logrus"
"io"
"os"
"path/filepath"
"time"

"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"bytes"
"context"
"fmt"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/pkg/stdcopy"
"github.com/gurkengewuerz/GitCodeJudge/internal/config"
"github.com/gurkengewuerz/GitCodeJudge/internal/models"
log "github.com/sirupsen/logrus"
"io"
"os"
"path/filepath"
"time"

"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
)

type DockerExecutor struct {
Expand Down Expand Up @@ -97,8 +97,8 @@ func (e *DockerExecutor) RunCode(ctx context.Context, testCase models.TestCase)
&container.Config{
Image: config.CFG.DockerImage,
Env: []string{
fmt.Sprintf("JUDGE_WORKSHOP=%s", testCase.Solution.Workshop),
fmt.Sprintf("JUDGE_TASK=%s", testCase.Solution.Task),
fmt.Sprintf("JUDGE_WORKSHOP=%s", Trim(testCase.Solution.Workshop)),
fmt.Sprintf("JUDGE_TASK=%s", Trim(testCase.Solution.Task)),
},
WorkingDir: "/judge",
},
Expand Down
2 changes: 1 addition & 1 deletion internal/judge/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (p *Pool) worker() {
}

owner, repo := parts[0], parts[1]
targetURL := fmt.Sprintf("%s/results/%s", submission.BaseURL, submission.CommitID)
targetURL := fmt.Sprintf("%s/results/%s", appConfig.CFG.BaseURL, submission.CommitID)

if err := submission.GitClient.PostStarting(owner, repo, submission.CommitID, targetURL, status.StatusNone, "Judge started"); err != nil {
log.WithFields(fields).WithError(err).Error("Failed to post starting")
Expand Down
1 change: 0 additions & 1 deletion internal/models/submission.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type Submission struct {
CloneURL string
Solutions []Solution
GitClient *gitea.GiteaClient
BaseURL string
}

type TestResult struct {
Expand Down

0 comments on commit 6e21aa3

Please sign in to comment.