Skip to content

Commit

Permalink
Merge pull request #19 from ToolmanP/main
Browse files Browse the repository at this point in the history
Infra: introduce mdbook, grader, makefile infrastructure
  • Loading branch information
ToolmanP authored Aug 17, 2024
2 parents 2929ffa + c843a0a commit e488c9c
Show file tree
Hide file tree
Showing 59 changed files with 1,311 additions and 890 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: GitHub Pages

on:
push:
sources:
- "Pages/**"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install mdbook and its preprocessors
run: |
mkdir mdbook
tag=$(curl 'https://api.github.com/repos/toolmanp/rs-mdbook-callouts/releases/latest' | jq -r '.tag_name')
url="https://github.com/toolmanp/rs-mdbook-callouts/releases/download/${tag}/mdbook-callouts-x86_64-unknown-linux-gnu.tar.gz"
curl -sSL $url | tar -xz --directory=./mdbook
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
curl -sSL $url | tar -xz --directory=./mdbook
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-toc/releases/latest' | jq -r '.tag_name')
url="https://github.com/badboy/mdbook-toc/releases/download/${tag}/mdbook-toc-${tag}-x86_64-unknown-linux-gnu.tar.gz"
curl -sSL $url | tar -xz --directory=./mdbook
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-last-changed/releases/latest' | jq -r '.tag_name')
url="https://github.com/badboy/mdbook-last-changed/releases/download/${tag}/mdbook-last-changed-${tag}-x86_64-unknown-linux-gnu.tar.gz"
curl -sSL $url | tar -xz --directory=./mdbook
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-mermaid/releases/latest' | jq -r '.tag_name')
url="https://github.com/badboy/mdbook-mermaid/releases/download/${tag}/mdbook-mermaid-${tag}-x86_64-unknown-linux-gnu.tar.gz"
curl -sSL $url | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build Book
run: |
mdbook-mermaid install ./
mdbook build
touch ./book/.nojekyll
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'book'
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ infer_*_report.txt
infer-out/
.repo/
*.tar.gz
book/
**mermaid**
**/index.html
File renamed without changes
13 changes: 6 additions & 7 deletions Lab0/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
LAB := 0

ifndef PROJECT
PROJECT := $(shell git rev-parse --show-toplevel)
endif
PROJECT := $(CURDIR)/..
GRADER := $(PROJECT)/Scripts/grader.sh

export CURDIR LAB
export PROJECT CURDIR LAB

include $(PROJECT)/scripts/lab.mk
include $(PROJECT)/Scripts/lab.mk

bomb: student-number.txt
@echo " GEN bomb"
@$(CURDIR)/scripts/generate_bomb.sh
@$(CURDIR)/Scripts/generate_bomb.sh

clean:
@echo " CLEAN bomb"
Expand All @@ -30,7 +29,7 @@ gdb:
$(GDB) -ex "set architecture aarch64" -ex "target remote localhost:1234" -ex "add-symbol-file bomb"

grade:
@$(CURDIR)/scripts/grade/lab0.sh
@$(GRADER)

submit:
@echo " SUBMIT lab0"
Expand Down
27 changes: 0 additions & 27 deletions Lab0/README.md

This file was deleted.

Binary file removed Lab0/docs/instructions.pdf
Binary file not shown.
Binary file removed Lab0/docs/tools-tutorial.pdf
Binary file not shown.
File renamed without changes.
15 changes: 10 additions & 5 deletions Lab0/scripts/generate_bomb.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#!/bin/bash

if [ ! -d "${CURDIR}/warehouse" ]; then
if [[ -z $PROJECT ]]; then
echo "Please set the PROJECT environment variable to the root directory of your project. (Makefile)"
exit 1
fi

if [[ ! -d "${CURDIR}/warehouse" ]]; then
echo "Please run under the root directory of this lab!"
exit -1
exit 1
fi

total_bombs=30
student=$(cat ${CURDIR}/student-number.txt)

if [ -z $student ]; then
if [[ -z $student ]]; then
echo "Please enter your student number in student-number.txt at first! Otherwise you would recieve 0 POINTS!"
exit -1
exit 1
fi

bomb_id=$(($student%$total_bombs+1))
bomb_id=$(($student % $total_bombs + 1))

cp ${CURDIR}/warehouse/bomb-${bomb_id} ${CURDIR}/bomb
16 changes: 0 additions & 16 deletions Lab0/scripts/grade/lab0.sh

This file was deleted.

48 changes: 1 addition & 47 deletions Lab1/Makefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,2 @@
LAB := 1

V := @
PROJECT_DIR := .
BUILD_DIR := $(PROJECT_DIR)/build
KERNEL_IMG := $(BUILD_DIR)/kernel.img
QEMU := qemu-system-aarch64
_QEMU := $(PROJECT_DIR)/scripts/qemu/qemu_wrapper.sh $(QEMU)
QEMU_GDB_PORT := 1234
QEMU_OPTS := -machine raspi3b -nographic -serial mon:stdio -m size=1G -kernel $(KERNEL_IMG)
GDB := gdb-multiarch
CHBUILD := $(PROJECT_DIR)/chbuild

.PHONY: all
all: build

.PHONY: defconfig build clean distclean

defconfig:
$(V)$(CHBUILD) defconfig

build:
$(V)test -f $(PROJECT_DIR)/.config || $(CHBUILD) defconfig
$(V)$(CHBUILD) build

clean:
$(V)$(CHBUILD) clean

distclean:
$(V)$(CHBUILD) distclean

.PHONY: qemu qemu-gdb gdb

qemu:
$(V)$(_QEMU) $(QEMU_OPTS)

qemu-gdb:
$(V)$(_QEMU) -S -gdb tcp::$(QEMU_GDB_PORT) $(QEMU_OPTS)

gdb:
$(V)$(GDB) --nx -x $(PROJECT_DIR)/.gdbinit

.PHONY: grade

grade:
$(V)test -f $(PROJECT_DIR)/.config && cp $(PROJECT_DIR)/.config $(PROJECT_DIR)/.config.bak
$(V)$(PROJECT_DIR)/scripts/grade/lab$(LAB).sh
$(V)test -f $(PROJECT_DIR)/.config.bak && mv $(PROJECT_DIR)/.config.bak $(PROJECT_DIR)/.config
include $(CURDIR)/../Scripts/lab.mk
Loading

0 comments on commit e488c9c

Please sign in to comment.