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

on:
push:
branches: [ main, master ]
tags:
- 'v*'
pull_request:
branches: [ main, master ]
workflow_dispatch:

jobs:
test-common:
name: Run Common Tests
runs-on: [self-hosted, macOS]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Flutter
run: |
flutter --version
flutter doctor -v

- name: Get dependencies
run: flutter pub get

- name: Run common tests
run: ./scripts/ci-test-common.sh

test-linux:
name: Run Linux-Specific Tests
runs-on: [self-hosted, Linux]
needs: test-common
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Flutter
run: |
export PATH="$PATH:$HOME/flutter/bin"
flutter --version
flutter doctor -v

- name: Get dependencies
run: |
export PATH="$PATH:$HOME/flutter/bin"
flutter pub get

- name: Run Linux-specific tests
run: ./scripts/ci-test-linux.sh

build-macos:
name: Build macOS
runs-on: [self-hosted, macOS]
needs: test-common
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Flutter
run: |
flutter --version
flutter doctor -v

- name: Get dependencies
run: flutter pub get

- name: Build macOS app
run: ./scripts/ci-build-macos.sh

- name: Upload macOS artifact
uses: actions/upload-artifact@v4
with:
name: aks-macos
path: |
build/macos/Build/Products/Release/aks.app
retention-days: 7

build-linux:
name: Build Linux (Flatpak)
runs-on: [self-hosted, Linux]
needs: [test-common, test-linux]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Flutter
run: |
export PATH="$PATH:$HOME/flutter/bin"
flutter --version
flutter doctor -v

- name: Get dependencies
run: |
export PATH="$PATH:$HOME/flutter/bin"
flutter pub get

- name: Build Linux app
run: |
export PATH="$PATH:$HOME/flutter/bin"
./scripts/ci-build-linux-native.sh

- name: Upload Linux Flatpak
uses: actions/upload-artifact@v4
with:
name: aks-linux-flatpak
path: aks.flatpak
retention-days: 7


release:
name: Create Release
runs-on: [self-hosted, macOS]
needs: [build-macos, build-linux]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
aks-macos/aks.app
aks-linux-flatpak/aks.flatpak
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62 changes: 62 additions & 0 deletions scripts/ci-build-linux-native.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -e

echo "==================================="
echo "Building aks for Linux (Native)"
echo "==================================="

# Add Flutter to PATH if not already there
export PATH="$PATH:$HOME/flutter/bin"

# Clean previous builds
echo "Cleaning previous builds..."
flutter clean

# Get dependencies
echo "Getting dependencies..."
flutter pub get

# Build Linux app
echo "Building Linux app (release mode)..."
flutter build linux --release --tree-shake-icons

# Check if build was successful
if [ ! -f "build/linux/x64/release/bundle/aks" ]; then
echo "Error: Linux build failed"
exit 1
fi

echo "Linux build complete!"

# Generate icons if needed
if [ -f "generate_app_icons.py" ]; then
echo "Generating app icons..."
python3 generate_app_icons.py || true
fi

# Build Flatpak if manifest exists and flatpak-builder is available
if [ -f "dev.myyc.aks.yaml" ] && command -v flatpak-builder &> /dev/null; then
echo "==================================="
echo "Building Flatpak"
echo "==================================="

# Ensure Flatpak runtime is installed
flatpak install --user -y flathub org.freedesktop.Platform//24.08 || true
flatpak install --user -y flathub org.freedesktop.Sdk//24.08 || true

# Build Flatpak (using cache if available)
# First build creates the app
flatpak-builder --ccache --keep-build-dirs --repo=repo build-dir dev.myyc.aks.yaml

# Build single-file bundle
flatpak build-bundle repo aks.flatpak dev.myyc.aks

echo "Flatpak build complete!"
else
echo "Skipping Flatpak build (flatpak-builder not found or manifest missing)"
fi


echo "==================================="
echo "Linux builds completed successfully!"
echo "==================================="
63 changes: 63 additions & 0 deletions scripts/ci-build-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
set -e

echo "==================================="
echo "Building aks for macOS"
echo "==================================="

# Flutter should be available via Homebrew in PATH

# Clean previous builds
echo "Cleaning previous builds..."
flutter clean

# Get dependencies
echo "Getting dependencies..."
flutter pub get

# Run code generation if needed
if [ -f "build_runner.yaml" ]; then
echo "Running code generation..."
flutter pub run build_runner build --delete-conflicting-outputs
fi

# Build macOS app
echo "Building macOS app..."
flutter build macos --release

# Check if build was successful
if [ ! -d "build/macos/Build/Products/Release/aks.app" ]; then
echo "Error: macOS build failed - app bundle not found"
exit 1
fi

# Get version from pubspec.yaml
VERSION=$(grep "^version:" pubspec.yaml | cut -d' ' -f2 | cut -d'+' -f1)
echo "Built version: $VERSION"

# Optional: Create a DMG for distribution
# Skip DMG creation in CI environments to avoid timeouts
if [ "$CI" = "true" ] || [ "$GITHUB_ACTIONS" = "true" ]; then
echo "Running in CI environment, skipping DMG creation"
elif command -v create-dmg &> /dev/null; then
echo "Creating DMG..."
create-dmg \
--volname "aks" \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
--icon "aks.app" 150 150 \
--hide-extension "aks.app" \
--app-drop-link 450 150 \
--no-internet-enable \
"aks-$VERSION.dmg" \
"build/macos/Build/Products/Release/"
echo "DMG created: aks-$VERSION.dmg"
else
echo "Note: create-dmg not found, skipping DMG creation"
echo "Install with: npm install -g create-dmg"
fi

echo "==================================="
echo "macOS build completed successfully!"
echo "===================================="
47 changes: 47 additions & 0 deletions scripts/ci-test-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -e

echo "==================================="
echo "Running aks common tests"
echo "=================================="

# Flutter should be available via Homebrew in PATH

# Get dependencies first
echo "Getting dependencies..."
flutter pub get

# Analyze code for issues
echo "Running Flutter analyze..."
flutter analyze --no-fatal-infos --no-fatal-warnings || {
echo "Warning: Flutter analyze found issues (continuing anyway)"
}

# Format check (optional - can be strict)
echo "Checking code formatting..."
dart format --set-exit-if-changed --output=none . || {
echo "Warning: Code formatting issues found"
echo "Run 'dart format .' to fix formatting"
# Uncomment the next line to make formatting checks strict
# exit 1
}

# Run common tests (exclude platform-specific tests)
echo "Running common tests..."
if [ -d "test" ] && [ "$(ls -A test/*.dart 2>/dev/null)" ]; then
# Run tests in test/ directory but exclude test/linux/
# Run specific test directories instead of using non-existent --exclude
flutter test --coverage --no-pub test/models/ test/widget_test.dart

# If you want to check coverage threshold (requires lcov)
if command -v lcov &> /dev/null && [ -f "coverage/lcov.info" ]; then
echo "Generating coverage report..."
lcov --summary coverage/lcov.info
fi
else
echo "No tests found in test/ directory"
fi

echo "==================================="
echo "Common tests completed!"
echo "===================================="
36 changes: 36 additions & 0 deletions scripts/ci-test-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e

echo "==================================="
echo "Running aks Linux-specific tests"
echo "=================================="

# Add Flutter to PATH if not already there
export PATH="$PATH:$HOME/flutter/bin"

# Get dependencies first
echo "Getting dependencies..."
flutter pub get

# Build native Linux libraries for tests
echo "Building Linux native libraries..."
if [ -f "scripts/build_test_libs.sh" ]; then
bash scripts/build_test_libs.sh
else
echo "Warning: build_test_libs.sh not found, skipping native library build"
fi

# Run Linux-specific tests
echo "Running Linux-specific tests..."
if [ -d "test/linux" ] && [ "$(ls -A test/linux/*.dart 2>/dev/null)" ]; then
# Run tests in test/linux/ directory
flutter test --no-pub test/linux/

echo "Linux-specific tests completed!"
else
echo "No Linux-specific tests found"
fi

echo "==================================="
echo "Linux tests completed!"
echo "===================================="
Loading