forked from LearningOS/template-2024a-rcore
-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (93 loc) · 3.46 KB
/
build.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Jobs
on: [push]
env:
CARGO_TERM_COLOR: always
rust_toolchain: nightly
jobs:
build-doc:
if: github.repository == 'LearningOS/rCore-Camp-Code-2024A'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build doc
run: |
git clone https://github.com/LearningOS/rCore-Tutorial-Test-2024A.git user
cd os
make
cargo doc --no-deps --verbose
- name: Push to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./os/target/riscv64gc-unknown-none-elf/doc
destination_dir: ${{ github.ref_name }}
basic-test:
runs-on: ubuntu-latest
outputs:
points: ${{ steps.end.outputs.points}}
container:
image: duskmoon/dev-env:rcore-ci
steps:
- uses: actions/checkout@v4
- name: Run tests
run: |
qemu-system-riscv64 --version
rustup target add riscv64gc-unknown-none-elf
git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
git clone https://github.com/LearningOS/rCore-Tutorial-Checker-2024A.git ci-user
git clone https://github.com/LearningOS/rCore-Tutorial-Test-2024A.git ci-user/user
ID=`git rev-parse --abbrev-ref HEAD | grep -oP 'ch\K[0-9]'`
# cd ci-user && make test CHAPTER=$ID passwd=${{ secrets.BASE_TEST_TOKEN }}
cd ci-user && make test CHAPTER=$ID passwd=${{ secrets.BASE_TEST_TOKEN }} > ../output.txt
cat ../output.txt
- name: end
id: end
run: |
cat output.txt | grep -a "Test passed" | grep -oP "\d{1,}/\d{1,}" | xargs -i echo "points={}"
cat output.txt | grep -a "Test passed" | grep -oP "\d{1,}/\d{1,}" | xargs -i echo "points={}" >> $GITHUB_OUTPUT
deploy:
if: github.repository != 'LearningOS/rCore-Camp-Code-2024A'
name: Deploy to pages
needs: basic-test
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v3
continue-on-error: true
with:
ref: 'gh-pages'
- name: Save Log File
uses: yfblock/multi-rank-log@main
with:
public-dir: classroom
points: ${{ needs.basic-test.outputs.points }}
- name: GitHub Pages
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: ./classroom
keep_history: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: check score
env:
course_id: ${{ secrets.RCORE_2024_AUTUMN_COURSE_ID }}
post_api: ${{ secrets.RUSTLINGS_2024_AUTUMN_POST_API }}
run: |
score=$(( $(grep -o 'ch' classroom/latest.json | wc -l) * 100))
cat classroom/latest.json
echo $score
github_user="${{ github.actor }}"
# 生成 JSON 结果
score_json=$(jq -n \
--arg channel "github" \
--argjson courseId "$course_id" \
--arg name "$github_user" \
--argjson score "$score" \
--argjson totalScore 500 \
'{channel: $channel, courseId: $courseId, name: $name, score: $score, totalScore: $totalScore}')
curl -X POST https://"$post_api" \
-H "accept: application/json;charset=utf-8" \
-H "Content-Type: application/json" \
-d "$score_json" \
-v