WIP: feat: scoreboard (#15) #31
|
@ -26,6 +26,13 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- make prepare-test
|
- make prepare-test
|
||||||
- make test
|
- make test
|
||||||
|
- name: scoreboard
|
||||||
|
environment:
|
||||||
|
GITEA_ACCESS_TOKEN:
|
||||||
|
from_secret: gitea-token
|
||||||
|
GITEA_ORG_NAME: FOCS-dev
|
||||||
|
commands:
|
||||||
|
- 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
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -125,3 +125,5 @@ $RECYCLE.BIN/
|
||||||
build/
|
build/
|
||||||
!examples/**/*.out
|
!examples/**/*.out
|
||||||
tmp/
|
tmp/
|
||||||
|
repos/
|
||||||
|
score.json
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/scoreboard"
|
||||||
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,6 +63,8 @@ func readStageResults(t *testing.T, path string) []stage.StageResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(t *testing.T) {
|
func TestMain(t *testing.T) {
|
||||||
|
scoreboard := scoreboard.Scoreboard{}
|
||||||
|
scoreboard.Init()
|
||||||
var tests []string
|
var tests []string
|
||||||
root := "../../tmp/submodules/JOJ3-examples/examples/"
|
root := "../../tmp/submodules/JOJ3-examples/examples/"
|
||||||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||||
|
@ -107,6 +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(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) {
|
||||||
|
@ -117,4 +121,7 @@ func TestMain(t *testing.T) {
|
||||||
compareStageResults(t, stageResults, expectedStageResults, regex)
|
compareStageResults(t, stageResults, expectedStageResults, regex)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if !t.Failed() {
|
||||||
|
scoreboard.SaveFile("../../score.json")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
40
internal/scoreboard/scoreboard.go
Normal file
40
internal/scoreboard/scoreboard.go
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package scoreboard
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TestRecord struct {
|
||||||
|
TestName string `json:"testname"`
|
||||||
|
StageResults []stage.StageResult `json:"stageresults"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ScoreboardData struct {
|
||||||
|
TestRecords []TestRecord `json:"testrecords"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Scoreboard struct {
|
||||||
|
scoreboard ScoreboardData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Scoreboard) Init() {
|
||||||
|
b.scoreboard.TestRecords = make([]TestRecord, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Scoreboard) AddScore(testname string, results []stage.StageResult) {
|
||||||
|
b.scoreboard.TestRecords = append(b.scoreboard.TestRecords,
|
||||||
|
TestRecord{TestName: testname, StageResults: results})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Scoreboard) SaveFile(filePath string) {
|
||||||
|
json_file, _ := os.Create(filePath)
|
||||||
|
defer json_file.Close()
|
||||||
|
|
||||||
|
encoder := json.NewEncoder(json_file)
|
||||||
|
encoder.SetEscapeHTML(false)
|
||||||
|
encoder.SetIndent("", " ")
|
||||||
|
_ = encoder.Encode(b.scoreboard)
|
||||||
|
}
|
25
scripts/submit_scoreboard_failedtable.sh
Normal file
25
scripts/submit_scoreboard_failedtable.sh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
export ORIG_HOME=$(grep ^${USER}: /etc/passwd |cut -d : -f 6)
|
||||||
|
PATH=$PATH:$ORIG_HOME/.local/bin
|
||||||
|
|
||||||
|
# if echo "${DRONE_REPO_NAME}" | grep -q '-'; then
|
||||||
|
# SUBMITTER_NAME=$(echo "${DRONE_REPO_NAME}" | cut -d'-' -f1);
|
||||||
|
# else
|
||||||
|
# SUBMITTER_NAME=${DRONE_REPO_NAME};
|
||||||
|
# fi
|
||||||
|
SUBMITTER_NAME=${DRONE_REPO_NAME}
|
||||||
|
|
||||||
|
mkdir repos
|
||||||
|
|
||||||
|
echo 'CANVAS_ACCESS_TOKEN=""' > .env
|
||||||
|
echo 'CANVAS_COURSE_ID=0' >> .env
|
||||||
|
echo 'GITEA_ACCESS_TOKEN=$GITEA_ACCESS_TOKEN' >> .env
|
||||||
|
echo 'GITEA_ORG_NAME=$GITEA_ORG_NAME' >> .env
|
||||||
|
echo 'MATTERMOST_TEAM=""' >> .env
|
||||||
|
echo 'MATTERMOST_ACCESS_TOKEN=""' >> .env
|
||||||
|
echo 'MATTERMOST_TEACHING_TEAM=[]' >> .env
|
||||||
|
|
||||||
|
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 .env
|
Loading…
Reference in New Issue
Block a user