From 5df60697a3e2f5e01043c73ecf34eb69fa998fdd Mon Sep 17 00:00:00 2001 From: HendrikRauh <114620133+HendrikRauh@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:16:36 +0100 Subject: [PATCH] add cache for build --- .github/actions/nix-devshell/action.yml | 29 +++++++++++++++++++ .github/workflows/android.yaml | 37 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/.github/actions/nix-devshell/action.yml b/.github/actions/nix-devshell/action.yml index d0f47b1..1154dde 100644 --- a/.github/actions/nix-devshell/action.yml +++ b/.github/actions/nix-devshell/action.yml @@ -12,6 +12,14 @@ inputs: "Commands to run inside the devshell (executed with bash -lc)." required: false default: "" + cachix_cache: + description: "Optional Cachix cache name to use (e.g. myorg). Requires `cachix_auth` for private caches." + required: false + default: "" + cachix_auth: + description: "Optional Cachix auth token used to access private caches (pass via secrets)." + required: false + default: "" runs: using: "composite" @@ -29,6 +37,27 @@ runs: fi nix --version + - name: (Optional) Configure Cachix binary cache + if: ${{ inputs.cachix_cache != '' }} + shell: bash + run: | + set -euo pipefail + # install cachix CLI if absent (via nix) + if ! command -v cachix >/dev/null 2>&1; then + if command -v nix >/dev/null 2>&1; then + nix profile install nixpkgs#cachix || true + else + echo "nix not available - cannot install cachix" + exit 1 + fi + fi + # authenticate if auth token provided (for private caches) + if [ -n "${{ inputs.cachix_auth }}" ]; then + echo "${{ inputs.cachix_auth }}" | cachix authtoken - || true + fi + # use the provided cachix cache + cachix use "${{ inputs.cachix_cache }}" || true + - name: Prebuild devshell if: ${{ inputs.prebuild == 'true' }} shell: bash diff --git a/.github/workflows/android.yaml b/.github/workflows/android.yaml index bc751fe..25042ae 100644 --- a/.github/workflows/android.yaml +++ b/.github/workflows/android.yaml @@ -14,10 +14,47 @@ jobs: - name: Checkout code uses: actions/checkout@v6 + - name: Cache Nix store/cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/nix + ~/.nix-profile + ~/.local/share/nix + key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock','flake.nix') }} + restore-keys: | + ${{ runner.os }}-nix- + + - name: Cache Flutter Pub + uses: actions/cache@v4 + with: + path: ~/.pub-cache + key: ${{ runner.os }}-pub-${{ hashFiles('pubspec.lock','pubspec.yaml') }} + restore-keys: | + ${{ runner.os }}-pub- + + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + android/.gradle + key: ${{ runner.os }}-gradle-${{ hashFiles('android/gradle.properties','android/gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Prepare Nix devshell uses: ./.github/actions/nix-devshell with: prebuild: "true" + cachix_cache: ${{ secrets.CACHIX_CACHE }} + cachix_auth: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Restore Dart packages + uses: ./.github/actions/nix-devshell + with: + commands: flutter pub get - name: Collect Translation Files uses: ./.github/actions/nix-devshell