fix(ci): install Flutter to /opt/flutter and use explicit PATH in every step
- GITHUB_PATH does not persist between steps in Gitea Actions/act - Install Flutter to /opt/flutter (system path accessible to all steps) - Explicitly prefix PATH in every flutter/dart command - Also install JDK to /opt/jdk for the same reason - Use env.FLUTTER_VERSION variable for easy version bumps
This commit is contained in:
+62
-62
@@ -5,6 +5,9 @@
|
||||
# NOTE: Gitea's `act` runner registers as `ubuntu-latest`. Jobs MUST use
|
||||
# `runs-on: ubuntu-latest` to be picked up. The runner executes jobs inside
|
||||
# x86_64 Linux Docker containers, so we use Linux SDK binaries.
|
||||
#
|
||||
# IMPORTANT: $GITHUB_PATH does NOT persist between steps in Gitea Actions.
|
||||
# We install Flutter to /opt/flutter so it is available without PATH tricks.
|
||||
|
||||
name: CI
|
||||
|
||||
@@ -19,6 +22,10 @@ concurrency:
|
||||
group: ${{ gitea.workflow }}-${{ gitea.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
FLUTTER_VERSION: "3.35.3"
|
||||
FLUTTER_PATH: "/opt/flutter/bin"
|
||||
|
||||
jobs:
|
||||
# ── Stage 1: Lint & static analysis ──────────────────────────────
|
||||
lint:
|
||||
@@ -30,26 +37,28 @@ jobs:
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
# Direct Flutter SDK download — Linux x86_64 (act container)
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.35.3-stable.tar.xz" \
|
||||
-o flutter.tar.xz
|
||||
tar -xf flutter.tar.xz
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
set -e
|
||||
mkdir -p /opt/flutter
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz" \
|
||||
-o /tmp/flutter.tar.xz
|
||||
tar -xf /tmp/flutter.tar.xz -C /opt/flutter --strip-components=1
|
||||
export PATH="/opt/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
# Write to $GITHUB_PATH for subsequent steps
|
||||
echo "/opt/flutter/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter pub get
|
||||
|
||||
- name: Generate stubs (lint gate support)
|
||||
if: hashFiles('theme.json') == ''
|
||||
run: python3 ci_stub_gen.py
|
||||
run: PATH="/opt/flutter/bin:$PATH" python3 ci_stub_gen.py
|
||||
|
||||
- name: Analyze Dart code
|
||||
run: flutter analyze --fatal-warnings
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter analyze --fatal-warnings
|
||||
|
||||
- name: Check formatting
|
||||
run: dart format --set-exit-if-changed lib/ test/
|
||||
run: PATH="/opt/flutter/bin:$PATH" dart format --set-exit-if-changed lib/ test/
|
||||
|
||||
|
||||
# ── Stage 2: Unit & widget tests ─────────────────────────────────
|
||||
@@ -63,21 +72,23 @@ jobs:
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.35.3-stable.tar.xz" \
|
||||
-o flutter.tar.xz
|
||||
tar -xf flutter.tar.xz
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
set -e
|
||||
mkdir -p /opt/flutter
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz" \
|
||||
-o /tmp/flutter.tar.xz
|
||||
tar -xf /tmp/flutter.tar.xz -C /opt/flutter --strip-components=1
|
||||
export PATH="/opt/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
echo "/opt/flutter/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter pub get
|
||||
|
||||
- name: Generate stubs (lint gate support)
|
||||
run: python3 ci_stub_gen.py
|
||||
run: PATH="/opt/flutter/bin:$PATH" python3 ci_stub_gen.py
|
||||
|
||||
- name: Run tests
|
||||
run: flutter test --reporter=expanded
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter test --reporter=expanded
|
||||
|
||||
|
||||
# ── Stage 3: Android build ──────────────────────────────────────
|
||||
@@ -91,70 +102,71 @@ jobs:
|
||||
|
||||
- name: Setup Java 17
|
||||
run: |
|
||||
# Direct Temurin JDK download — Linux x86_64
|
||||
set -e
|
||||
curl -fsSL "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.12_7.tar.gz" \
|
||||
-o jdk.tar.gz
|
||||
mkdir -p "$HOME/jdk"
|
||||
tar -xzf jdk.tar.gz -C "$HOME/jdk" --strip-components=1
|
||||
export JAVA_HOME="$HOME/jdk"
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
-o /tmp/jdk.tar.gz
|
||||
mkdir -p /opt/jdk
|
||||
tar -xzf /tmp/jdk.tar.gz -C /opt/jdk --strip-components=1
|
||||
export JAVA_HOME="/opt/jdk"
|
||||
export PATH="/opt/jdk/bin:$PATH"
|
||||
java -version
|
||||
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" || export JAVA_HOME="$JAVA_HOME"
|
||||
echo "$JAVA_HOME/bin" >> "$GITHUB_PATH" || export PATH="$JAVA_HOME/bin:$PATH"
|
||||
echo "/opt/jdk/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.35.3-stable.tar.xz" \
|
||||
-o flutter.tar.xz
|
||||
tar -xf flutter.tar.xz
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
set -e
|
||||
mkdir -p /opt/flutter
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz" \
|
||||
-o /tmp/flutter.tar.xz
|
||||
tar -xf /tmp/flutter.tar.xz -C /opt/flutter --strip-components=1
|
||||
export PATH="/opt/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
echo "/opt/flutter/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Install Android SDK command-line tools
|
||||
run: |
|
||||
set -e
|
||||
export ANDROID_HOME="${HOME}/android-sdk"
|
||||
mkdir -p "${ANDROID_HOME}/cmdline-tools"
|
||||
curl -fsSL "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" -o cmdline-tools.zip
|
||||
unzip -q cmdline-tools.zip -d "${ANDROID_HOME}/cmdline-tools"
|
||||
curl -fsSL "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" -o /tmp/cmdline-tools.zip
|
||||
unzip -q /tmp/cmdline-tools.zip -d "${ANDROID_HOME}/cmdline-tools"
|
||||
mv "${ANDROID_HOME}/cmdline-tools/cmdline-tools" "${ANDROID_HOME}/cmdline-tools/latest"
|
||||
export PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}"
|
||||
yes | sdkmanager --licenses >/dev/null 2>&1 || true
|
||||
sdkmanager "platform-tools" "platforms;android-35" "build-tools;35.0.0"
|
||||
echo "ANDROID_HOME=${ANDROID_HOME}" >> "$GITHUB_ENV" || echo "ANDROID_HOME=${ANDROID_HOME}" >> "$HOME/.env"
|
||||
echo "${ANDROID_HOME}/cmdline-tools/latest/bin" >> "$GITHUB_PATH" || export PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}"
|
||||
echo "${ANDROID_HOME}/platform-tools" >> "$GITHUB_PATH" || export PATH="${ANDROID_HOME}/platform-tools:${PATH}"
|
||||
echo "${ANDROID_HOME}/cmdline-tools/latest/bin" >> "$GITHUB_PATH"
|
||||
echo "${ANDROID_HOME}/platform-tools" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Pre-cache Android platform artifacts
|
||||
run: flutter precache --android
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter precache --android
|
||||
|
||||
- name: Accept Android SDK licenses
|
||||
run: |
|
||||
yes | sdkmanager --licenses || true
|
||||
yes | ${HOME}/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses || true
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter pub get
|
||||
|
||||
- name: Generate stubs (lint gate support)
|
||||
run: python3 ci_stub_gen.py
|
||||
run: PATH="/opt/flutter/bin:$PATH" python3 ci_stub_gen.py
|
||||
|
||||
- name: Analyze (gate before build)
|
||||
run: flutter analyze --fatal-warnings
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter analyze --fatal-warnings
|
||||
|
||||
- name: Run tests (gate before build)
|
||||
run: flutter test --reporter=expanded
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter test --reporter=expanded
|
||||
|
||||
# Optional: run whitelabel build script to regenerate lib/generated/
|
||||
# Skip gracefully if theme.json is missing or script fails
|
||||
- name: Run whitelabel build script
|
||||
if: hashFiles('theme.json') != ''
|
||||
run: python3 build_whitelabel.py
|
||||
run: PATH="/opt/flutter/bin:$PATH" python3 build_whitelabel.py
|
||||
|
||||
- name: Build APK (release)
|
||||
run: flutter build apk --release
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter build apk --release
|
||||
|
||||
- name: Build App Bundle (release)
|
||||
run: flutter build appbundle --release
|
||||
run: PATH="/opt/flutter/bin:$PATH" flutter build appbundle --release
|
||||
|
||||
- name: List build outputs
|
||||
run: |
|
||||
@@ -181,22 +193,10 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Flutter
|
||||
run: |
|
||||
curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.35.3-stable.tar.xz" \
|
||||
-o flutter.tar.xz
|
||||
tar -xf flutter.tar.xz
|
||||
export PATH="$PWD/flutter/bin:$PATH"
|
||||
flutter --version
|
||||
echo "$PWD/flutter/bin" >> "$GITHUB_PATH" || echo "$PWD/flutter/bin" >> "$HOME/.env_path"
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
|
||||
- name: Check iOS build feasibility
|
||||
run: |
|
||||
# iOS builds require macOS + Xcode. Our self-hosted runner runs Linux
|
||||
# containers via act, so we can natively build iOS only when running
|
||||
# directly on the Mac host. Skip gracefully here.
|
||||
echo "SKIP: iOS build requires macOS host with Xcode."
|
||||
echo "To enable iOS builds, run this job natively on the Mac host."
|
||||
echo "INFO: iOS builds require macOS host with Xcode."
|
||||
echo "Our self-hosted runner runs Linux containers via act."
|
||||
echo "Skipping iOS build — it will succeed as a no-op."
|
||||
echo "To enable iOS builds, configure a native macOS runner."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user