Files
cutdex/.gitea/CI_PERFORMANCE.md
T
lingjhf 5a0ffa513c
Gitea CI / Check code and tests (pull_request) Successful in 6m19s
Gitea CI / Build Windows x64 app (pull_request) Successful in 3m12s
Gitea CI / Build Android APK (pull_request) Successful in 3m39s
Gitea CI / Audit and package Windows x64 (pull_request) Successful in 1m4s
Gitea CI / Assemble and validate CI artifacts (pull_request) Successful in 50s
Gitea CI / Gitea CI passed (pull_request) Successful in 2s
refactor(ci): unify build environment initialization
2026-10-06 17:58:03 +08:00

117 lines
7.6 KiB
Markdown

# CI build performance
The workflow runs checks first, then Android and Windows compilation concurrently.
Windows compilation saves `cutdex-windows-app`; an independent Windows job
downloads that app, audits it and creates Velopack packages. Packaging needs
neither Flutter dependencies nor another Windows compilation. The Android job
builds the APK. The final job downloads only platform packages and
validates the complete release manifest, update feed and checksums. The public
artifact remains `cutdex-release-packages`.
Build jobs explicitly use persistent runner-user Pub and Gradle caches, respecting
existing `PUB_CACHE` and `GRADLE_USER_HOME` overrides. Gradle task output caching is
enabled for CI. Do not clear these caches between runs. Each job must have its own
checkout; do not share a Flutter `build/` or `.dart_tool/` directory between jobs.
With an ephemeral runner, these user directories must be persisted separately.
The local `prepare-flutter` action owns cache setup, Flutter version validation,
optional Java configuration and locked dependency resolution for the quality,
Android and Windows compilation jobs. `FLUTTER_VERSION` is declared once in the
CI workflow. The separate `prepare-windows-packaging` action owns the user .NET
installation and packaging tool setup, so packaging retries do not resolve
Flutter dependencies. Individual setup steps remain visible within each action.
Workflow-level environment variables contain only shared nonsecret settings.
The SDK token is limited to quality and platform compilation jobs. The fixed
Maven account name is set only on the Android build step, matching the SDK token
owner rather than the user who triggered CI. Assembly needs no SDK credentials;
Release credentials remain confined to the Release workflow's publishing jobs.
Build commands keep Flutter's default Pub preparation after the explicit locked
resolution. Do not use `--no-pub`: Flutter also regenerates release plugin
registrants in that preparation, removing dev-only plugins such as integration_test.
The runner needs at least two execution slots. The local runner configuration at
`D:/workspace/gitea-stack/runner/config.yaml` currently has `capacity: 2`. The host
has 12 logical processors and approximately 16 GB RAM; the Android job retains its
3 GB heap and four-worker limit to leave room for concurrent Windows compilation.
`prepare-package-tools.ps1` installs pinned `pefile` and `vpk` on first use under
the runner user's `%LOCALAPPDATA%/Cutdex/ci-tools/`. Later builds reuse them after
version checks. Python interpreter identity and tool versions isolate the cache,
and a mutex protects installation across concurrent workflows. .NET setup remains
in the Windows packaging job to provide SDK 10 and the runtime required by `vpk`.
The .NET installation uses the runner user's `Cutdex/ci-tools/dotnet` directory
through `DOTNET_INSTALL_DIR` and `DOTNET_ROOT`, so setup needs no administrator
access and later jobs reuse the installed SDK and runtime.
The Windows build verifies that the resolved deskup native SDK matches the pinned
Velopack version before saving the app. Packaging imports no Flutter package
configuration and independently verifies the installed vpk version.
APK and Windows package uploads use `compression-level: 0` to avoid recompressing
already compressed artifacts. The saved Windows app uses compression level 1,
preserves nested and hidden runtime assets, and excludes the same debug files and
optional workers omitted by packaging. The saved app, platform packages, compact
metadata and validated release artifact all retain 30 days.
This host runs both Gitea and the runner. The workflows set
`CUTDEX_GITEA_INTERNAL_URL=http://127.0.0.1:3000` and override `ACTIONS_RESULTS_URL`
on artifact upload/download steps, so those transfers stay on the host instead of
looping through the public FRP tunnel. Release API uploads and byte verification
also use this loopback endpoint; tooling rewrites only the validated public Gitea
origin. The server's public URL remains `https://git.orangraph.com`, and the runner
registration is unchanged. These workflow labels require this shared-host layout;
configure a reachable private endpoint before using runners on other hosts.
Checkout uses the same endpoint through its `github-server-url` input, retaining
the requested commit/tag and disabling persisted credentials. Release requests
retain the public Host header so Gitea response links pass the public-origin checks.
CI artifact ZIP download requests retain the loopback Host instead: Gitea returns
a signed redirect to the raw archive, and its Host must remain local for that
second request to avoid the public tunnel. Release attachment links stay public.
Compare warm CI runs after the first cache fill. Measure checks, Android compile,
Windows compile, packaging and artifact transfer separately. Total duration follows
the slower platform branch, plus checks and final assembly; no fixed speedup is
assumed. Release audits and artifact validation remain mandatory.
## Failure recovery
Use Gitea's failed-job rerun rather than rerunning the entire workflow. A job
reruns from its first step, including downstream dependent jobs. Once the Windows
app artifact has been saved, a Windows packaging failure can be retried without
recompilation. Assembly failures reuse the saved Android and Windows packages;
Release failures reuse the successful main CI. Splitting Windows adds one app
upload/download on successful runs in exchange for this recovery point.
Every CI artifact upload uses the local `upload-artifact` composite, with at most
three action attempts and 5/15-second delays. Attempts replace incomplete
artifacts with the same name; each name belongs to one producing job. Exhausted
retries fail the job. If the first Windows app checkpoint cannot be uploaded,
the build job must still be rerun; it has no saved app to restore.
Release attachment uploads retry temporary network errors, HTTP 408/429 and
500/502/503/504 up to three POST attempts per file, also with 5/15-second delays.
The specific FRP HTML "Not Found" page observed during tunnel reconnection is
also treated as temporary; ordinary Gitea API or HTML 404 responses still fail.
Before retrying a POST, the uploader checks whether Gitea already saved the named
attachment, including after the final response is lost. This avoids duplicate
uploads after a timeout. Authorization, invalid-input and other permanent errors
fail immediately. No draft creation or publication PATCH is automatically retried.
Attachment-list reads have their own bounded retries. Final byte verification
remains mandatory even when an existing filename is reused.
The tag/manual Release workflow reuses a successful main CI for the exact tagged
commit; it performs no Flutter builds, dependency resolution or Windows packaging.
A prepare job binds the draft and both platform upload jobs to one CI run. Android
and Windows independently fetch and upload their existing packages in parallel.
Publication requires the small cutdex-release-metadata artifact; it never
downloads the combined binary artifact. Missing or expired metadata/platform
artifacts fail preparation, with no old-format fallback. Every remote file is read and verified once, immediately
before publication, with two verification workers and 1 MiB chunks. Platform
upload steps check presence without repeating binary readbacks. Each upload
batch also uses at most two workers; while both platform jobs run, Android can
have one upload in flight alongside two Windows uploads.
Retries retain the original CI-run binding. Ordinary CI never creates
drafts. Wait for main CI success before tagging or retry Release after it finishes;
platform Release uploads overlap each other, not the original main builds.