diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 9f009f4..0000000 --- a/.drone.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -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 diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 0000000..a7a5081 --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,44 @@ +--- +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 diff --git a/Makefile b/Makefile index cea7f45..f54d3c0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build clean prepare-test test +.PHONY: all build clean lint prepare-test test ci-test BUILD_DIR = ./build TMP_DIR = ./tmp @@ -15,9 +15,17 @@ clean: rm -rf $(TMP_DIR)/* rm -rf *.out +lint: + golangci-lint run + prepare-test: git submodule update --init --remote test: ./scripts/prepare_test_repos.sh $(TMP_DIR) 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 ./... diff --git a/internal/stage/model.go b/internal/stage/model.go index cb33462..dba945a 100644 --- a/internal/stage/model.go +++ b/internal/stage/model.go @@ -3,7 +3,6 @@ package stage import ( "fmt" "strconv" - "time" "github.com/criyle/go-judge/envexec" ) @@ -126,8 +125,8 @@ func (r ExecutorResult) String() string { Status Status ExitStatus int Error string - Time time.Duration - RunTime time.Duration + Time uint64 + RunTime uint64 Memory envexec.Size Files map[string]string FileIDs map[string]string @@ -137,8 +136,8 @@ func (r ExecutorResult) String() string { Status: r.Status, ExitStatus: r.ExitStatus, Error: r.Error, - Time: time.Duration(r.Time), - RunTime: time.Duration(r.RunTime), + Time: r.Time, + RunTime: r.RunTime, Memory: envexec.Size(r.Memory), Files: make(map[string]string), FileIDs: r.FileIDs,