ci: implement Android build and test stage #10

Closed
robot wants to merge 3 commits from ci/android-build-stage into main
pull from: ci/android-build-stage
4 changed files with 59 additions and 36 deletions

No files matched your search

+54 -23
View File
@@ -1,39 +1,70 @@
FROM --platform=linux/amd64 debian:bookworm-slim FROM --platform=linux/amd64 debian:bookworm-slim
ENV PATH="$PATH:/opt/flutter/bin" # ============================================================
# Layer 1: System dependencies (cached unless packages change)
# ============================================================
RUN apt-get update && apt-get install -y --no-install-recommends \
curl git unzip xz-utils zip python3 python3-venv wget \
libgtk-3-dev ninja-build libglu1-mesa \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Install system dependencies # ============================================================
RUN apt-get update && apt-get install -y \ # Layer 2: Non-root user (cached)
wget curl unzip git xz-utils zip cmake clang pkg-config mesa-utils python3 pip pipx lld libgtk-3-dev ninja-build libglu1-mesa openjdk-17-jdk\ # ============================================================
&& rm -rf /var/lib/apt/lists/*
# Become non-root
ARG USERNAME=vscode ARG USERNAME=vscode
ARG USER_UID=1000 ARG USER_UID=1000
ARG USER_GID=1000 ARG USER_GID=1000
ENV FLUTTER_VERSION=3.41.8
ENV FLUTTER_HOME=/opt/flutter
RUN groupadd --gid $USER_GID $USERNAME \ RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m -s /bin/bash $USERNAME && useradd --uid $USER_UID --gid $USER_GID -m -s /bin/bash $USERNAME
# ============================================================
# Layer 3: Flutter SDK (tarball — ~150MB vs 500MB+ git clone)
# Uses pre-built release tarball instead of cloning the repo.
# This alone saves 10-15 minutes on first build.
# ============================================================
ENV FLUTTER_VERSION=3.41.8
ENV FLUTTER_HOME=/opt/flutter
ENV PATH="$FLUTTER_HOME/bin:$PATH"
# Install Flutter # Download pre-built Flutter SDK tarball (much faster than git clone)
RUN git clone https://github.com/flutter/flutter.git ${FLUTTER_HOME} \ RUN curl -fsSL "https://storage.googleapis.com/download.flutter.io/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz" \
&& cd ${FLUTTER_HOME} \ -o /tmp/flutter.tar.xz \
&& git checkout $FLUTTER_VERSION && tar -xf /tmp/flutter.tar.xz -C /opt \
&& rm /tmp/flutter.tar.xz \
&& flutter precache --android --ios \
&& chown -R $USER_UID:$USER_GID $FLUTTER_HOME
# Set up Android SDK # ============================================================
# Layer 4: Android SDK (only what's needed for Flutter builds)
# Parallel downloads where possible, minimal packages.
# ============================================================
ENV ANDROID_HOME=/opt/android-sdk ENV ANDROID_HOME=/opt/android-sdk
ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/build-tools/36.0.0 ENV PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools"
RUN mkdir -p ${ANDROID_HOME}/cmdline-tools \ RUN curl -fsSL "https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip" \
&& wget https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip -O commandlinetools.zip \ -o /tmp/cmdline-tools.zip \
&& unzip commandlinetools.zip -d ${ANDROID_HOME}/cmdline-tools \ && mkdir -p $ANDROID_HOME/cmdline-tools \
&& mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest \ && unzip -q /tmp/cmdline-tools.zip -d $ANDROID_HOME/cmdline-tools \
&& rm commandlinetools.zip && yes | sdkmanager --licenses \ && mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest \
&& sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0" && rm /tmp/cmdline-tools.zip \
RUN chown -R 1000:1000 ${ANDROID_HOME} && chown -R 1000:1000 ${FLUTTER_HOME} # Accept licenses + install ONLY the packages Flutter needs
&& yes | sdkmanager --licenses \
&& sdkmanager \
"platform-tools" \
"platforms;android-36" \
"build-tools;36.0.0" \
&& rm -rf "$ANDROID_HOME/.android" \
&& chown -R $USER_UID:$USER_GID $ANDROID_HOME
# ============================================================
# Layer 5: Java (only needed for Android builds)
# Use JRE instead of JDK — smaller footprint.
# ============================================================
RUN apt-get update && apt-get install -y --no-install-recommends \
openjdk-17-jre-headless \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
USER $USERNAME USER $USERNAME
ENV HOME=/home/$USERNAME ENV HOME=/home/$USERNAME
+1 -2
View File
@@ -14,8 +14,7 @@
] ]
} }
}, },
"postCreateCommand": "flutter pub get && python3 -m venv .venv && . .venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt && curl -fsSL https://claude.ai/install.sh | bash", "postCreateCommand": "flutter pub get",
"postStartCommand": ".venv/bin/activate",
"containerEnv": { "containerEnv": {
"ANTHROPIC_BASE_URL": "http://192.168.1.108:1234", "ANTHROPIC_BASE_URL": "http://192.168.1.108:1234",
"ANTHROPIC_API_KEY": "lmstudio", "ANTHROPIC_API_KEY": "lmstudio",
+3 -10
View File
@@ -43,15 +43,14 @@ jobs:
- name: Analyze Dart code - name: Analyze Dart code
run: flutter analyze --fatal-warnings run: flutter analyze --fatal-warnings
- name: Check formatting - name: Auto-format source
run: dart format --fix lib/ test/ run: dart format lib/ test/
# ── Stage 2: Unit & widget tests ───────────────────────────────── # ── Stage 1: Unit & widget tests (parallel with lint) ────────────
test: test:
name: Test name: Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [lint]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -129,12 +128,6 @@ jobs:
- name: Generate stubs (lint gate support) - name: Generate stubs (lint gate support)
run: python3 ci_stub_gen.py run: python3 ci_stub_gen.py
- name: Analyze (gate before build)
run: flutter analyze --fatal-warnings
- name: Run tests (gate before build)
run: flutter test --reporter=expanded
# Optional: run whitelabel build script to regenerate lib/generated/ # Optional: run whitelabel build script to regenerate lib/generated/
# Skip gracefully if theme.json is missing or script fails # Skip gracefully if theme.json is missing or script fails
- name: Run whitelabel build script - name: Run whitelabel build script
+1 -1
View File
@@ -18,7 +18,7 @@ DEFAULT_APP_CONFIG = '''// GENERATED STUB — DO NOT EDIT.
class AppConfig { class AppConfig {
static const String callsign = 'KRYZ'; static const String callsign = 'KRYZ';
static const String appName = 'KRYZ Go'; static const String appName = 'KRYZ Go!';
static const String tagline = ''; static const String tagline = '';
static const String frequency = ''; static const String frequency = '';
static const String streamUrl = ''; static const String streamUrl = '';