Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"component": {
"name": "axaddrspace",
"crate_name": "axaddrspace"
},
"targets": [
"aarch64-unknown-none-softfloat",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-none",
"riscv64gc-unknown-none-elf"
],
"unit_test_targets": [
"x86_64-unknown-linux-gnu"
],
"rust_components": [
"rust-src",
"clippy",
Expand Down
67 changes: 8 additions & 59 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,15 @@
name: Quality Checks
# Quality Check Workflow
# References shared workflow from axci

name: Check

on:
push:
branches:
- '**'
tags-ignore:
- '**'
branches: ['**']
tags-ignore: ['**']
pull_request:
workflow_call:
workflow_dispatch:

jobs:
load-config:
name: Load CI Configuration
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.config.outputs.targets }}
rust_components: ${{ steps.config.outputs.rust_components }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Load configuration
id: config
run: |
TARGETS=$(jq -c '.targets' .github/config.json)
COMPONENTS=$(jq -r '.rust_components | join(", ")' .github/config.json)

echo "targets=$TARGETS" >> $GITHUB_OUTPUT
echo "rust_components=$COMPONENTS" >> $GITHUB_OUTPUT

check:
name: Check
runs-on: ubuntu-latest
needs: load-config
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.load-config.outputs.targets) }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: ${{ needs.load-config.outputs.rust_components }}
targets: ${{ matrix.target }}

- name: Check rust version
run: rustc --version --verbose

- name: Check code format
run: cargo fmt --all -- --check

- name: Build
run: cargo build --target ${{ matrix.target }} --all-features

- name: Run clippy
run: cargo clippy --target ${{ matrix.target }} --all-features -- -D warnings

- name: Build documentation
env:
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links -D missing-docs
run: cargo doc --no-deps --target ${{ matrix.target }} --all-features
uses: arceos-hypervisor/axci/.github/workflows/check.yml@main
107 changes: 7 additions & 100 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,109 +1,16 @@
# Deploy Workflow
# References shared workflow from axci

name: Deploy

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

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

concurrency:
group: 'pages'
cancel-in-progress: false

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
verify-tag:
name: Verify Tag
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ steps.check.outputs.should_deploy }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if tag is on main or master branch
id: check
run: |
git fetch origin main master || true
BRANCHES=$(git branch -r --contains ${{ github.ref }})

if echo "$BRANCHES" | grep -qE 'origin/(main|master)'; then
echo "✓ Tag is on main or master branch"
echo "should_deploy=true" >> $GITHUB_OUTPUT
else
echo "✗ Tag is not on main or master branch, skipping deployment"
echo "Tag is on: $BRANCHES"
echo "should_deploy=false" >> $GITHUB_OUTPUT
fi

- name: Verify version consistency
if: steps.check.outputs.should_deploy == 'true'
run: |
# Extract version from git tag (remove 'v' prefix)
TAG_VERSION="${{ github.ref_name }}"
TAG_VERSION="${TAG_VERSION#v}"
# Extract version from Cargo.toml
CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)"/\1/')
echo "Git tag version: $TAG_VERSION"
echo "Cargo.toml version: $CARGO_VERSION"
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "ERROR: Version mismatch! Tag version ($TAG_VERSION) != Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "✓ Version check passed!"

check:
uses: ./.github/workflows/check.yml
needs: verify-tag
if: needs.verify-tag.outputs.should_deploy == 'true'

test:
uses: ./.github/workflows/test.yml
needs: verify-tag
if: needs.verify-tag.outputs.should_deploy == 'true'

build:
name: Build documentation
runs-on: ubuntu-latest
needs: [verify-tag, check, test]
if: needs.verify-tag.outputs.should_deploy == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Build docs
env:
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links -D missing-docs
run: |
cargo doc --no-deps --all-features
printf '<meta http-equiv="refresh" content="0;url=%s/index.html">' $(cargo tree | head -1 | cut -d' ' -f1) > target/doc/index.html

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: target/doc

deploy:
name: Deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: [verify-tag, build]
if: needs.verify-tag.outputs.should_deploy == 'true'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: arceos-hypervisor/axci/.github/workflows/deploy.yml@main
with:
verify_branch: true
verify_version: true
145 changes: 7 additions & 138 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,147 +1,16 @@
# ═══════════════════════════════════════════════════════════════════════════════
# 组件仓库 GitHub Actions 配置模板
# ═══════════════════════════════════════════════════════════════════════════════
#
# 此文件用于子仓库,当子仓库有更新时通知主仓库进行 subtree pull 同步。
#
# 【使用步骤】
# ─────────────────────────────────────────────────────────────────────────────
# 1. 将此文件复制到子仓库的 .github/workflows/ 目录:
# cp scripts/push.yml <子仓库>/.github/workflows/push.yml
#
# 2. 在子仓库中配置 Secret:
# GitHub 仓库 → Settings → Secrets → Actions → New repository secret
# 名称: PARENT_REPO_TOKEN
# 值: 具有主仓库 repo 权限的 Personal Access Token
#
# 3. 修改下方 env 块中的一个变量(标注了「需要修改」的行):
# PARENT_REPO - 主仓库路径,例如 rcore-os/tgoskits
# (subtree 目录由主仓库自动从 git 历史中推断,无需手动指定)
#
# 【Token 权限要求】
# ─────────────────────────────────────────────────────────────────────────────
# PARENT_REPO_TOKEN 需要 Classic Personal Access Token,权限包括:
# - repo (Full control of private repositories)
# 或
# - Fine-grained token: Contents (Read and Write)
#
# 【触发条件】
# ─────────────────────────────────────────────────────────────────────────────
# - 自动触发:推送到 dev 或 main 分支时
# - 手动触发:Actions → Notify Parent Repository → Run workflow
#
# 【工作流程】
# ─────────────────────────────────────────────────────────────────────────────
# 子仓库 push → 触发此工作流 → 调用主仓库 API → 主仓库 subtree pull
#
# 【注意事项】
# ─────────────────────────────────────────────────────────────────────────────
# - 主仓库需要配置接收 repository_dispatch 事件的同步工作流
# - 如果不需要子仓库到主仓库的同步,可以不使用此文件
#
# ═══════════════════════════════════════════════════════════════════════════════

name: Notify Parent Repository

# 当有新的推送时触发
on:
push:
branches:
- main
- master
- zcs
workflow_dispatch:

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Get repository info
id: repo
env:
GH_REPO_NAME: ${{ github.event.repository.name }}
GH_REF_NAME: ${{ github.ref_name }}
GH_SERVER_URL: ${{ github.server_url }}
GH_REPOSITORY: ${{ github.repository }}
run: |
# 直接使用 GitHub Actions 内置变量,通过 env 传入避免 shell 注入
COMPONENT="$GH_REPO_NAME"
BRANCH="$GH_REF_NAME"
# 构造标准 HTTPS URL,供主仓库按 URL 精确匹配 repos.list
REPO_URL="${GH_SERVER_URL}/${GH_REPOSITORY}"

echo "component=${COMPONENT}" >> $GITHUB_OUTPUT
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
echo "repo_url=${REPO_URL}" >> $GITHUB_OUTPUT

echo "Component: ${COMPONENT}"
echo "Branch: ${BRANCH}"
echo "Repo URL: ${REPO_URL}"

- name: Notify parent repository
env:
# ── 需要修改 ──────────────────────────────────────────────────────────
PARENT_REPO: "rcore-os/tgoskits" # 主仓库路径
# ── 无需修改 ──────────────────────────────────────────────────────────
DISPATCH_TOKEN: ${{ secrets.PARENT_REPO_TOKEN }}
# 将用户可控内容通过 env 传入,避免直接插值到 shell 脚本
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
GIT_ACTOR: ${{ github.actor }}
GIT_SHA: ${{ github.sha }}
STEP_COMPONENT: ${{ steps.repo.outputs.component }}
STEP_BRANCH: ${{ steps.repo.outputs.branch }}
STEP_REPO_URL: ${{ steps.repo.outputs.repo_url }}
run: |
COMPONENT="$STEP_COMPONENT"
BRANCH="$STEP_BRANCH"
REPO_URL="$STEP_REPO_URL"

echo "Notifying parent repository about update in ${COMPONENT}:${BRANCH}"

# 使用 jq 安全构建 JSON,避免 commit message 中任何特殊字符导致注入
PAYLOAD=$(jq -n \
--arg component "$COMPONENT" \
--arg branch "$BRANCH" \
--arg repo_url "$REPO_URL" \
--arg commit "$GIT_SHA" \
--arg message "$COMMIT_MESSAGE" \
--arg author "$GIT_ACTOR" \
'{
event_type: "subtree-update",
client_payload: {
component: $component,
branch: $branch,
repo_url: $repo_url,
commit: $commit,
message: $message,
author: $author
}
}')

curl --fail --show-error -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${DISPATCH_TOKEN}" \
https://api.github.com/repos/${PARENT_REPO}/dispatches \
-d "$PAYLOAD"

echo "Notification sent successfully"

- name: Create summary
env:
STEP_COMPONENT: ${{ steps.repo.outputs.component }}
STEP_BRANCH: ${{ steps.repo.outputs.branch }}
STEP_REPO_URL: ${{ steps.repo.outputs.repo_url }}
GIT_SHA: ${{ github.sha }}
GIT_ACTOR: ${{ github.actor }}
run: |
COMPONENT="$STEP_COMPONENT"
BRANCH="$STEP_BRANCH"
REPO_URL="$STEP_REPO_URL"

echo "## Notification Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Component**: ${COMPONENT}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
echo "- **Repo URL**: ${REPO_URL}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: \`${GIT_SHA}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Author**: ${GIT_ACTOR}" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: ✅ Notification sent" >> $GITHUB_STEP_SUMMARY
notify-parent:
name: Notify Parent Repository
# 调用 axci 仓库的可复用工作流
uses: arceos-hypervisor/axci/.github/workflows/push.yml@main
secrets:
PARENT_REPO_TOKEN: ${{ secrets.PARENT_REPO_TOKEN }}
Loading