6 Commits

Author SHA1 Message Date
86b8d83643 fix license
All checks were successful
Release / Build & publish (push) Successful in 33s
2026-04-07 09:57:55 +03:00
8aea2806e0 fix license
Some checks failed
Release / Build & publish (push) Failing after 21s
2026-04-07 09:56:30 +03:00
edfdc40aea fix repo miss vsix
All checks were successful
Release / Build & publish (push) Successful in 1m35s
2026-04-07 09:54:00 +03:00
e4ab003a9d add mac, fix vsix release
All checks were successful
Release / Build & publish (push) Successful in 37s
2026-04-07 09:51:53 +03:00
00e1c9195c add sources, add visx to release flow
All checks were successful
Release / Build & publish (push) Successful in 1m26s
2026-04-06 19:50:16 +03:00
9b9a790618 fork bomb handling and gdb support
All checks were successful
Release / Build & publish (push) Successful in 7s
2026-04-06 17:59:26 +03:00
11 changed files with 151 additions and 9 deletions

View File

@@ -2,8 +2,6 @@ name: judge
run-name: "Sum tests (${{ inputs.student_url || github.repository }})"
on:
push:
pull_request:
workflow_dispatch:
inputs:
student_url:
@@ -143,7 +141,7 @@ jobs:
# runner auto-detects .exe suffix on Windows
judge "$SUITE_FILE" . --json $WRAPPER_ARG > "$GITHUB_WORKSPACE/${REPORT_NAME}.json" || true
judge "$SUITE_FILE" . $WRAPPER_ARG || true
judge "$SUITE_FILE" . $WRAPPER_ARG
- name: Upload report
if: ${{ always() }}

View File

@@ -18,20 +18,30 @@ jobs:
with:
go-version: '1.22'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cross-compile
shell: bash
run: |
tag="${GITHUB_REF#refs/tags/}"
mkdir -p dist
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "dist/judge-linux-amd64" ./cmd/cli
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o "dist/judge-windows-amd64.exe" ./cmd/cli
ls -la dist/
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o "dist/judge-darwin-arm64" ./cmd/cli
- name: Build VS Code extension
shell: bash
run: |
npm install -g @vscode/vsce
cd editor/vscode-jdg
vsce package --allow-missing-repository -o "../../dist/jdg-language.vsix"
- name: Create release
uses: https://gitea.com/actions/gitea-release-action@main
with:
files: |-
dist/judge-linux-amd64
dist/judge-windows-amd64.exe
dist/*
api_key: ${{ secrets.RELEASE_TOKEN }}
title: ${{ github.ref_name }}

View File

@@ -9,6 +9,7 @@ type File struct {
BuildDarwin string
Timeout time.Duration
Binary string // executable name produced by build (default: solution)
Sources string // glob pattern for source files, expanded as $SOURCES in build
NormalizeCRLF bool // strip \r before matching stdout/stderr/outFiles
TrimTrailingWS bool // trim trailing whitespace on each line before matching

View File

@@ -128,6 +128,17 @@ func (p *Parser) parseFile() (*File, error) {
}
f.Binary = s.Value
case "sources":
p.advance()
if _, err := p.expect(TOKEN_ASSIGN); err != nil {
return nil, err
}
s, err := p.expect(TOKEN_STRING)
if err != nil {
return nil, err
}
f.Sources = s.Value
case "normalize_crlf":
p.advance()
if _, err := p.expect(TOKEN_ASSIGN); err != nil {

BIN
editor/.DS_Store vendored

Binary file not shown.

21
editor/vscode-jdg/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Mikhail Kornilovich
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -4,6 +4,7 @@
"description": "Syntax highlighting for judge test-suite files",
"version": "0.1.0",
"publisher": "judge",
"repository": {"type": "git", "url": "https://gitea.mkorn.me/admin/judge"},
"engines": { "vscode": "^1.60.0" },
"categories": ["Programming Languages"],
"contributes": {

View File

@@ -53,7 +53,7 @@
},
"top-keywords": {
"name": "keyword.control.jdg",
"match": "\\b(?:build|build_linux|build_windows|build_darwin|binary|timeout|normalize_crlf|trim_trailing_ws|group|test|pattern|env|file|outFile)\\b"
"match": "\\b(?:build|build_linux|build_windows|build_darwin|binary|sources|timeout|normalize_crlf|trim_trailing_ws|group|test|pattern|env|file|outFile)\\b"
},
"block-keywords": {
"name": "variable.parameter.jdg",

18
runner/process_unix.go Normal file
View File

@@ -0,0 +1,18 @@
//go:build !windows
package runner
import (
"os/exec"
"syscall"
)
func setProcessGroup(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
func killProcessGroup(cmd *exec.Cmd) {
if cmd.Process != nil {
syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
}
}

20
runner/process_windows.go Normal file
View File

@@ -0,0 +1,20 @@
//go:build windows
package runner
import (
"os/exec"
"syscall"
)
func setProcessGroup(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
}
}
func killProcessGroup(cmd *exec.Cmd) {
if cmd.Process != nil {
cmd.Process.Kill()
}
}

View File

@@ -119,9 +119,48 @@ func (r *Runner) buildCommand() string {
return "go build -o solution ."
}
func (r *Runner) findSources() (string, error) {
if r.file.Sources == "" {
return "", nil
}
var files []string
err := filepath.Walk(r.cfg.WorkDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
if info.Name() == ".git" || info.Name() == ".gitea" {
return filepath.SkipDir
}
return nil
}
matched, _ := filepath.Match(r.file.Sources, info.Name())
if matched {
rel, _ := filepath.Rel(r.cfg.WorkDir, path)
files = append(files, filepath.ToSlash(rel))
}
return nil
})
if err != nil {
return "", fmt.Errorf("source discovery: %w", err)
}
if len(files) == 0 {
return "", fmt.Errorf("no files matching %q found", r.file.Sources)
}
return strings.Join(files, " "), nil
}
func (r *Runner) build() (string, error) {
buildCmd := r.buildCommand()
sources, err := r.findSources()
if err != nil {
return "", err
}
if sources != "" {
buildCmd = strings.ReplaceAll(buildCmd, "$SOURCES", sources)
}
ctx := context.Background()
if r.file.Timeout > 0 {
var cancel context.CancelFunc
@@ -131,6 +170,7 @@ func (r *Runner) build() (string, error) {
cmd := shellCommand(ctx, buildCmd)
cmd.Dir = r.cfg.WorkDir
setProcessGroup(cmd)
cmd.Env = os.Environ()
var out bytes.Buffer
@@ -138,6 +178,7 @@ func (r *Runner) build() (string, error) {
cmd.Stderr = &out
if err := cmd.Run(); err != nil {
killProcessGroup(cmd)
return out.String(), fmt.Errorf("build failed: %w\n%s", err, out.String())
}
return out.String(), nil
@@ -249,8 +290,13 @@ func (r *Runner) runTest(t *dsl.Test) *TestResult {
wrapper = t.Wrapper
}
cmd := buildExecCmd(ctx, wrapper, r.binary, t.Args)
args := t.Args
if wrapper != "" {
args = absoluteArgs(tmpDir, args)
}
cmd := buildExecCmd(ctx, wrapper, r.binary, args)
cmd.Dir = tmpDir
setProcessGroup(cmd)
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "LC_ALL=C", "LANG=C")
@@ -271,6 +317,10 @@ func (r *Runner) runTest(t *dsl.Test) *TestResult {
runErr := cmd.Run()
tr.Elapsed = time.Since(start)
if ctx.Err() == context.DeadlineExceeded {
killProcessGroup(cmd)
}
tr.ActualStdout = normalizeOutput(stdout.String(), r.file)
tr.ActualStderr = normalizeOutput(stderr.String(), r.file)
@@ -327,6 +377,18 @@ func (r *Runner) runTest(t *dsl.Test) *TestResult {
return tr
}
func absoluteArgs(dir string, args []string) []string {
out := make([]string, len(args))
for i, a := range args {
if !filepath.IsAbs(a) {
out[i] = filepath.Join(dir, a)
} else {
out[i] = a
}
}
return out
}
func buildExecCmd(ctx context.Context, wrapper, binary string, args []string) *exec.Cmd {
if wrapper == "" {
return exec.CommandContext(ctx, binary, args...)