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
10 changes: 10 additions & 0 deletions .github/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"targets": [
"x86_64-unknown-none"
],
"rust_components": [
"rust-src",
"clippy",
"rustfmt"
]
}
66 changes: 66 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Quality Checks

on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
workflow_call:

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
76 changes: 0 additions & 76 deletions .github/workflows/ci.yml

This file was deleted.

126 changes: 126 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
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: |
# Build documentation
cargo doc --no-deps --all-features

# Auto-detect documentation directory
# Check if doc exists in target/doc or target/*/doc
if [ -d "target/doc" ]; then
DOC_DIR="target/doc"
else
# Find doc directory under target/*/doc pattern
DOC_DIR=$(find target -type d -name doc -path "target/*/doc" | head -n 1)
if [ -z "$DOC_DIR" ]; then
echo "Error: Could not find documentation directory"
exit 1
fi
fi

echo "Documentation found in: $DOC_DIR"
printf '<meta http-equiv="refresh" content="0;url=%s/index.html">' $(cargo tree | head -1 | cut -d' ' -f1) > "${DOC_DIR}/index.html"
echo "DOC_DIR=${DOC_DIR}" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.DOC_DIR }}

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
Loading