Compare commits
No commits in common. "3780ae004beb6f179ef42617c2de60a1d248d09d" and "d56e3e5ebc642b67017318a3f2b3f5d05b902bc5" have entirely different histories.
3780ae004b
...
d56e3e5ebc
|
@ -1,7 +1,6 @@
|
|||
package stage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
||||
|
@ -69,24 +68,19 @@ func generateStages(conf *conf.Conf, group string) ([]stage.Stage, error) {
|
|||
return stages, nil
|
||||
}
|
||||
|
||||
func newErrorStageResults(err error) []stage.StageResult {
|
||||
return []stage.StageResult{
|
||||
func Run(conf *conf.Conf, group string) (
|
||||
stageResults []stage.StageResult, forceQuit bool, err error,
|
||||
) {
|
||||
stageResultsOnError := []stage.StageResult{
|
||||
{
|
||||
Name: "Internal Error",
|
||||
Results: []stage.ParserResult{{
|
||||
Score: 0,
|
||||
Comment: "JOJ3 internal error, " +
|
||||
"check the log in Gitea Actions.\n" +
|
||||
fmt.Sprintf("Error: `%s`", err),
|
||||
Score: 0,
|
||||
Comment: "JOJ3 internal error, check the log in Gitea Actions.",
|
||||
}},
|
||||
ForceQuit: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func Run(conf *conf.Conf, group string) (
|
||||
stageResults []stage.StageResult, forceQuit bool, err error,
|
||||
) {
|
||||
executors.InitWithConf(
|
||||
conf.Stage.SandboxExecServer,
|
||||
conf.Stage.SandboxToken,
|
||||
|
@ -94,7 +88,7 @@ func Run(conf *conf.Conf, group string) (
|
|||
stages, err := generateStages(conf, group)
|
||||
if err != nil {
|
||||
slog.Error("generate stages", "error", err)
|
||||
stageResults = newErrorStageResults(err)
|
||||
stageResults = stageResultsOnError
|
||||
forceQuit = true
|
||||
return
|
||||
}
|
||||
|
@ -102,7 +96,7 @@ func Run(conf *conf.Conf, group string) (
|
|||
stageResults, forceQuit, err = stage.Run(stages)
|
||||
if err != nil {
|
||||
slog.Error("run stages", "error", err)
|
||||
stageResults = newErrorStageResults(err)
|
||||
stageResults = stageResultsOnError
|
||||
forceQuit = true
|
||||
return
|
||||
}
|
||||
|
|
|
@ -17,15 +17,13 @@ type Conf struct {
|
|||
Score int `default:"100"`
|
||||
RootDir string `default:"/w"`
|
||||
Matches []Match
|
||||
Stdout string `default:"stdout"`
|
||||
Stderr string `default:"stderr"`
|
||||
}
|
||||
|
||||
type ClangTidy struct{}
|
||||
|
||||
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||
stdout := executorResult.Files[conf.Stdout]
|
||||
stderr := executorResult.Files[conf.Stderr]
|
||||
stdout := executorResult.Files["stdout"]
|
||||
stderr := executorResult.Files["stderr"]
|
||||
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
||||
if !((executorResult.Status == stage.Status(envexec.StatusNonzeroExitStatus)) &&
|
||||
(executorResult.ExitStatus == 1)) {
|
||||
|
|
|
@ -19,8 +19,6 @@ type Match struct {
|
|||
type Conf struct {
|
||||
Score int `default:"100"`
|
||||
Matches []Match
|
||||
Stdout string `default:"stdout"`
|
||||
Stderr string `default:"stderr"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
|
@ -33,8 +31,8 @@ type Record struct {
|
|||
}
|
||||
|
||||
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||
// stdout := executorResult.Files[conf.Stdout]
|
||||
stderr := executorResult.Files[conf.Stderr]
|
||||
// stdout := executorResult.Files["stdout"]
|
||||
stderr := executorResult.Files["stderr"]
|
||||
|
||||
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
||||
return stage.ParserResult{
|
||||
|
|
|
@ -9,19 +9,14 @@ import (
|
|||
|
||||
type Healthcheck struct{}
|
||||
|
||||
type Conf struct {
|
||||
Stdout string `default:"stdout"`
|
||||
Stderr string `default:"stderr"`
|
||||
}
|
||||
|
||||
func Parse(executorResult stage.ExecutorResult, conf Conf) (stage.ParserResult, bool) {
|
||||
stdout := executorResult.Files[conf.Stdout]
|
||||
stderr := executorResult.Files[conf.Stderr]
|
||||
func Parse(executorResult stage.ExecutorResult) (stage.ParserResult, bool) {
|
||||
stdout := executorResult.Files["stdout"]
|
||||
stderr := executorResult.Files["stderr"]
|
||||
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
||||
return stage.ParserResult{
|
||||
Score: 0,
|
||||
Comment: fmt.Sprintf(
|
||||
"Unexpected executor status: %s.\n`stdout`: ```%s\n```\n`stderr`: ```%s\n```",
|
||||
"Unexpected executor status: %s.\nStdout: %s\nStderr: %s",
|
||||
executorResult.Status, stdout, stderr,
|
||||
),
|
||||
}, true
|
||||
|
@ -35,14 +30,10 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) (stage.ParserResult,
|
|||
func (*Healthcheck) Run(results []stage.ExecutorResult, confAny any) (
|
||||
[]stage.ParserResult, bool, error,
|
||||
) {
|
||||
conf, err := stage.DecodeConf[Conf](confAny)
|
||||
if err != nil {
|
||||
return nil, true, err
|
||||
}
|
||||
var res []stage.ParserResult
|
||||
forceQuit := false
|
||||
for _, result := range results {
|
||||
parserResult, forceQuitResult := Parse(result, *conf)
|
||||
parserResult, forceQuitResult := Parse(result)
|
||||
res = append(res, parserResult)
|
||||
forceQuit = forceQuit || forceQuitResult
|
||||
}
|
||||
|
|
|
@ -12,15 +12,13 @@ import (
|
|||
type Conf struct {
|
||||
Score int
|
||||
Comment string
|
||||
Stdout string `default:"stdout"`
|
||||
Stderr string `default:"stderr"`
|
||||
}
|
||||
|
||||
type Sample struct{}
|
||||
|
||||
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||
stdout := executorResult.Files[conf.Stdout]
|
||||
stderr := executorResult.Files[conf.Stderr]
|
||||
stdout := executorResult.Files["stdout"]
|
||||
stderr := executorResult.Files["stderr"]
|
||||
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
||||
return stage.ParserResult{
|
||||
Score: 0,
|
||||
|
|
Loading…
Reference in New Issue
Block a user