WIP: feat: scoreboard (#15) #31
|
@ -32,7 +32,7 @@ steps:
|
||||||
from_secret: gitea-token
|
from_secret: gitea-token
|
||||||
GITEA_ORG_NAME: FOCS-dev
|
GITEA_ORG_NAME: FOCS-dev
|
||||||
commands:
|
commands:
|
||||||
- bash scripts/submit_scoreboard.sh
|
- bash scripts/submit_scoreboard_failedtable.sh
|
||||||
- name: store
|
- name: store
|
||||||
commands:
|
commands:
|
||||||
- cp build/joj3 /home/drone/.local/bin/joj3
|
- cp build/joj3 /home/drone/.local/bin/joj3
|
||||||
|
|
|
@ -62,13 +62,6 @@ func readStageResults(t *testing.T, path string) []stage.StageResult {
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeStringPrefix(s, prefix string) string {
|
|
||||||
if strings.HasPrefix(s, prefix) {
|
|
||||||
return s[len(prefix):]
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMain(t *testing.T) {
|
func TestMain(t *testing.T) {
|
||||||
scoreboard := scoreboard.Scoreboard{}
|
scoreboard := scoreboard.Scoreboard{}
|
||||||
scoreboard.Init()
|
scoreboard.Init()
|
||||||
|
@ -117,7 +110,7 @@ func TestMain(t *testing.T) {
|
||||||
defer os.Remove(outputFile)
|
defer os.Remove(outputFile)
|
||||||
main()
|
main()
|
||||||
stageResults := readStageResults(t, outputFile)
|
stageResults := readStageResults(t, outputFile)
|
||||||
scoreboard.AddScore(removeStringPrefix(tt, "/examples/"), stageResults)
|
scoreboard.AddScore(strings.TrimPrefix(tt, "/examples/"), stageResults)
|
||||||
regex := true
|
regex := true
|
||||||
expectedFile := "expected_regex.json"
|
expectedFile := "expected_regex.json"
|
||||||
if _, err := os.Stat(expectedFile); os.IsNotExist(err) {
|
if _, err := os.Stat(expectedFile); os.IsNotExist(err) {
|
||||||
|
|
|
@ -7,13 +7,13 @@ import (
|
||||||
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StageRecord struct {
|
type TestRecord struct {
|
||||||
StageName string `json:"stagename"`
|
TestName string `json:"testname"`
|
||||||
StageResults []stage.StageResult `json:"stageresults"`
|
StageResults []stage.StageResult `json:"stageresults"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScoreboardData struct {
|
type ScoreboardData struct {
|
||||||
StageRecords []StageRecord `json:"stagerecords"`
|
TestRecords []TestRecord `json:"testrecords"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Scoreboard struct {
|
type Scoreboard struct {
|
||||||
|
@ -21,12 +21,12 @@ type Scoreboard struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Scoreboard) Init() {
|
func (b *Scoreboard) Init() {
|
||||||
b.scoreboard.StageRecords = make([]StageRecord, 0)
|
b.scoreboard.TestRecords = make([]TestRecord, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Scoreboard) AddScore(stagename string, results []stage.StageResult) {
|
func (b *Scoreboard) AddScore(testname string, results []stage.StageResult) {
|
||||||
b.scoreboard.StageRecords = append(b.scoreboard.StageRecords,
|
b.scoreboard.TestRecords = append(b.scoreboard.TestRecords,
|
||||||
StageRecord{StageName: stagename, StageResults: results})
|
TestRecord{TestName: testname, StageResults: results})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Scoreboard) SaveFile(filePath string) {
|
func (b *Scoreboard) SaveFile(filePath string) {
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
export ORIG_HOME=$(grep ^${USER}: /etc/passwd |cut -d : -f 6)
|
export ORIG_HOME=$(grep ^${USER}: /etc/passwd |cut -d : -f 6)
|
||||||
PATH=$PATH:$ORIG_HOME/.local/bin
|
PATH=$PATH:$ORIG_HOME/.local/bin
|
||||||
|
|
||||||
if echo "${DRONE_REPO_NAME}" | grep -q '-'; then
|
# if echo "${DRONE_REPO_NAME}" | grep -q '-'; then
|
||||||
SUBMITTER_NAME=$(echo "${DRONE_REPO_NAME}" | cut -d'-' -f1);
|
# SUBMITTER_NAME=$(echo "${DRONE_REPO_NAME}" | cut -d'-' -f1);
|
||||||
else
|
# else
|
||||||
SUBMITTER_NAME=${DRONE_REPO_NAME};
|
# SUBMITTER_NAME=${DRONE_REPO_NAME};
|
||||||
fi
|
# fi
|
||||||
|
SUBMITTER_NAME=${DRONE_REPO_NAME}
|
||||||
|
|
||||||
mkdir repos
|
mkdir repos
|
||||||
|
|
||||||
|
@ -19,5 +20,6 @@ echo 'MATTERMOST_ACCESS_TOKEN=""' >> .env
|
||||||
echo 'MATTERMOST_TEACHING_TEAM=[]' >> .env
|
echo 'MATTERMOST_TEACHING_TEAM=[]' >> .env
|
||||||
|
|
||||||
joint-teapot JOJ3-scoreboard "score.json" $SUBMITTER_NAME "" "JOJ3-examples" "JOJ3_dev.csv"
|
joint-teapot JOJ3-scoreboard "score.json" $SUBMITTER_NAME "" "JOJ3-examples" "JOJ3_dev.csv"
|
||||||
|
joint-teapot JOJ3-failed-table "score.json" "JOJ3-examples" $DRONE_REPO_NAME $DRONE_REMOTE_URL "JOJ3-failed.md"
|
||||||
rm score.json
|
rm score.json
|
||||||
rm .env
|
rm .env
|
Loading…
Reference in New Issue
Block a user