diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b682f4f..39b3e76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,30 +1,163 @@ -name: Rust CI +name: Full Stack CI on: push: branches: [ "main" ] + paths-ignore: + - '**.md' + - '.gitignore' + - 'LICENSE' pull_request: branches: [ "main" ] + paths-ignore: + - '**.md' + - '.gitignore' + - 'LICENSE' workflow_dispatch: env: CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 jobs: - build: - runs-on: macos-latest + # Check if we should skip CI + changes: + name: Detect Changes + runs-on: ubuntu-latest + outputs: + backend: ${{ steps.changes.outputs.backend }} + frontend: ${{ steps.changes.outputs.frontend }} + general: ${{ steps.changes.outputs.general }} + gha: ${{ steps.changes.outputs.gha }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Check for changes + uses: dorny/paths-filter@v3 + id: changes + with: + # Define filters for different parts of the project to conditionally run jobs + filters: | + backend: + - 'src-tauri/**' + frontend: + - 'src/**' + - 'public/**' + - 'package.json' + - 'pnpm-lock.yaml' + - 'index.html' + - 'vite.config.*' + - 'tsconfig.json' + - 'tsconfig.node.json' + - 'postcss.config.js' + - 'tailwind.config.*' + - 'components.json' + - 'app-icon.png' + - 'pnpm-lock.yaml' + general: + - '**.md' + - '.gitignore' + - 'LICENSE' + - 'docs/**' + gha: + - '.github/**' + + + # Combined Full Stack Test and Build + full-stack-test-build: + name: Full Stack Test & Build + runs-on: ${{ matrix.os }} + needs: changes + if: needs.changes.outputs.general == 'false' || (needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' || needs.changes.outputs.gha == 'true') + + strategy: + fail-fast: false + matrix: + os: [ macos-latest ] steps: - - name: Fetch Repository + - name: Checkout Repository uses: actions/checkout@v4 - - name: Install stable Rust toolchain + # Setup all required tools + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'pnpm' + + - name: Install Rust Toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable - target: x86_64-unknown-linux-gnu + cache: true + + # Enhanced caching strategy + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - name: Run tests + - name: Cache All Dependencies + uses: actions/cache@v4 + with: + path: | + ${{ env.STORE_PATH }} + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + src-tauri/target/ + node_modules + dist/ + key: ${{ runner.os }}-fullstack-${{ hashFiles('**/Cargo.lock', '**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-fullstack- + ${{ runner.os }}- + + # Install all dependencies + - name: Install Frontend Dependencies + run: pnpm install --frozen-lockfile + + # Backend tests and checks (if backend changed) + - name: Run Rust Unit Tests + if: needs.changes.outputs.backend == 'true' + run: | + cd src-tauri + cargo test --verbose --all-features --lib + + # Frontend tests and checks (if frontend changed) + - name: Run Frontend Unit Tests + if: needs.changes.outputs.frontend == 'true' + run: pnpm test + env: + NODE_ENV: test + + # Build frontend first (required for Tauri) + - name: Build Frontend + run: pnpm run build + + # Run Tauri integration tests + - name: Run Tauri Integration Tests + run: | + cd src-tauri + cargo test + + # Start backend for integration tests (if needed) + - name: Start Backend for Integration Tests + if: needs.changes.outputs.frontend == 'true' && needs.changes.outputs.backend == 'true' run: | cd src-tauri - cargo test --verbose \ No newline at end of file + cargo check --release + + # Build Tauri application (includes both frontend and backend) + - name: Build Tauri Application + run: pnpm tauri build --verbose + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 0000000..43e30c0 --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,72 @@ +name: Update Version Badge in Markdown Files + +on: + push: + branches: [ "main", "master" ] + paths: [ 'src-tauri/Cargo.toml' ] # Trigger only when Cargo.toml changes + workflow_dispatch: + +jobs: + update-badge: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract version from Cargo.toml + id: get_version + run: | + # Extract version using multiple methods for robustness + if command -v toml &> /dev/null; then + VERSION=$(toml get Cargo.toml package.version --raw 2>/dev/null) + fi + + if [ -z "$VERSION" ]; then + VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') + fi + + if [ -z "$VERSION" ]; then + echo "Error: Could not extract version from Cargo.toml" + exit 1 + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Extracted version: $VERSION" + + - name: Update version badges in all markdown files + run: | + VERSION="${{ steps.get_version.outputs.version }}" + echo "Updating badges to version: $VERSION" + + # Find all markdown files and update the version badge + find . -name "*.md" -type f | while read -r file; do + echo "Checking file: $file" + if grep -q "img.shields.io/badge/Version-" "$file"; then + echo "Updating badge in: $file" + sed -i "s|https://img\.shields\.io/badge/Version-[^-]*-informational|https://img.shields.io/badge/Version-$VERSION-informational|g" "$file" + fi + done + + - name: Check for changes + id: check_changes + run: | + if git diff --quiet; then + echo "changes=false" >> $GITHUB_OUTPUT + echo "No changes detected" + else + echo "changes=true" >> $GITHUB_OUTPUT + echo "Changes detected:" + git diff --name-only + fi + + - name: Commit and push changes + if: steps.check_changes.outputs.changes == 'true' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add -A + git commit -m "๐ Update version badge to v${{ steps.get_version.outputs.version }}" + git push \ No newline at end of file diff --git a/README.md b/README.md index 1cecb63..98be83c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@