forked from livstyle/rustlings-template
-
Notifications
You must be signed in to change notification settings - Fork 9
73 lines (69 loc) · 2.12 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
67
68
69
70
71
72
73
name: GitHub Classroom Workflow
on:
push:
branches: [ main ]
paths-ignore:
- 'README.md'
- '.github/**'
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: checkouttoml
run: curl -o check.toml https://raw.githubusercontent.com/livstyle/os-autograding-rust/main/check.toml
- name: Run tests
run: cargo test --test check --verbose
- uses: yfblock/os-autograding@master
id: autograding
with:
outputFile: .github/result/check_result.json
deploy:
name: Deploy to pages
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
continue-on-error: true
with:
ref: 'gh-pages'
- name: Save Log File
run: |
mkdir autograding_logs
cd autograding_logs
if [ -f "../latest.json" ]; then
cp ../latest.json older.json
else
echo "{}" > older.json
fi
FILE_NAME=`date +%Y_%m_%d_%H_%M_%S`.txt
echo -ne "${{ needs.build.outputs.details }}\n" > $FILE_NAME
echo -ne "Points: ${{ needs.build.outputs.points }}" >> $FILE_NAME
cat older.json | jq ".default |= \"$FILE_NAME\"" > latest.json
rm older.json
echo -ne "# Got Points\n" > README.md
echo "![Points bar](../../blob/gh-pages/points-badge.svg)" >> README.md
- name: Make points svg
uses: markpatterson27/points-bar@v1
with:
points: '${{ needs.build.outputs.points }}'
path: 'autograding_logs/points-badge.svg'
type: 'badge'
- name: GitHub Pages
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: autograding_logs
keep_history: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}