Skip to content

Commit 6242a23

Browse files
Initialize ch3
0 parents  commit 6242a23

38 files changed

+2234
-0
lines changed

.github/workflows/build.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Jobs
2+
3+
on: [push]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
rust_toolchain: nightly
8+
9+
jobs:
10+
build-doc:
11+
if: github.repository == 'LearningOS/rCore-Camp-Code-2024A'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Build doc
16+
run: |
17+
git clone https://github.com/LearningOS/rCore-Tutorial-Test-2024A.git user
18+
cd os
19+
make
20+
cargo doc --no-deps --verbose
21+
- name: Push to gh-pages
22+
uses: peaceiris/actions-gh-pages@v3
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
publish_dir: ./os/target/riscv64gc-unknown-none-elf/doc
26+
destination_dir: ${{ github.ref_name }}
27+
basic-test:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
points: ${{ steps.end.outputs.points}}
31+
container:
32+
image: duskmoon/dev-env:rcore-ci
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Run tests
36+
run: |
37+
qemu-system-riscv64 --version
38+
rustup target add riscv64gc-unknown-none-elf
39+
git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
40+
git clone https://github.com/LearningOS/rCore-Tutorial-Checker-2024A.git ci-user
41+
git clone https://github.com/LearningOS/rCore-Tutorial-Test-2024A.git ci-user/user
42+
ID=`git rev-parse --abbrev-ref HEAD | grep -oP 'ch\K[0-9]'`
43+
# cd ci-user && make test CHAPTER=$ID passwd=${{ secrets.BASE_TEST_TOKEN }}
44+
cd ci-user && make test CHAPTER=$ID passwd=${{ secrets.BASE_TEST_TOKEN }} > ../output.txt
45+
cat ../output.txt
46+
- name: end
47+
id: end
48+
run: |
49+
cat output.txt | grep -a "Test passed" | grep -oP "\d{1,}/\d{1,}" | xargs -i echo "points={}"
50+
cat output.txt | grep -a "Test passed" | grep -oP "\d{1,}/\d{1,}" | xargs -i echo "points={}" >> $GITHUB_OUTPUT
51+
deploy:
52+
if: github.repository != 'LearningOS/rCore-Camp-Code-2024A'
53+
name: Deploy to pages
54+
needs: basic-test
55+
runs-on: ubuntu-latest
56+
permissions: write-all
57+
steps:
58+
- uses: actions/checkout@v3
59+
continue-on-error: true
60+
with:
61+
ref: 'gh-pages'
62+
- name: Save Log File
63+
uses: yfblock/multi-rank-log@main
64+
with:
65+
public-dir: classroom
66+
points: ${{ needs.basic-test.outputs.points }}
67+
- name: GitHub Pages
68+
uses: crazy-max/ghaction-github-pages@v3
69+
with:
70+
target_branch: gh-pages
71+
build_dir: ./classroom
72+
keep_history: true
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
- name: check score
76+
env:
77+
course_id: ${{ secrets.RCORE_2024_AUTUMN_COURSE_ID }}
78+
post_api: ${{ secrets.RUSTLINGS_2024_AUTUMN_POST_API }}
79+
run: |
80+
score=$(( $(grep -o 'ch' classroom/latest.json | wc -l) * 100))
81+
cat classroom/latest.json
82+
echo $score
83+
84+
github_user="${{ github.actor }}"
85+
86+
# 生成 JSON 结果
87+
score_json=$(jq -n \
88+
--arg channel "github" \
89+
--argjson courseId "$course_id" \
90+
--arg name "$github_user" \
91+
--argjson score "$score" \
92+
--argjson totalScore 500 \
93+
'{channel: $channel, courseId: $courseId, name: $name, score: $score, totalScore: $totalScore}')
94+
95+
curl -X POST https://"$post_api" \
96+
-H "accept: application/json;charset=utf-8" \
97+
-H "Content-Type: application/json" \
98+
-d "$score

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.*/*
2+
!.github/*
3+
!.vscode/settings.json
4+
.idea
5+
Cargo.lock
6+
target
7+
os/src/link_app.S
8+
os/last-*
9+
os/Cargo.lock
10+
os/.gdb_history
11+
easy-fs/Cargo.lock
12+
easy-fs/target/*
13+
easy-fs-fuse/Cargo.lock
14+
easy-fs-fuse/target/*
15+
tools/
16+
pushall.sh
17+
*.bak
18+
19+
user/
20+
ci-user/

.gitlab-ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
default:
2+
image: tkf2023/env:rcore-ci
3+
4+
stages:
5+
- test
6+
7+
test-code-job:
8+
stage: test
9+
script:
10+
- git clone https://token:${rCoreCheckToken}@git.tsinghua.edu.cn/os-lab/2024a/ta/rcore-tutorial-checker-2024a.git ci-user
11+
- git clone https://token:${rCoreTestToken}@git.tsinghua.edu.cn/os-lab/2024a/public/rcore-tutorial-test-2024a.git ci-user/user
12+
- cd ci-user && make test CHAPTER=`echo $CI_COMMIT_REF_NAME | grep -oP 'ch\K[0-9]'` passwd=$BASE_TEST_TOKEN OFFLINE=1

.vscode/settings.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
// Prevent "can't find crate for `test`" error on no_std
3+
// Ref: https://github.com/rust-lang/vscode-rust/issues/729
4+
// For vscode-rust plugin users:
5+
"rust.target": "riscv64gc-unknown-none-elf",
6+
"rust.all_targets": false,
7+
// For Rust Analyzer plugin users:
8+
"rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
9+
"rust-analyzer.checkOnSave.allTargets": false,
10+
// "rust-analyzer.cargo.features": [
11+
// "board_qemu"
12+
// ]
13+
}

Dockerfile

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# syntax=docker/dockerfile:1
2+
# This Dockerfile is adapted from https://github.com/LearningOS/rCore-Tutorial-v3/blob/main/Dockerfile
3+
# with the following major updates:
4+
# - ubuntu 18.04 -> 20.04
5+
# - qemu 5.0.0 -> 7.0.0
6+
# - Extensive comments linking to relevant documentation
7+
FROM ubuntu:20.04
8+
9+
ARG QEMU_VERSION=7.0.0
10+
ARG HOME=/root
11+
12+
# 0. Install general tools
13+
ARG DEBIAN_FRONTEND=noninteractive
14+
RUN apt-get update && \
15+
apt-get install -y \
16+
curl \
17+
git \
18+
python3 \
19+
wget
20+
21+
# 1. Set up QEMU RISC-V
22+
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
23+
# - https://www.qemu.org/download/
24+
# - https://wiki.qemu.org/Documentation/Platforms/RISCV
25+
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html
26+
27+
# 1.1. Download source
28+
WORKDIR ${HOME}
29+
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
30+
tar xvJf qemu-${QEMU_VERSION}.tar.xz
31+
32+
# 1.2. Install dependencies
33+
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
34+
RUN apt-get install -y \
35+
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
36+
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
37+
zlib1g-dev libexpat-dev git \
38+
ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev
39+
40+
# 1.3. Build and install from source
41+
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
42+
RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
43+
make -j$(nproc) && \
44+
make install
45+
46+
# 1.4. Clean up
47+
WORKDIR ${HOME}
48+
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
49+
50+
# 1.5. Sanity checking
51+
RUN qemu-system-riscv64 --version && \
52+
qemu-riscv64 --version
53+
54+
# 2. Set up Rust
55+
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
56+
# - https://www.rust-lang.org/tools/install
57+
# - https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-debian.template
58+
59+
# 2.1. Install
60+
ENV RUSTUP_HOME=/usr/local/rustup \
61+
CARGO_HOME=/usr/local/cargo \
62+
PATH=/usr/local/cargo/bin:$PATH \
63+
RUST_VERSION=nightly
64+
RUN set -eux; \
65+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init; \
66+
chmod +x rustup-init; \
67+
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \
68+
rm rustup-init; \
69+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME;
70+
71+
# 2.2. Sanity checking
72+
RUN rustup --version && \
73+
cargo --version && \
74+
rustc --version
75+
76+
# 2.3 Env
77+
RUN cargo install cargo-binutils; \
78+
rustup target add riscv64gc-unknown-none-elf; \
79+
rustup component add rust-src; \
80+
rustup component add llvm-tools-preview; \
81+
rustup component add rustfmt; \
82+
rustup component add clippy;
83+
84+
# 3. Cargo vendor
85+
WORKDIR ${HOME}
86+
COPY os/vendor ./os-vendor
87+
COPY user/vendor ./user-vendor
88+
89+
# Ready to go
90+
WORKDIR ${HOME}

0 commit comments

Comments
 (0)