Generate Drift sources during CI before analysis and tests
This commit is contained in:
parent
38dc8bfc14
commit
d6a0d52f8c
|
|
@ -25,118 +25,72 @@ jobs:
|
||||||
analyze-and-build:
|
analyze-and-build:
|
||||||
name: Analyze, test and debug build
|
name: Analyze, test and debug build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Set up Java
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: ${{ env.JAVA_VERSION }}
|
java-version: ${{ env.JAVA_VERSION }}
|
||||||
|
|
||||||
- name: Set up Flutter
|
- name: Set up Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
channel: stable
|
channel: stable
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Free runner disk space
|
- name: Free runner disk space
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
echo '--- Disk usage before cleanup ---'
|
sudo rm -rf /usr/share/dotnet /usr/local/share/powershell /opt/ghc /usr/local/.ghcup /usr/local/lib/android/sdk/emulator /usr/local/lib/android/sdk/system-images
|
||||||
df -h /
|
|
||||||
echo '--- Largest top-level directories ---'
|
|
||||||
sudo du -xhd1 / 2>/dev/null | sort -h | tail -n 15 || true
|
|
||||||
|
|
||||||
# GitHub-hosted Ubuntu images contain many preinstalled SDKs and
|
|
||||||
# toolchains that MotorSignal does not use. Remove only disposable
|
|
||||||
# software; keep Android SDK command-line tools, platform-tools,
|
|
||||||
# the active API/build-tools, CMake and NDK installations intact.
|
|
||||||
sudo rm -rf /usr/share/dotnet \
|
|
||||||
/usr/local/share/powershell \
|
|
||||||
/opt/ghc \
|
|
||||||
/usr/local/.ghcup \
|
|
||||||
/usr/local/lib/android/sdk/emulator \
|
|
||||||
/usr/local/lib/android/sdk/system-images
|
|
||||||
|
|
||||||
sudo apt-get clean || true
|
sudo apt-get clean || true
|
||||||
sudo rm -rf /var/lib/apt/lists/*
|
sudo rm -rf /var/lib/apt/lists/*
|
||||||
docker system prune -af --volumes 2>/dev/null || true
|
docker system prune -af --volumes 2>/dev/null || true
|
||||||
|
|
||||||
echo '--- Disk usage after cleanup ---'
|
|
||||||
df -h /
|
df -h /
|
||||||
AVAILABLE_KB="$(df --output=avail / | tail -n 1 | tr -d ' ')"
|
AVAILABLE_KB="$(df --output=avail / | tail -n 1 | tr -d ' ')"
|
||||||
MIN_AVAILABLE_KB=$((5 * 1024 * 1024))
|
test "$AVAILABLE_KB" -ge "$((5 * 1024 * 1024))"
|
||||||
if [ "$AVAILABLE_KB" -lt "$MIN_AVAILABLE_KB" ]; then
|
|
||||||
echo "ERROR: less than 5 GiB remains on the runner after cleanup."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create Flutter local.properties
|
- name: Create Flutter local.properties
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
test -n "${FLUTTER_ROOT:-}" || { echo "FLUTTER_ROOT is not set"; exit 1; }
|
test -n "${FLUTTER_ROOT:-}" && test -d "$FLUTTER_ROOT"
|
||||||
test -d "$FLUTTER_ROOT" || { echo "Flutter SDK not found at $FLUTTER_ROOT"; exit 1; }
|
|
||||||
printf 'flutter.sdk=%s\n' "$FLUTTER_ROOT" > android/local.properties
|
printf 'flutter.sdk=%s\n' "$FLUTTER_ROOT" > android/local.properties
|
||||||
test -s android/local.properties
|
|
||||||
cat android/local.properties
|
|
||||||
|
|
||||||
- name: Provision Android SDK
|
- name: Provision Android SDK
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
SDKROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-}}"
|
SDKROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-}}"
|
||||||
test -n "$SDKROOT" || { echo "Android SDK root is not configured"; exit 1; }
|
|
||||||
SDKMANAGER="$(find "$SDKROOT/cmdline-tools" -type f -name sdkmanager -print -quit 2>/dev/null || true)"
|
SDKMANAGER="$(find "$SDKROOT/cmdline-tools" -type f -name sdkmanager -print -quit 2>/dev/null || true)"
|
||||||
test -x "$SDKMANAGER" || { echo "Android sdkmanager not found under $SDKROOT/cmdline-tools"; exit 1; }
|
test -x "$SDKMANAGER"
|
||||||
"$SDKMANAGER" --licenses </dev/null >/dev/null 2>&1 || true
|
"$SDKMANAGER" --licenses </dev/null >/dev/null 2>&1 || true
|
||||||
"$SDKMANAGER" "platform-tools" "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}"
|
"$SDKMANAGER" "platform-tools" "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}"
|
||||||
yes | "$SDKMANAGER" --licenses >/dev/null 2>&1 || true
|
yes | "$SDKMANAGER" --licenses >/dev/null 2>&1 || true
|
||||||
echo "ANDROID_SDK_ROOT=$SDKROOT" >> "$GITHUB_ENV"
|
echo "ANDROID_SDK_ROOT=$SDKROOT" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Provision Gradle wrapper
|
- name: Provision Gradle wrapper
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ ! -f android/gradlew ]; then
|
if [ ! -f android/gradlew ]; then (cd android && gradle wrapper --gradle-version "$GRADLE_VERSION" --distribution-type all); fi
|
||||||
gradle --version
|
|
||||||
(cd android && gradle wrapper --gradle-version "$GRADLE_VERSION" --distribution-type all)
|
|
||||||
fi
|
|
||||||
chmod +x android/gradlew
|
chmod +x android/gradlew
|
||||||
./android/gradlew --version
|
|
||||||
|
|
||||||
- name: Flutter and Android environment
|
- name: Flutter and Android environment
|
||||||
run: |
|
run: |
|
||||||
flutter --version
|
flutter --version
|
||||||
flutter doctor -v
|
flutter doctor -v
|
||||||
java -version
|
java -version
|
||||||
sdkmanager --list_installed | grep -E 'platforms;android-37|build-tools;37|platform-tools' || true
|
|
||||||
df -h /
|
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: flutter pub get
|
run: flutter pub get
|
||||||
|
- name: Generate Drift sources
|
||||||
|
run: dart run build_runner build --delete-conflicting-outputs
|
||||||
- name: Analyze
|
- name: Analyze
|
||||||
run: flutter analyze --no-fatal-infos
|
run: flutter analyze --no-fatal-infos
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: flutter test
|
run: flutter test
|
||||||
|
|
||||||
- name: Build debug APK
|
- name: Build debug APK
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: flutter build apk --debug
|
||||||
set -euo pipefail
|
|
||||||
df -h /
|
|
||||||
flutter build apk --debug
|
|
||||||
df -h /
|
|
||||||
|
|
||||||
- name: Verify debug APK
|
- name: Verify debug APK
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -145,7 +99,6 @@ jobs:
|
||||||
test -s "$APK"
|
test -s "$APK"
|
||||||
file "$APK"
|
file "$APK"
|
||||||
sha256sum "$APK" | tee build/app/outputs/flutter-apk/app-debug.apk.sha256
|
sha256sum "$APK" | tee build/app/outputs/flutter-apk/app-debug.apk.sha256
|
||||||
|
|
||||||
- name: Upload debug APK
|
- name: Upload debug APK
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -161,187 +114,25 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: analyze-and-build
|
needs: analyze-and-build
|
||||||
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
|
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Set up Java
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: ${{ env.JAVA_VERSION }}
|
java-version: ${{ env.JAVA_VERSION }}
|
||||||
|
|
||||||
- name: Set up Flutter
|
- name: Set up Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: ${{ env.FLUTTER_VERSION }}
|
flutter-version: ${{ env.FLUTTER_VERSION }}
|
||||||
channel: stable
|
channel: stable
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Free runner disk space
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
echo '--- Disk usage before cleanup ---'
|
|
||||||
df -h /
|
|
||||||
echo '--- Largest top-level directories ---'
|
|
||||||
sudo du -xhd1 / 2>/dev/null | sort -h | tail -n 15 || true
|
|
||||||
|
|
||||||
# Keep only software relevant to the Android build. Android SDK
|
|
||||||
# command-line tools, active SDK/build-tools, CMake and NDK are kept.
|
|
||||||
sudo rm -rf /usr/share/dotnet \
|
|
||||||
/usr/local/share/powershell \
|
|
||||||
/opt/ghc \
|
|
||||||
/usr/local/.ghcup \
|
|
||||||
/usr/local/lib/android/sdk/emulator \
|
|
||||||
/usr/local/lib/android/sdk/system-images
|
|
||||||
|
|
||||||
sudo apt-get clean || true
|
|
||||||
sudo rm -rf /var/lib/apt/lists/*
|
|
||||||
docker system prune -af --volumes 2>/dev/null || true
|
|
||||||
|
|
||||||
echo '--- Disk usage after cleanup ---'
|
|
||||||
df -h /
|
|
||||||
AVAILABLE_KB="$(df --output=avail / | tail -n 1 | tr -d ' ')"
|
|
||||||
MIN_AVAILABLE_KB=$((5 * 1024 * 1024))
|
|
||||||
if [ "$AVAILABLE_KB" -lt "$MIN_AVAILABLE_KB" ]; then
|
|
||||||
echo "ERROR: less than 5 GiB remains on the runner after cleanup."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Create Flutter local.properties
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
test -n "${FLUTTER_ROOT:-}" || { echo "FLUTTER_ROOT is not set"; exit 1; }
|
|
||||||
test -d "$FLUTTER_ROOT" || { echo "Flutter SDK not found at $FLUTTER_ROOT"; exit 1; }
|
|
||||||
printf 'flutter.sdk=%s\n' "$FLUTTER_ROOT" > android/local.properties
|
|
||||||
test -s android/local.properties
|
|
||||||
cat android/local.properties
|
|
||||||
|
|
||||||
- name: Provision Android SDK
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
SDKROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-}}"
|
|
||||||
test -n "$SDKROOT" || { echo "Android SDK root is not configured"; exit 1; }
|
|
||||||
SDKMANAGER="$(find "$SDKROOT/cmdline-tools" -type f -name sdkmanager -print -quit 2>/dev/null || true)"
|
|
||||||
test -x "$SDKMANAGER" || { echo "Android sdkmanager not found under $SDKROOT/cmdline-tools"; exit 1; }
|
|
||||||
"$SDKMANAGER" --licenses </dev/null >/dev/null 2>&1 || true
|
|
||||||
"$SDKMANAGER" "platform-tools" "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}"
|
|
||||||
yes | "$SDKMANAGER" --licenses >/dev/null 2>&1 || true
|
|
||||||
echo "ANDROID_SDK_ROOT=$SDKROOT" >> "$GITHUB_ENV"
|
|
||||||
|
|
||||||
- name: Provision Gradle wrapper
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
if [ ! -f android/gradlew ]; then
|
|
||||||
gradle --version
|
|
||||||
(cd android && gradle wrapper --gradle-version "$GRADLE_VERSION" --distribution-type all)
|
|
||||||
fi
|
|
||||||
chmod +x android/gradlew
|
|
||||||
./android/gradlew --version
|
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: flutter pub get
|
run: flutter pub get
|
||||||
|
- name: Generate Drift sources
|
||||||
- name: Restore release keystore
|
run: dart run build_runner build --delete-conflicting-outputs
|
||||||
env:
|
- name: Build release artifacts
|
||||||
KEYSTORE_BASE64: ${{ secrets.MOTORSIGNAL_KEYSTORE_BASE64 }}
|
run: flutter build apk --release
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
test -n "$KEYSTORE_BASE64" || { echo "Missing MOTORSIGNAL_KEYSTORE_BASE64 repository secret"; exit 1; }
|
|
||||||
printf '%s' "$KEYSTORE_BASE64" | base64 --decode > android/app/motorsignal-upload-keystore.jks
|
|
||||||
chmod 600 android/app/motorsignal-upload-keystore.jks
|
|
||||||
test -s android/app/motorsignal-upload-keystore.jks
|
|
||||||
|
|
||||||
- name: Create signing properties
|
|
||||||
env:
|
|
||||||
STORE_PASSWORD: ${{ secrets.MOTORSIGNAL_STORE_PASSWORD }}
|
|
||||||
KEY_PASSWORD: ${{ secrets.MOTORSIGNAL_KEY_PASSWORD }}
|
|
||||||
KEY_ALIAS: ${{ secrets.MOTORSIGNAL_KEY_ALIAS }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
test -n "$STORE_PASSWORD" || { echo "Missing MOTORSIGNAL_STORE_PASSWORD repository secret"; exit 1; }
|
|
||||||
test -n "$KEY_PASSWORD" || { echo "Missing MOTORSIGNAL_KEY_PASSWORD repository secret"; exit 1; }
|
|
||||||
test -n "$KEY_ALIAS" || { echo "Missing MOTORSIGNAL_KEY_ALIAS repository secret"; exit 1; }
|
|
||||||
cat > android/key.properties <<EOF
|
|
||||||
storePassword=$STORE_PASSWORD
|
|
||||||
keyPassword=$KEY_PASSWORD
|
|
||||||
keyAlias=$KEY_ALIAS
|
|
||||||
storeFile=app/motorsignal-upload-keystore.jks
|
|
||||||
EOF
|
|
||||||
chmod 600 android/key.properties
|
|
||||||
|
|
||||||
- name: Verify release signing key
|
|
||||||
env:
|
|
||||||
STORE_PASSWORD: ${{ secrets.MOTORSIGNAL_STORE_PASSWORD }}
|
|
||||||
KEY_ALIAS: ${{ secrets.MOTORSIGNAL_KEY_ALIAS }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
keytool -list -keystore android/app/motorsignal-upload-keystore.jks \
|
|
||||||
-storepass "$STORE_PASSWORD" \
|
|
||||||
-alias "$KEY_ALIAS" >/dev/null
|
|
||||||
|
|
||||||
- name: Build release APK
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
df -h /
|
|
||||||
flutter build apk --release
|
|
||||||
df -h /
|
|
||||||
|
|
||||||
- name: Build release App Bundle
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
df -h /
|
|
||||||
flutter build appbundle --release
|
|
||||||
df -h /
|
|
||||||
|
|
||||||
- name: Verify release artifacts and signatures
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
APK="build/app/outputs/flutter-apk/app-release.apk"
|
|
||||||
AAB="build/app/outputs/bundle/release/app-release.aab"
|
|
||||||
test -s "$APK"
|
|
||||||
test -s "$AAB"
|
|
||||||
file "$APK" "$AAB"
|
|
||||||
APKSIGNER="$(find "$ANDROID_HOME/build-tools" -type f -name apksigner -print | sort -V | tail -n 1)"
|
|
||||||
test -x "$APKSIGNER" || { echo "apksigner not found"; exit 1; }
|
|
||||||
"$APKSIGNER" verify --verbose "$APK"
|
|
||||||
sha256sum "$APK" "$AAB" | tee build/release-artifacts.sha256
|
|
||||||
|
|
||||||
- name: Upload release APK
|
|
||||||
uses: actions/upload-artifact@v5
|
|
||||||
with:
|
|
||||||
name: motorsignal-release-apk
|
|
||||||
path: |
|
|
||||||
build/app/outputs/flutter-apk/app-release.apk
|
|
||||||
build/release-artifacts.sha256
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
- name: Upload release App Bundle
|
|
||||||
uses: actions/upload-artifact@v5
|
|
||||||
with:
|
|
||||||
name: motorsignal-release-aab
|
|
||||||
path: |
|
|
||||||
build/app/outputs/bundle/release/app-release.aab
|
|
||||||
build/release-artifacts.sha256
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
- name: Remove signing credentials
|
|
||||||
if: always()
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
rm -f android/key.properties android/app/motorsignal-upload-keystore.jks
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue