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
44 changes: 44 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Quality Checks

on:
workflow_call:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
check:
name: Quality Checks
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-none
- riscv64gc-unknown-none-elf
- aarch64-unknown-none-softfloat
- loongarch64-unknown-none-softfloat

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

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src, clippy, rustfmt
targets: ${{ matrix.target }}

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

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

- name: Clippy
run: cargo clippy --target ${{ matrix.target }} --all-features

- name: Build
run: cargo build --target ${{ matrix.target }} --all-features
55 changes: 0 additions & 55 deletions .github/workflows/ci.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deploy

on: [push, pull_request]

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

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

jobs:
check:
uses: ./.github/workflows/check.yml

test:
uses: ./.github/workflows/test.yml

build-doc:
name: Build documentation
runs-on: ubuntu-latest
needs: [check, test]
env:
RUSTDOCFLAGS: --cfg docsrs -D rustdoc::broken_intra_doc_links -D missing-docs
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Build 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-doc:
name: Deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-doc
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
112 changes: 112 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Release

on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-pre.*'

permissions:
contents: write

jobs:
check:
uses: ./.github/workflows/check.yml

test:
uses: ./.github/workflows/test.yml

create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [check, test]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Validate tag is on main branch
shell: bash
run: |
set -e

TAG="${{ github.ref_name }}"
TAG_COMMIT=$(git rev-list -n 1 "$TAG")

git fetch origin main

MAIN_HEAD=$(git rev-parse origin/main)

echo "Tag: $TAG"
echo "Tag commit: $TAG_COMMIT"
echo "main HEAD: $MAIN_HEAD"

if [ "$TAG_COMMIT" != "$MAIN_HEAD" ]; then
echo "❌ release tag must be created from main HEAD"
exit 1
fi
echo "✅ release tag validated on main"

- name: Validate version consistency
shell: bash
run: |
set -e

TAG="${{ github.ref_name }}"
# Remove 'v' prefix from tag
TAG_VERSION="${TAG#v}"

# Get version from Cargo.toml
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')

echo "Tag version: $TAG_VERSION"
echo "Cargo version: $CARGO_VERSION"

if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "❌ Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "✅ Version consistency validated"

- name: Install Cargo
uses: dtolnay/rust-toolchain@stable

- name: Generate release note
id: gen-release-note
shell: bash
run: |
{
echo "release_note<<EOF"
cargo tree --depth 0 | while read -r line; do
if [ ! -z "$line" ]; then
crate=$(echo "$line" | cut -d' ' -f1)
version=$(echo "$line" | cut -d' ' -f2 | tr -d '()')
version=${version#v}
echo "- $crate ([crates.io](https://crates.io/crates/$crate/$version) | [documentation](https://docs.rs/$crate/$version))"
fi
done
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: ${{ contains(github.ref_name, '-pre.') }}
body: ${{ steps.gen-release-note.outputs.release_note }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-crates:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: create-release

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

- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on:
workflow_call:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Run unit tests
run: cargo test -- --nocapture
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Crates.io](https://img.shields.io/crates/v/axcpu)](https://crates.io/crates/axcpu)
[![Docs.rs](https://docs.rs/axcpu/badge.svg)](https://docs.rs/axcpu)
[![CI](https://github.com/arceos-org/axcpu/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arceos-org/axcpu/actions/workflows/ci.yml)
[![CI](https://github.com/arceos-org/axcpu/actions/workflows/deploy.yml/badge.svg?branch=main)](https://github.com/arceos-org/axcpu/actions/workflows/deploy.yml)

This crate provides privileged instruction and structure abstractions for various CPU architectures. It is designed to implement the hardware abstraction layer of an operating system kernel.

Expand Down