Skip to content

Commit c1d3c2d

Browse files
committed
[Refactor]: Migrate CI workflows to shared axci and update project docs
1 parent 396b8d4 commit c1d3c2d

12 files changed

Lines changed: 411 additions & 626 deletions

File tree

.github/config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
2+
"component": {
3+
"name": "axdevice",
4+
"crate_name": "axdevice"
5+
},
26
"targets": [
37
"aarch64-unknown-none-softfloat",
48
"x86_64-unknown-linux-gnu",
59
"x86_64-unknown-none",
610
"riscv64gc-unknown-none-elf"
711
],
12+
"unit_test_targets": [
13+
"x86_64-unknown-linux-gnu"
14+
],
815
"rust_components": [
916
"rust-src",
1017
"clippy",

.github/workflows/check.yml

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,15 @@
1-
name: Quality Checks
1+
# Quality Check Workflow
2+
# References shared workflow from axci
3+
4+
name: Check
25

36
on:
47
push:
5-
branches:
6-
- '**'
7-
tags-ignore:
8-
- '**'
8+
branches: ['**']
9+
tags-ignore: ['**']
910
pull_request:
10-
workflow_call:
11+
workflow_dispatch:
1112

1213
jobs:
13-
load-config:
14-
name: Load CI Configuration
15-
runs-on: ubuntu-latest
16-
outputs:
17-
targets: ${{ steps.config.outputs.targets }}
18-
rust_components: ${{ steps.config.outputs.rust_components }}
19-
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
23-
- name: Load configuration
24-
id: config
25-
run: |
26-
TARGETS=$(jq -c '.targets' .github/config.json)
27-
COMPONENTS=$(jq -r '.rust_components | join(", ")' .github/config.json)
28-
29-
echo "targets=$TARGETS" >> $GITHUB_OUTPUT
30-
echo "rust_components=$COMPONENTS" >> $GITHUB_OUTPUT
31-
3214
check:
33-
name: Check
34-
runs-on: ubuntu-latest
35-
needs: load-config
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
target: ${{ fromJson(needs.load-config.outputs.targets) }}
40-
41-
steps:
42-
- name: Checkout code
43-
uses: actions/checkout@v4
44-
45-
- name: Install Rust toolchain
46-
uses: dtolnay/rust-toolchain@nightly
47-
with:
48-
components: ${{ needs.load-config.outputs.rust_components }}
49-
targets: ${{ matrix.target }}
50-
51-
- name: Check rust version
52-
run: rustc --version --verbose
53-
54-
- name: Check code format
55-
run: cargo fmt --all -- --check
56-
57-
- name: Build
58-
run: cargo build --target ${{ matrix.target }} --all-features
59-
60-
- name: Run clippy
61-
run: cargo clippy --target ${{ matrix.target }} --all-features -- -D warnings
62-
63-
- name: Build documentation
64-
env:
65-
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links -D missing-docs
66-
run: cargo doc --no-deps --target ${{ matrix.target }} --all-features
15+
uses: arceos-hypervisor/axci/.github/workflows/check.yml@main

.github/workflows/deploy.yml

Lines changed: 7 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,16 @@
1+
# Deploy Workflow
2+
# References shared workflow from axci
3+
14
name: Deploy
25

36
on:
47
push:
58
tags:
69
- 'v[0-9]+.[0-9]+.[0-9]+'
710

8-
permissions:
9-
contents: read
10-
pages: write
11-
id-token: write
12-
13-
concurrency:
14-
group: 'pages'
15-
cancel-in-progress: false
16-
17-
env:
18-
CARGO_TERM_COLOR: always
19-
RUST_BACKTRACE: 1
20-
2111
jobs:
22-
verify-tag:
23-
name: Verify Tag
24-
runs-on: ubuntu-latest
25-
outputs:
26-
should_deploy: ${{ steps.check.outputs.should_deploy }}
27-
steps:
28-
- name: Checkout code
29-
uses: actions/checkout@v4
30-
with:
31-
fetch-depth: 0
32-
33-
- name: Check if tag is on main or master branch
34-
id: check
35-
run: |
36-
git fetch origin main master || true
37-
BRANCHES=$(git branch -r --contains ${{ github.ref }})
38-
39-
if echo "$BRANCHES" | grep -qE 'origin/(main|master)'; then
40-
echo "✓ Tag is on main or master branch"
41-
echo "should_deploy=true" >> $GITHUB_OUTPUT
42-
else
43-
echo "✗ Tag is not on main or master branch, skipping deployment"
44-
echo "Tag is on: $BRANCHES"
45-
echo "should_deploy=false" >> $GITHUB_OUTPUT
46-
fi
47-
48-
- name: Verify version consistency
49-
if: steps.check.outputs.should_deploy == 'true'
50-
run: |
51-
# Extract version from git tag (remove 'v' prefix)
52-
TAG_VERSION="${{ github.ref_name }}"
53-
TAG_VERSION="${TAG_VERSION#v}"
54-
# Extract version from Cargo.toml
55-
CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)"/\1/')
56-
echo "Git tag version: $TAG_VERSION"
57-
echo "Cargo.toml version: $CARGO_VERSION"
58-
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
59-
echo "ERROR: Version mismatch! Tag version ($TAG_VERSION) != Cargo.toml version ($CARGO_VERSION)"
60-
exit 1
61-
fi
62-
echo "✓ Version check passed!"
63-
64-
check:
65-
uses: ./.github/workflows/check.yml
66-
needs: verify-tag
67-
if: needs.verify-tag.outputs.should_deploy == 'true'
68-
69-
test:
70-
uses: ./.github/workflows/test.yml
71-
needs: verify-tag
72-
if: needs.verify-tag.outputs.should_deploy == 'true'
73-
74-
build:
75-
name: Build documentation
76-
runs-on: ubuntu-latest
77-
needs: [verify-tag, check, test]
78-
if: needs.verify-tag.outputs.should_deploy == 'true'
79-
steps:
80-
- name: Checkout code
81-
uses: actions/checkout@v4
82-
83-
- name: Install Rust toolchain
84-
uses: dtolnay/rust-toolchain@nightly
85-
86-
- name: Build docs
87-
env:
88-
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links -D missing-docs
89-
run: |
90-
# Build documentation
91-
cargo doc --no-deps --all-features
92-
93-
# Auto-detect documentation directory
94-
# Check if doc exists in target/doc or target/*/doc
95-
if [ -d "target/doc" ]; then
96-
DOC_DIR="target/doc"
97-
else
98-
# Find doc directory under target/*/doc pattern
99-
DOC_DIR=$(find target -type d -name doc -path "target/*/doc" | head -n 1)
100-
if [ -z "$DOC_DIR" ]; then
101-
echo "Error: Could not find documentation directory"
102-
exit 1
103-
fi
104-
fi
105-
106-
echo "Documentation found in: $DOC_DIR"
107-
printf '<meta http-equiv="refresh" content="0;url=%s/index.html">' $(cargo tree | head -1 | cut -d' ' -f1) > "${DOC_DIR}/index.html"
108-
echo "DOC_DIR=${DOC_DIR}" >> $GITHUB_ENV
109-
110-
- name: Upload artifact
111-
uses: actions/upload-pages-artifact@v3
112-
with:
113-
path: ${{ env.DOC_DIR }}
114-
11512
deploy:
116-
name: Deploy to GitHub Pages
117-
environment:
118-
name: github-pages
119-
url: ${{ steps.deployment.outputs.page_url }}
120-
runs-on: ubuntu-latest
121-
needs: [verify-tag, build]
122-
if: needs.verify-tag.outputs.should_deploy == 'true'
123-
steps:
124-
- name: Deploy to GitHub Pages
125-
id: deployment
126-
uses: actions/deploy-pages@v4
13+
uses: arceos-hypervisor/axci/.github/workflows/deploy.yml@main
14+
with:
15+
verify_branch: true
16+
verify_version: true

.github/workflows/push.yml

Lines changed: 7 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,16 @@
1-
# ═══════════════════════════════════════════════════════════════════════════════
2-
# 组件仓库 GitHub Actions 配置模板
3-
# ═══════════════════════════════════════════════════════════════════════════════
4-
#
5-
# 此文件用于子仓库,当子仓库有更新时通知主仓库进行 subtree pull 同步。
6-
#
7-
# 【使用步骤】
8-
# ─────────────────────────────────────────────────────────────────────────────
9-
# 1. 将此文件复制到子仓库的 .github/workflows/ 目录:
10-
# cp scripts/push.yml <子仓库>/.github/workflows/push.yml
11-
#
12-
# 2. 在子仓库中配置 Secret:
13-
# GitHub 仓库 → Settings → Secrets → Actions → New repository secret
14-
# 名称: PARENT_REPO_TOKEN
15-
# 值: 具有主仓库 repo 权限的 Personal Access Token
16-
#
17-
# 3. 修改下方 env 块中的一个变量(标注了「需要修改」的行):
18-
# PARENT_REPO - 主仓库路径,例如 rcore-os/tgoskits
19-
# (subtree 目录由主仓库自动从 git 历史中推断,无需手动指定)
20-
#
21-
# 【Token 权限要求】
22-
# ─────────────────────────────────────────────────────────────────────────────
23-
# PARENT_REPO_TOKEN 需要 Classic Personal Access Token,权限包括:
24-
# - repo (Full control of private repositories)
25-
#
26-
# - Fine-grained token: Contents (Read and Write)
27-
#
28-
# 【触发条件】
29-
# ─────────────────────────────────────────────────────────────────────────────
30-
# - 自动触发:推送到 dev 或 main 分支时
31-
# - 手动触发:Actions → Notify Parent Repository → Run workflow
32-
#
33-
# 【工作流程】
34-
# ─────────────────────────────────────────────────────────────────────────────
35-
# 子仓库 push → 触发此工作流 → 调用主仓库 API → 主仓库 subtree pull
36-
#
37-
# 【注意事项】
38-
# ─────────────────────────────────────────────────────────────────────────────
39-
# - 主仓库需要配置接收 repository_dispatch 事件的同步工作流
40-
# - 如果不需要子仓库到主仓库的同步,可以不使用此文件
41-
#
42-
# ═══════════════════════════════════════════════════════════════════════════════
43-
441
name: Notify Parent Repository
452

46-
# 当有新的推送时触发
473
on:
484
push:
495
branches:
506
- main
51-
- master
7+
- zcs
528
workflow_dispatch:
539

5410
jobs:
55-
notify:
56-
runs-on: ubuntu-latest
57-
steps:
58-
- name: Get repository info
59-
id: repo
60-
env:
61-
GH_REPO_NAME: ${{ github.event.repository.name }}
62-
GH_REF_NAME: ${{ github.ref_name }}
63-
GH_SERVER_URL: ${{ github.server_url }}
64-
GH_REPOSITORY: ${{ github.repository }}
65-
run: |
66-
# 直接使用 GitHub Actions 内置变量,通过 env 传入避免 shell 注入
67-
COMPONENT="$GH_REPO_NAME"
68-
BRANCH="$GH_REF_NAME"
69-
# 构造标准 HTTPS URL,供主仓库按 URL 精确匹配 repos.list
70-
REPO_URL="${GH_SERVER_URL}/${GH_REPOSITORY}"
71-
72-
echo "component=${COMPONENT}" >> $GITHUB_OUTPUT
73-
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
74-
echo "repo_url=${REPO_URL}" >> $GITHUB_OUTPUT
75-
76-
echo "Component: ${COMPONENT}"
77-
echo "Branch: ${BRANCH}"
78-
echo "Repo URL: ${REPO_URL}"
79-
80-
- name: Notify parent repository
81-
env:
82-
# ── 需要修改 ──────────────────────────────────────────────────────────
83-
PARENT_REPO: "rcore-os/tgoskits" # 主仓库路径
84-
# ── 无需修改 ──────────────────────────────────────────────────────────
85-
DISPATCH_TOKEN: ${{ secrets.PARENT_REPO_TOKEN }}
86-
# 将用户可控内容通过 env 传入,避免直接插值到 shell 脚本
87-
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
88-
GIT_ACTOR: ${{ github.actor }}
89-
GIT_SHA: ${{ github.sha }}
90-
STEP_COMPONENT: ${{ steps.repo.outputs.component }}
91-
STEP_BRANCH: ${{ steps.repo.outputs.branch }}
92-
STEP_REPO_URL: ${{ steps.repo.outputs.repo_url }}
93-
run: |
94-
COMPONENT="$STEP_COMPONENT"
95-
BRANCH="$STEP_BRANCH"
96-
REPO_URL="$STEP_REPO_URL"
97-
98-
echo "Notifying parent repository about update in ${COMPONENT}:${BRANCH}"
99-
100-
# 使用 jq 安全构建 JSON,避免 commit message 中任何特殊字符导致注入
101-
PAYLOAD=$(jq -n \
102-
--arg component "$COMPONENT" \
103-
--arg branch "$BRANCH" \
104-
--arg repo_url "$REPO_URL" \
105-
--arg commit "$GIT_SHA" \
106-
--arg message "$COMMIT_MESSAGE" \
107-
--arg author "$GIT_ACTOR" \
108-
'{
109-
event_type: "subtree-update",
110-
client_payload: {
111-
component: $component,
112-
branch: $branch,
113-
repo_url: $repo_url,
114-
commit: $commit,
115-
message: $message,
116-
author: $author
117-
}
118-
}')
119-
120-
curl --fail --show-error -X POST \
121-
-H "Accept: application/vnd.github.v3+json" \
122-
-H "Authorization: token ${DISPATCH_TOKEN}" \
123-
https://api.github.com/repos/${PARENT_REPO}/dispatches \
124-
-d "$PAYLOAD"
125-
126-
echo "Notification sent successfully"
127-
128-
- name: Create summary
129-
env:
130-
STEP_COMPONENT: ${{ steps.repo.outputs.component }}
131-
STEP_BRANCH: ${{ steps.repo.outputs.branch }}
132-
STEP_REPO_URL: ${{ steps.repo.outputs.repo_url }}
133-
GIT_SHA: ${{ github.sha }}
134-
GIT_ACTOR: ${{ github.actor }}
135-
run: |
136-
COMPONENT="$STEP_COMPONENT"
137-
BRANCH="$STEP_BRANCH"
138-
REPO_URL="$STEP_REPO_URL"
139-
140-
echo "## Notification Summary" >> $GITHUB_STEP_SUMMARY
141-
echo "" >> $GITHUB_STEP_SUMMARY
142-
echo "- **Component**: ${COMPONENT}" >> $GITHUB_STEP_SUMMARY
143-
echo "- **Branch**: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
144-
echo "- **Repo URL**: ${REPO_URL}" >> $GITHUB_STEP_SUMMARY
145-
echo "- **Commit**: \`${GIT_SHA}\`" >> $GITHUB_STEP_SUMMARY
146-
echo "- **Author**: ${GIT_ACTOR}" >> $GITHUB_STEP_SUMMARY
147-
echo "- **Status**: ✅ Notification sent" >> $GITHUB_STEP_SUMMARY
11+
notify-parent:
12+
name: Notify Parent Repository
13+
# 调用 axci 仓库的可复用工作流
14+
uses: arceos-hypervisor/axci/.github/workflows/push.yml@main
15+
secrets:
16+
PARENT_REPO_TOKEN: ${{ secrets.PARENT_REPO_TOKEN }}

0 commit comments

Comments
 (0)