🎨 Simplify the logic of actions and fix the Mac environment

This commit is contained in:
Tw93
2025-09-07 07:01:16 +08:00
parent b5a3b624a6
commit c1938e9fa6
3 changed files with 29 additions and 46 deletions

View File

@@ -1,13 +1,15 @@
name: Setup Development Environment name: Setup Development Environment
description: One-stop setup with smart presets description: Unified environment setup with Node.js, Rust, and system dependencies
# Modes: full (default), node-only, rust-only, build (with cache)
inputs: inputs:
mode: mode:
description: "Setup mode: full, node-only, rust-only, or build" description: |
Setup mode:
- build: Complete environment (Node + Rust + System deps + Cache)
- node: Node.js only (pnpm + Node 22)
- rust: Rust only (toolchain + targets)
required: false required: false
default: "full" default: "build"
outputs: outputs:
setup-complete: setup-complete:
@@ -17,7 +19,7 @@ outputs:
runs: runs:
using: composite using: composite
steps: steps:
# 1. Setup environment flags # Parse mode and set environment flags
- name: Setup environment flags - name: Setup environment flags
shell: bash shell: bash
run: | run: |
@@ -25,33 +27,28 @@ runs:
# Validate and set flags in one pass # Validate and set flags in one pass
case "$MODE" in case "$MODE" in
full) build|full)
echo "SETUP_NODE=true" >> $GITHUB_ENV echo "SETUP_NODE=true" >> $GITHUB_ENV
echo "SETUP_RUST=true" >> $GITHUB_ENV echo "SETUP_RUST=true" >> $GITHUB_ENV
echo "SETUP_SYSTEM=true" >> $GITHUB_ENV echo "SETUP_SYSTEM=true" >> $GITHUB_ENV
;; ;;
node-only) node|node-only)
echo "SETUP_NODE=true" >> $GITHUB_ENV echo "SETUP_NODE=true" >> $GITHUB_ENV
echo "SETUP_RUST=false" >> $GITHUB_ENV echo "SETUP_RUST=false" >> $GITHUB_ENV
echo "SETUP_SYSTEM=false" >> $GITHUB_ENV echo "SETUP_SYSTEM=false" >> $GITHUB_ENV
;; ;;
rust-only) rust|rust-only)
echo "SETUP_NODE=false" >> $GITHUB_ENV echo "SETUP_NODE=false" >> $GITHUB_ENV
echo "SETUP_RUST=true" >> $GITHUB_ENV echo "SETUP_RUST=true" >> $GITHUB_ENV
echo "SETUP_SYSTEM=false" >> $GITHUB_ENV echo "SETUP_SYSTEM=false" >> $GITHUB_ENV
;; ;;
build)
echo "SETUP_NODE=true" >> $GITHUB_ENV
echo "SETUP_RUST=true" >> $GITHUB_ENV
echo "SETUP_SYSTEM=true" >> $GITHUB_ENV
;;
*) *)
echo "❌ Invalid mode: '$MODE'. Valid modes: full, node-only, rust-only, build" echo "❌ Invalid mode: '$MODE'. Valid modes: build, node, rust"
exit 1 exit 1
;; ;;
esac esac
# 2. Node.js Environment Setup # Node.js Environment Setup
- name: Install pnpm - name: Install pnpm
if: env.SETUP_NODE == 'true' if: env.SETUP_NODE == 'true'
uses: pnpm/action-setup@v4 uses: pnpm/action-setup@v4
@@ -71,7 +68,7 @@ runs:
shell: bash shell: bash
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
# 3. Rust Environment Setup # Rust Environment Setup
- name: Setup Rust for Linux - name: Setup Rust for Linux
if: env.SETUP_RUST == 'true' && runner.os == 'Linux' if: env.SETUP_RUST == 'true' && runner.os == 'Linux'
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
@@ -99,7 +96,7 @@ runs:
rustup target add x86_64-apple-darwin rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin rustup target add aarch64-apple-darwin
# 4. System Dependencies # System Dependencies
- name: Install Ubuntu dependencies - name: Install Ubuntu dependencies
if: env.SETUP_SYSTEM == 'true' && runner.os == 'Linux' if: env.SETUP_SYSTEM == 'true' && runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@v1.4.3 uses: awalsh128/cache-apt-pkgs-action@v1.4.3
@@ -140,7 +137,7 @@ runs:
exit 1 exit 1
} }
# 5. Build optimizations (caching) # Build optimizations (caching)
- name: Setup Rust cache - name: Setup Rust cache
if: inputs.mode == 'build' if: inputs.mode == 'build'
uses: actions/cache@v4 uses: actions/cache@v4

View File

@@ -33,6 +33,8 @@ jobs:
- name: Setup Development Environment - name: Setup Development Environment
uses: ./.github/actions/setup-env uses: ./.github/actions/setup-env
with:
mode: node
- name: Auto-fix Prettier formatting - name: Auto-fix Prettier formatting
run: npx prettier --write . --ignore-unknown run: npx prettier --write . --ignore-unknown
@@ -175,29 +177,13 @@ jobs:
steps: steps:
- name: Generate Summary - name: Generate Summary
run: | run: |
echo "# Quality & Testing Summary" >> $GITHUB_STEP_SUMMARY {
echo "" >> $GITHUB_STEP_SUMMARY echo "# Quality & Testing Summary"
echo ""
if [ "${{ needs.auto-format.result }}" == "success" ]; then echo "| Check | Status |"
echo "✅ **Auto Formatting**: PASSED" >> $GITHUB_STEP_SUMMARY echo "|-------|--------|"
else echo "| Auto Formatting | ${{ needs.auto-format.result == 'success' && 'PASSED' || 'FAILED' }} |"
echo "❌ **Auto Formatting**: FAILED" >> $GITHUB_STEP_SUMMARY echo "| Rust Quality | ${{ needs.rust-quality.result == 'success' && 'PASSED' || 'FAILED' }} |"
fi echo "| CLI Tests | ${{ needs.cli-tests.result == 'success' && 'PASSED' || 'FAILED' }} |"
echo "| Release Build | ${{ needs.release-build-test.result == 'success' && 'PASSED' || 'FAILED' }} |"
if [ "${{ needs.rust-quality.result }}" == "success" ]; then } >> $GITHUB_STEP_SUMMARY
echo "✅ **Rust Quality**: PASSED" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Rust Quality**: FAILED" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.cli-tests.result }}" == "success" ]; then
echo "✅ **CLI Tests**: PASSED" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **CLI Tests**: FAILED" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.release-build-test.result }}" == "success" ]; then
echo "✅ **Release Build Test**: PASSED" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Release Build Test**: FAILED" >> $GITHUB_STEP_SUMMARY
fi

View File

@@ -76,7 +76,7 @@ jobs:
- name: Setup Node.js Environment - name: Setup Node.js Environment
uses: ./.github/actions/setup-env uses: ./.github/actions/setup-env
with: with:
mode: ${{ matrix.build == 'linux' && 'full' || 'node-only' }} mode: ${{ (matrix.build == 'linux' || matrix.build == 'macos') && 'build' || 'node' }}
- name: Rust cache restore - name: Rust cache restore
uses: actions/cache/restore@v4.2.0 uses: actions/cache/restore@v4.2.0