Skip to content

Commit ba2c33e

Browse files
committed
ci: try customized action to reuse code
* test msg: YSYX_SUBMIT=false
1 parent 35e815e commit ba2c33e

File tree

4 files changed

+154
-96
lines changed

4 files changed

+154
-96
lines changed

.github/actions/prepare/action.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: 'Setup Environment'
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Check submit flag
6+
shell: bash
7+
run: |
8+
MSG=$(git log -1)
9+
SUBMIT_FLAG=$(echo $MSG | grep -o "YSYX_SUBMIT=true")
10+
if [[ $SUBMIT_FLAG == "" ]]; then
11+
echo "Missing flag 'YSYX_SUBMIT=true' in the commit message. Abort."
12+
false
13+
fi
14+
15+
- name: Get student ID
16+
shell: bash
17+
id: get-stuid
18+
run: |
19+
STUID=$(grep -E -o "STUID = ysyx_[0-9]{8}" Makefile)
20+
if [[ $STUID == "" ]]; then
21+
echo "Missing STUID in Makefile (format: STUID = ysyx_XXXXXXXX). Abort."
22+
false
23+
fi
24+
STUID=$(echo $STUID | grep -E -o "[0-9]{8}$")
25+
echo "STUID=$STUID" >> $GITHUB_ENV
26+
27+
- name: Check student ID in whitelist
28+
shell: bash
29+
run: |
30+
wget https://raw.githubusercontent.com/OSCPU/ysyx-workbench/whitelist/whitelist.txt
31+
if ! grep -o $STUID whitelist.txt 2> /dev/null ; then
32+
echo "$STUID is not in whitelist. Abort."
33+
false
34+
fi
35+
36+
- name: Changing Directory
37+
shell: bash
38+
run: |
39+
pwd
40+
ls
41+
YSYX_HOME=$(pwd)
42+
cd ..
43+
TEMP_DIR=$(mktemp -d -p .)
44+
cd $TEMP_DIR
45+
TEMP_DIR=$(pwd)
46+
mv $YSYX_HOME $TEMP_DIR/ysyx-workbench
47+
mkdir -p $YSYX_HOME # leave the original directory empty
48+
echo "YSYX_HOME=$TEMP_DIR/ysyx-workbench" >> "$GITHUB_ENV"
49+
50+
- name: Setting environment variables
51+
shell: bash
52+
run: |
53+
pwd
54+
cd $YSYX_HOME
55+
echo "NEMU_HOME=`pwd`/nemu" >> "$GITHUB_ENV"
56+
echo "AM_HOME=`pwd`/abstract-machine" >> "$GITHUB_ENV"
57+
echo "NAVY_HOME=`pwd`/navy-apps" >> "$GITHUB_ENV"
58+
echo "NPC_HOME=`pwd`/npc" >> "$GITHUB_ENV"
59+
MAKE_CMD="make -j `nproc`"
60+
echo "MAKE=$MAKE_CMD" >> "$GITHUB_ENV"
61+
62+
- name: Disable git tracer
63+
shell: bash
64+
run: |
65+
pwd
66+
cd $YSYX_HOME
67+
echo ".git_commit:" >> Makefile
68+
echo -e "\t@echo git tracer is disabled" >> Makefile
69+
70+
- name: Clone repos
71+
shell: bash
72+
run: |
73+
cd $YSYX_HOME
74+
git clone https://github.com/NJU-ProjectN/am-kernels
75+
76+
- name: Install dependency
77+
shell: bash
78+
run: |
79+
sudo apt install g++-riscv64-linux-gnu
80+
sudo sed -i -e '8d' /usr/riscv64-linux-gnu/include/gnu/stubs.h
81+
82+
mkdir -p ~/.local/bin
83+
MILL_VERSION=0.11.13
84+
if [[ -e $NPC_HOME/.mill-version ]]; then
85+
MILL_VERSION=`cat $NPC_HOME/.mill-version`
86+
fi
87+
echo "Downloading mill with version $MILL_VERSION"
88+
sh -c "curl -L https://github.com/com-lihaoyi/mill/releases/download/$MILL_VERSION/$MILL_VERSION > ~/.local/bin/mill && chmod +x ~/.local/bin/mill"
89+
mill --version
90+
91+
wget -q https://github.com/YosysHQ/oss-cad-suite-build/releases/download/2025-04-24/oss-cad-suite-linux-x64-20250424.tgz
92+
tar xf oss-cad-suite-linux-x64-20250424.tgz
93+
OSS_CAD_SUITE_BIN_PATH=`pwd`/oss-cad-suite/bin
94+
echo "PATH=$PATH:$OSS_CAD_SUITE_BIN_PATH" >> "$GITHUB_ENV"
95+
96+
- name: clean up
97+
shell: bash
98+
run: |
99+
cd $YSYX_HOME
100+
$MAKE -C $NEMU_HOME clean
101+
$MAKE -C $AM_HOME clean-all
102+
$MAKE -C $NPC_HOME clean

.github/workflows/ci-issue.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Log New Issue Content
2+
on:
3+
issues:
4+
types: [opened] # 仅监听issue创建事件
5+
6+
jobs:
7+
log_issue_content:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Print issue details
11+
run: |
12+
echo "🆕 New Issue Created"
13+
echo "---------------------"
14+
echo "📌 Title: ${{ github.event.issue.title }}"
15+
echo "👤 Author: ${{ github.event.issue.user.login }}"
16+
echo "🔗 URL: ${{ github.event.issue.html_url }}"
17+
echo ""
18+
echo "📝 Body Content:"
19+
echo "${{ github.event.issue.body }}" # 直接输出issue正文

.github/workflows/ci-test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- ysyx-submit
7+
8+
permissions:
9+
contents: write # For checkout and reading commit info
10+
pull-requests: write # For merging and commenting on PRs
11+
12+
jobs:
13+
hello:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Prepare
20+
uses: ./.github/actions/prepare
21+
- name: hello
22+
run: $MAKE ARCH=riscv32e-npc -C $YSYX_HOME/am-kernels/kernels/hello run
23+
24+
cpu-tests:
25+
runs-on: ubuntu-22.04
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
- name: Prepare
31+
uses: ./.github/actions/prepare
32+
- name: cpu-tests
33+
run: $MAKE ARCH=riscv32e-npc -C $YSYX_HOME/am-kernels/tests/cpu-tests run

.github/workflows/ci.yml

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)