From 7fb41b5ad4e1f43ffa38ba9557f1c989bc53ab59 Mon Sep 17 00:00:00 2001 From: TapTap Date: Sat, 14 Nov 2026 19:51:11 +0000 Subject: [PATCH] ci: cut the pipeline from 13 minutes to a single fast build The production Wasm optimizer dominated the old run (about 10 of 13 minutes). Main/PR builds now produce the development Wasm bundle, while the optimized bundle and desktop fat jar are built only for release tags. Merge test and build into one job so a checkout and a Gradle run are not repeated, and bake the Gradle dependency cache plus the Android SDK into the CI image. Raise the version of the image to 2. --- .dockerignore | 11 ++++++++++ .gitea/workflows/ci.yaml | 45 ++++++++++++++++++++++------------------ README.md | 14 ++++++------- ci/Dockerfile | 15 ++++++++++++++ gradle.properties | 4 ++-- 5 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d78c96a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# Keep the Docker build context small; Gradle output and local state are not +# inputs for the warm-up build. +.git +.gradle +**/.gradle +build +**/build +local.properties +.idea +**/*.iml +node_modules diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index e94ad17..68a407f 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -11,42 +11,47 @@ on: env: # Built by scripts/build-ci-image.sh from ci/Dockerfile. - CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-client-ci:1 + CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-client-ci:2 jobs: - test: - runs-on: ubuntu-latest - container: - image: gitea.tap-tap.win/taptap/audiomanager-client-ci:1 - steps: - - uses: actions/checkout@v4 - - name: Unit tests - run: gradle :composeApp:desktopTest --console=plain - build: - needs: test runs-on: ubuntu-latest permissions: contents: write container: - image: gitea.tap-tap.win/taptap/audiomanager-client-ci:1 + image: gitea.tap-tap.win/taptap/audiomanager-client-ci:2 steps: - uses: actions/checkout@v4 - - name: Build Android, desktop and web + - name: Test and build run: | - gradle \ - :composeApp:assembleDebug \ - :composeApp:packageUberJarForCurrentOS \ - :composeApp:wasmJsBrowserDistribution \ - --console=plain + set -euo pipefail + if [[ "$GITHUB_REF" == refs/tags/* ]]; then + gradle \ + :composeApp:desktopTest \ + :composeApp:assembleDebug \ + :composeApp:packageUberJarForCurrentOS \ + :composeApp:wasmJsBrowserDistribution \ + --console=plain + else + # The optimized Wasm build is CPU-bound and slow; main/PR builds + # only need to prove the web target compiles and bundles. + gradle \ + :composeApp:desktopTest \ + :composeApp:assembleDebug \ + :composeApp:wasmJsBrowserDevelopmentExecutableDistribution \ + --console=plain + fi - name: Collect artifacts run: | + set -euo pipefail mkdir -p dist cp composeApp/build/outputs/apk/debug/composeApp-debug.apk dist/AudioManager.apk - cp composeApp/build/compose/jars/*.jar dist/AudioManager-desktop.jar - (cd composeApp/build/dist/wasmJs/productionExecutable && zip -qr "$GITHUB_WORKSPACE/dist/AudioManager-web.zip" .) + if [[ "$GITHUB_REF" == refs/tags/* ]]; then + cp composeApp/build/compose/jars/*.jar dist/AudioManager-desktop.jar + (cd composeApp/build/dist/wasmJs/productionExecutable && zip -qr "$GITHUB_WORKSPACE/dist/AudioManager-web.zip" .) + fi - name: Publish release assets if: startsWith(github.ref, 'refs/tags/') diff --git a/README.md b/README.md index 34cc2f6..27b597c 100644 --- a/README.md +++ b/README.md @@ -104,19 +104,19 @@ Adding a song makes it a permanent seed, so it is always eligible in future radi ## CI and releases -`.gitea/workflows/ci.yaml` runs on Gitea Actions using `gitea.tap-tap.win/taptap/audiomanager-client-ci:1`: +`.gitea/workflows/ci.yaml` runs on Gitea Actions using `gitea.tap-tap.win/taptap/audiomanager-client-ci:2`. The image has the Android SDK installed and a warmed Gradle dependency cache, so jobs do not download either on every run. -1. `desktopTest` — shared API/cache tests. -2. Build Android APK, desktop fat jar and Wasm bundle. -3. Upload artifacts. -4. On a `v*` tag, attach the three artifacts to the Gitea release. +- **main / PR:** run `desktopTest`, build the Android APK and the *development* Wasm bundle. The optimized Wasm build is CPU-bound and reserved for releases. +- **`v*` tag:** additionally build the desktop fat jar and the optimized Wasm bundle, then attach all three to the Gitea release. -Rebuild the CI image after changing `ci/Dockerfile`: +Rebuild the CI image after changing `ci/Dockerfile` or dependency versions: ```bash -scripts/build-ci-image.sh 2 +scripts/build-ci-image.sh 3 ``` +The image build performs one warm-up compile (`desktopTest`, `assembleDebug`, `compileKotlinWasmJs`) and then removes the sources, keeping only `/root/.gradle`. + ## Known limitations - Android playback runs inside the app process; a foreground `MediaSessionService` with a notification and lock-screen controls is the next step. diff --git a/ci/Dockerfile b/ci/Dockerfile index d9afc7c..0beec1a 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -43,6 +43,21 @@ RUN mkdir -p "$ANDROID_HOME/cmdline-tools" \ "build-tools;35.0.0" \ && rm -rf "$ANDROID_HOME/.temp" "$ANDROID_HOME/.downloadIntermediates" +# Warm the Gradle dependency cache and the Kotlin/Wasm (node, yarn, binaryen) +# toolchain so CI jobs do not download them on every run. Rebuild this image +# when dependencies change. +COPY . /warmup +WORKDIR /warmup +# Only warm dependencies and the common/Android/desktop compilers here. The +# Wasm executable build is memory hungry; the web job downloads node/yarn itself. +RUN sed -i 's/kotlin.daemon.jvmargs=-Xmx3g/kotlin.daemon.jvmargs=-Xmx2g/' gradle.properties \ + && gradle --no-daemon --max-workers=2 \ + :composeApp:desktopTest \ + :composeApp:assembleDebug \ + :composeApp:compileKotlinWasmJs \ + --console=plain \ + && rm -rf /warmup + WORKDIR /workspace CMD ["sleep", "infinity"] diff --git a/gradle.properties b/gradle.properties index bd98a10..f7319dc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ -org.gradle.jvmargs=-Xmx3g -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.caching=true kotlin.code.style=official -kotlin.daemon.jvmargs=-Xmx2g +kotlin.daemon.jvmargs=-Xmx3g android.useAndroidX=true android.nonTransitiveRClass=true