generated from LearningOS/rustlings-100exercises-template
-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (57 loc) · 1.92 KB
/
rust.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: GitHub Classroom Workflow
on:
push:
branches: [ main ]
paths-ignore:
- 'README.md'
pull_request:
branches: [ main ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
TZ: Asia/Shanghai # 设置时区
jobs:
build:
name: Autograding
runs-on: ubuntu-latest
outputs:
details: ${{ steps.autograding.outputs.details }}
points: ${{ steps.autograding.outputs.points}}
steps:
- uses: actions/checkout@v3
- name: Run tests
run: cargo test --test cicv --verbose
- uses: yfblock/os-autograding@master
id: autograding
with:
outputFile: .github/result/check_result.json
- name: Generate summary JSON
run: |
outfile=".github/result/check_result.json"
summary_file=".github/result/summary.json"
# 提取需要的值
total_exercations=$(jq '.statistics.total_exercations' $outfile)
total_succeeds=$(jq '.statistics.total_succeeds' $outfile)
github_user="${{ github.actor }}"
# 生成新的 JSON 内容
new_json=$(jq -n \
--arg channel "github" \
--argjson courseId 1558 \
--arg ext "aaa" \
--arg name "$github_user" \
--argjson score "$total_succeeds" \
--argjson totalScore "$total_exercations" \
'{channel: $channel, courseId: $courseId, ext: $ext, name: $name, score: $score, totalScore: $totalScore}')
# 保存新的 JSON 文件
echo "$new_json" > $summary_file
# 打印新的 JSON 文件到终端
cat $summary_file
- name: Post summary JSON to remote API
run: |
summary_file=".github/result/summary.json"
# 发送 POST 请求
curl -X POST "https://api.learningcamp.cn/web/api/courseRank/createByThird" \
-H "accept: application/json;charset=utf-8" \
-H "Content-Type: application/json" \
-d "$(cat $summary_file)" \
-v