ci: prebuilt CI image with the Android SDK, Gradle and pub cache
Every build started from the bare Flutter image: Gradle installed two NDKs, build-tools, platform 35 and CMake (~4 min) and resolved all its dependencies from scratch (assembleRelease 13-17 min). .gitea/ci/Dockerfile adds those SDK packages, the Android engine artifacts and node (for JS actions). The ci-image job builds it into the Docker of the big runner, tagged by the Dockerfile hash, and reuses it otherwise. actions/cache keeps the Gradle home (with the build cache on) and the pub cache. The build warns when Gradle still installs an SDK package, i.e. when upstream moved to a new NDK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e8ea12c1c9
commit
3bdb46c815
2 files changed
+85
-4
No files matched your search
@@ -41,16 +41,44 @@ defaults:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
# CI image (.gitea/ci/Dockerfile: Flutter + the Android SDK packages and
|
||||
# engine artifacts every build used to download, ~4 min) tagged by a hash
|
||||
# of its Dockerfile. Built straight into the Docker of the `big` runner
|
||||
# (grg-runner, the only one with that label) and never pushed: the job
|
||||
# container below then starts from the local image. If the image is gone
|
||||
# (prune), this job just builds it again.
|
||||
ci-image:
|
||||
runs-on: big
|
||||
outputs:
|
||||
image: ${{ steps.img.outputs.image }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- name: Build the CI image if its Dockerfile changed
|
||||
id: img
|
||||
run: |
|
||||
set -euo pipefail
|
||||
hash=$(sha256sum .gitea/ci/Dockerfile | cut -c1-12)
|
||||
tag="meshcore-open-ci:$hash"
|
||||
if docker image inspect "$tag" >/dev/null 2>&1; then
|
||||
echo "$tag already built"
|
||||
else
|
||||
docker build -t "$tag" .gitea/ci
|
||||
docker images meshcore-open-ci --format '{{.Tag}}' | grep -vx "$hash" |
|
||||
xargs -r -I{} docker rmi "meshcore-open-ci:{}" || true
|
||||
fi
|
||||
echo "image=$tag" >>"$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: ci-image
|
||||
runs-on: big
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
container:
|
||||
image: ghcr.io/cirruslabs/flutter:stable@sha256:46691e311715845de03a3ba4753a475476936805b29431b1f00f1816981033f8
|
||||
image: ${{ needs.ci-image.outputs.image }}
|
||||
steps:
|
||||
# Plain git instead of actions/checkout: that is a JS action and the
|
||||
# image (Ubuntu 24.04) only offers node 18.
|
||||
# Plain git instead of actions/checkout: it also leaves the push
|
||||
# credentials for the merge commit in place.
|
||||
- name: Checkout
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||
@@ -100,6 +128,19 @@ jobs:
|
||||
echo "needed=true" >>"$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# Gradle (deps, wrapper, build cache) and pub caches; the paths are set
|
||||
# in .gitea/ci/Dockerfile. Without it Gradle spent ~17 min per build.
|
||||
- name: Gradle and pub cache
|
||||
if: steps.rel.outputs.needed == 'true'
|
||||
uses: actions/cache@v6
|
||||
with:
|
||||
path: |
|
||||
/ci-cache/gradle/caches
|
||||
/ci-cache/gradle/wrapper
|
||||
/ci-cache/pub
|
||||
key: android-${{ hashFiles('pubspec.lock', 'android/**/*.gradle.kts', 'android/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
restore-keys: android-
|
||||
|
||||
- name: Tests
|
||||
if: steps.rel.outputs.needed == 'true'
|
||||
run: |
|
||||
@@ -145,7 +186,12 @@ jobs:
|
||||
# Minutes since 2026-01-01: monotonic, and far above upstream's codes.
|
||||
code=$((($(date -u +%s) - 1767225600) / 60))
|
||||
flutter build apk --release --no-pub --target-platform android-arm64 \
|
||||
--build-name "$name" --build-number "$code"
|
||||
--build-name "$name" --build-number "$code" 2>&1 | tee "$RUNNER_TEMP/build.log"
|
||||
# The CI image should already hold every SDK package; an install here
|
||||
# means upstream moved on (new NDK, ...) - update .gitea/ci/Dockerfile.
|
||||
if grep '^Installing ' "$RUNNER_TEMP/build.log"; then
|
||||
echo "::warning::Gradle installed SDK packages missing from .gitea/ci/Dockerfile (see above)"
|
||||
fi
|
||||
rm -f android/key.properties "$ks"
|
||||
apk="$RUNNER_TEMP/meshcore-open-$name-arm64.apk"
|
||||
cp build/app/outputs/flutter-apk/app-release.apk "$apk"
|
||||
|
||||
Reference in new issue
Block a user