Skip to content

Commit

Permalink
Initialize ch3
Browse files Browse the repository at this point in the history
  • Loading branch information
github-classroom[bot] authored Apr 29, 2024
0 parents commit a4f6874
Show file tree
Hide file tree
Showing 38 changed files with 2,225 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Jobs

on: [push]

env:
CARGO_TERM_COLOR: always
rust_toolchain: nightly

jobs:
build-doc:
if: github.repository == 'LearningOS/rCore-Tutorial-Code-2024S'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build doc
run: |
git clone https://github.com/LearningOS/rCore-Tutorial-Test-2024S.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-2024S.git ci-user
git clone https://github.com/LearningOS/rCore-Tutorial-Test-2024S.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
gitlab-mirror:
if: github.repository == 'LearningOS/rCore-Tutorial-Code-2024S'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Mirror + trigger CI
uses: tkf2019/gitlab-mirror-and-ci-action@master
with:
args: "https://git.tsinghua.edu.cn/os-lab/2024s/public/rcore-tutorial-code-2024s"
env:
GITLAB_HOSTNAME: "git.tsinghua.edu.cn"
GITLAB_PROJECT_ID: "29091"
GITLAB_PROJECT_NAME: "rcore-tutorial-code-2024s"
GITLAB_PROJECT_TOKEN: ${{secrets.GITLAB_PROJECT_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
deploy:
if: github.repository != 'LearningOS/rCore-Tutorial-Code-2024S'
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 }}
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.*/*
!.github/*
!.vscode/settings.json
.idea
Cargo.lock
target
os/src/link_app.S
os/last-*
os/Cargo.lock
os/.gdb_history
easy-fs/Cargo.lock
easy-fs/target/*
easy-fs-fuse/Cargo.lock
easy-fs-fuse/target/*
tools/
pushall.sh
*.bak

user/*
12 changes: 12 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
default:
image: tkf2023/env:rcore-ci

stages:
- test

test-code-job:
stage: test
script:
- git clone https://token:${RCORE_CHECKER_REPO_READ_TOKEN_2024S}@git.tsinghua.edu.cn/os-lab/2024s/ta/rcore-tutorial-checker-2024s.git ci-user
- git clone https://token:${RCORE_TEST_REPO_READ_TOKEN_2024S}@git.tsinghua.edu.cn/os-lab/2024s/public/rcore-tutorial-test-2024s.git ci-user/user
- cd ci-user && make test CHAPTER=`echo $CI_COMMIT_REF_NAME | grep -oP 'ch\K[0-9]'` passwd=$BASE_TEST_TOKEN OFFLINE=1
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// Prevent "can't find crate for `test`" error on no_std
// Ref: https://github.com/rust-lang/vscode-rust/issues/729
// For vscode-rust plugin users:
"rust.target": "riscv64gc-unknown-none-elf",
"rust.all_targets": false,
// For Rust Analyzer plugin users:
"rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
"rust-analyzer.checkOnSave.allTargets": false,
// "rust-analyzer.cargo.features": [
// "board_qemu"
// ]
}
90 changes: 90 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# syntax=docker/dockerfile:1
# This Dockerfile is adapted from https://github.com/LearningOS/rCore-Tutorial-v3/blob/main/Dockerfile
# with the following major updates:
# - ubuntu 18.04 -> 20.04
# - qemu 5.0.0 -> 7.0.0
# - Extensive comments linking to relevant documentation
FROM ubuntu:20.04

ARG QEMU_VERSION=7.0.0
ARG HOME=/root

# 0. Install general tools
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
curl \
git \
python3 \
wget

# 1. Set up QEMU RISC-V
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
# - https://www.qemu.org/download/
# - https://wiki.qemu.org/Documentation/Platforms/RISCV
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html

# 1.1. Download source
WORKDIR ${HOME}
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
tar xvJf qemu-${QEMU_VERSION}.tar.xz

# 1.2. Install dependencies
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
RUN apt-get install -y \
autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
zlib1g-dev libexpat-dev git \
ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev

# 1.3. Build and install from source
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
make -j$(nproc) && \
make install

# 1.4. Clean up
WORKDIR ${HOME}
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz

# 1.5. Sanity checking
RUN qemu-system-riscv64 --version && \
qemu-riscv64 --version

# 2. Set up Rust
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
# - https://www.rust-lang.org/tools/install
# - https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-debian.template

# 2.1. Install
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUN set -eux; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME;

# 2.2. Sanity checking
RUN rustup --version && \
cargo --version && \
rustc --version

# 2.3 Env
RUN cargo install cargo-binutils; \
rustup target add riscv64gc-unknown-none-elf; \
rustup component add rust-src; \
rustup component add llvm-tools-preview; \
rustup component add rustfmt; \
rustup component add clippy;

# 3. Cargo vendor
WORKDIR ${HOME}
COPY os/vendor ./os-vendor
COPY user/vendor ./user-vendor

# Ready to go
WORKDIR ${HOME}
Loading

0 comments on commit a4f6874

Please sign in to comment.