Compare commits

..

1 Commits

Author SHA1 Message Date
d59de7bbd8
test: これは違法コミットの一例 2024-09-15 16:37:32 +08:00
25 changed files with 64 additions and 96 deletions

31
.drone.yml Normal file
View File

@ -0,0 +1,31 @@
---
kind: pipeline
type: ssh
name: CI
server:
host: 111.186.59.59
user: drone
ssh_key:
from_secret: joj3-test
steps:
- name: prepare
commands:
- go env -w GOPROXY=https://goproxy.cn,direct
- whoami
- pwd
- env
- go version
- go env
- git status -v
- git log -1
- name: build
commands:
- make
- name: test
commands:
- make prepare-test
- make test
- name: store
commands:
- cp build/joj3 /home/drone/.local/bin/joj3

View File

@ -1,44 +0,0 @@
---
name: checks
on:
- push
- pull_request
jobs:
build:
container:
image: focs.ji.sjtu.edu.cn:5000/gitea/runner-images:ubuntu-latest
volumes:
- /home/actions/.ssh:/root/.ssh
steps:
- name: Check out repository code
uses: https://gitea.com/BoYanZh/checkout@focs
- name: Setup Go 1.23.1
run: |
wget -q https://studygolang.com/dl/golang/go1.23.1.linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
rm -rf go1.23.1.linux-amd64.tar.gz
echo "PATH=$PATH:/usr/local/go/bin:/root/go/bin" >> $GITHUB_ENV
- name: Display Go version
run: go version
- name: Prepare
run: |
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
chown -R root:root /root/.ssh
- name: Setup golangci-lint
run: |
wget -q https://ghp.ci/https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-linux-amd64.tar.gz
tar -C /tmp -xzf golangci-lint-1.61.0-linux-amd64.tar.gz
rm -rf golangci-lint-1.61.0-linux-amd64.tar.gz
mkdir -p /root/go/bin
mv /tmp/golangci-lint-1.61.0-linux-amd64/golangci-lint /root/go/bin
- name: Lint
run: make lint
- name: Build
run: make build
- name: Test
run: |
make prepare-test
make ci-test

View File

@ -1,4 +1,4 @@
.PHONY: all build clean lint prepare-test test ci-test .PHONY: all build clean prepare-test test
BUILD_DIR = ./build BUILD_DIR = ./build
TMP_DIR = ./tmp TMP_DIR = ./tmp
@ -15,17 +15,9 @@ clean:
rm -rf $(TMP_DIR)/* rm -rf $(TMP_DIR)/*
rm -rf *.out rm -rf *.out
lint:
golangci-lint run
prepare-test: prepare-test:
git submodule update --init --remote git submodule update --init --remote
test: test:
./scripts/prepare_test_repos.sh $(TMP_DIR) ./scripts/prepare_test_repos.sh $(TMP_DIR)
go test -coverprofile cover.out -v ./... go test -coverprofile cover.out -v ./...
ci-test:
./scripts/prepare_test_repos.sh $(TMP_DIR)
./scripts/run_foreach_test_repos.sh $(TMP_DIR) "sed -i '2i \ \ \"sandboxExecServer\": \"172.17.0.1:5051\",' conf.json"
go test -coverprofile cover.out -v ./...

View File

@ -61,20 +61,11 @@ type OptionalCmd struct {
} }
func parseConfFile(path string) (conf Conf, err error) { func parseConfFile(path string) (conf Conf, err error) {
d := &multiconfig.DefaultLoader{} m := multiconfig.NewWithPath(path)
d.Loader = multiconfig.MultiLoader( if err = m.Load(&conf); err != nil {
&multiconfig.TagLoader{},
&multiconfig.JSONLoader{Path: path},
)
d.Validator = multiconfig.MultiValidator(&multiconfig.RequiredValidator{})
if err = d.Load(&conf); err != nil {
slog.Error("parse stages conf", "error", err) slog.Error("parse stages conf", "error", err)
return return
} }
if err = d.Validate(&conf); err != nil {
slog.Error("validate stages conf", "error", err)
return
}
return return
} }
@ -94,6 +85,6 @@ func commitMsgToConf() (conf Conf, err error) {
msg := commit.Message msg := commit.Message
slog.Debug("commit msg to conf", "msg", msg) slog.Debug("commit msg to conf", "msg", msg)
// TODO: parse msg to conf name // TODO: parse msg to conf name
conf, err = parseConfFile("conf.json") conf, err = parseConfFile("conf.toml")
return return
} }

@ -1 +1 @@
Subproject commit 235d1980bb55c8ec231ab03933cf8e8335344b81 Subproject commit 6084f4dc39929257f35eb2467b5aa105ceb03e81

@ -1 +1 @@
Subproject commit fc02680432a9003d623970187acce73276ce03b5 Subproject commit 4e5fab93e5a0ce67c8f40fef1e8f4cab7018fc5d

@ -1 +1 @@
Subproject commit 3a0760f2442723eb77eafacbf89b0d25d62eb607 Subproject commit 1512cb5f20473a598d7504a08dacff3d6406b983

@ -1 +1 @@
Subproject commit 578be035a0aedc0d9b5ffe5f40d4162e6483b6d0 Subproject commit 40fe2dbef18ac5188f72fe788426e3d9c8aa88ae

@ -1 +1 @@
Subproject commit 80ec230f63267a10777ae58ebb632709fc562e85 Subproject commit 1ec92f39ce2fac82356e79ae08c457784769d49c

@ -1 +1 @@
Subproject commit 13a3d05163213ce44c1ec638d4a409ed9db90530 Subproject commit af990327ab095c22a383448ad70d915f8d10490b

@ -1 +1 @@
Subproject commit 7f6f6e881d39e870e51afb3fd36fdbef20b9cb35 Subproject commit ac7a2fc912fb51af156cd4babb7e72148ebe1c14

@ -1 +1 @@
Subproject commit 1492b43605a17850071d4e6674151719ae55e761 Subproject commit a236c7ea934de5e59525fa27e4211f4a48dbbf93

@ -1 +1 @@
Subproject commit 415ab7e9d8e74a5290eec18bec54b3a6d727d3d7 Subproject commit 36bb5fb15f100078bd3af1027017825932f8c24b

@ -1 +1 @@
Subproject commit 02de953cbc841afb3f53d0d4096b423f91d78593 Subproject commit 62c43fe51666417c7cbb227d6daaeee7189b6944

@ -1 +1 @@
Subproject commit 3161962adba8d6f2663963eb5c39578cb7874ab8 Subproject commit 5c2cd9e6b31c6f223ac5d3ee5b07f11fbd378427

@ -1 +1 @@
Subproject commit 01b362e3bd5156211f8152237b101301560433b8 Subproject commit fc9828bde135e53a7ef3e6367c708d9a000afc74

@ -1 +1 @@
Subproject commit 0648e32a8932e561e102f336766ca18165866ab8 Subproject commit a49a6aa29d3dcb0509e8de540db0781aca596f26

@ -1 +1 @@
Subproject commit 5e25b932fc3950f382c8533e018520b04542af4a Subproject commit 2f455dca9d28e39926e68b9b13eef39b0a9f67fc

@ -1 +1 @@
Subproject commit 1f53f4df209662a30f7005a925fff0f0e3d94b13 Subproject commit 9938ef006e25c8caea24493172e60a58380c8df4

@ -1 +1 @@
Subproject commit 244a63f54397196f9f9a08114f4eef279093f2a6 Subproject commit 96d02348a20a5a244cd4f82e94a04dccfe3f009c

@ -1 +1 @@
Subproject commit 980baf11df313e659fb4b1dea1a126add15ac547 Subproject commit aa5bf333e30c9c0175e021c001d85f90092d7d1a

@ -1 +1 @@
Subproject commit 1d886f8754d0a22471405580d231b2691b929bfd Subproject commit ed17357671e1c6f8aa7f534a482d9b2fac76d959

View File

@ -5,7 +5,6 @@ import (
) )
type Conf struct { type Conf struct {
Score int
Comment string Comment string
} }
@ -20,7 +19,7 @@ func (*Dummy) Run(results []stage.ExecutorResult, confAny any) (
} }
var res []stage.ParserResult var res []stage.ParserResult
for range results { for range results {
res = append(res, stage.ParserResult{Score: conf.Score, Comment: conf.Comment}) res = append(res, stage.ParserResult{Score: 0, Comment: conf.Comment})
} }
return res, false, nil return res, false, nil
} }

View File

@ -7,24 +7,22 @@ import (
"github.com/criyle/go-judge/envexec" "github.com/criyle/go-judge/envexec"
) )
type Conf struct { type Conf struct{}
Score int
Comment string
}
type ResultStatus struct{} type ResultStatus struct{}
func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) ( func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error, []stage.ParserResult, bool, error,
) { ) {
conf, err := stage.DecodeConf[Conf](confAny) // TODO: more conf options
_, err := stage.DecodeConf[Conf](confAny)
if err != nil { if err != nil {
return nil, true, err return nil, true, err
} }
forceQuit := false forceQuit := false
var res []stage.ParserResult var res []stage.ParserResult
for _, result := range results { for _, result := range results {
comment := conf.Comment comment := ""
if result.Status != stage.Status(envexec.StatusAccepted) { if result.Status != stage.Status(envexec.StatusAccepted) {
forceQuit = true forceQuit = true
comment = fmt.Sprintf( comment = fmt.Sprintf(
@ -32,7 +30,7 @@ func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) (
) )
} }
res = append(res, stage.ParserResult{ res = append(res, stage.ParserResult{
Score: conf.Score, Score: 0,
Comment: comment, Comment: comment,
}) })
} }

View File

@ -3,6 +3,7 @@ package stage
import ( import (
"fmt" "fmt"
"strconv" "strconv"
"time"
"github.com/criyle/go-judge/envexec" "github.com/criyle/go-judge/envexec"
) )
@ -125,8 +126,8 @@ func (r ExecutorResult) String() string {
Status Status Status Status
ExitStatus int ExitStatus int
Error string Error string
Time uint64 Time time.Duration
RunTime uint64 RunTime time.Duration
Memory envexec.Size Memory envexec.Size
Files map[string]string Files map[string]string
FileIDs map[string]string FileIDs map[string]string
@ -136,8 +137,8 @@ func (r ExecutorResult) String() string {
Status: r.Status, Status: r.Status,
ExitStatus: r.ExitStatus, ExitStatus: r.ExitStatus,
Error: r.Error, Error: r.Error,
Time: r.Time, Time: time.Duration(r.Time),
RunTime: r.RunTime, RunTime: time.Duration(r.RunTime),
Memory: envexec.Size(r.Memory), Memory: envexec.Size(r.Memory),
Files: make(map[string]string), Files: make(map[string]string),
FileIDs: r.FileIDs, FileIDs: r.FileIDs,