-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathaction.yml
More file actions
118 lines (107 loc) · 6.27 KB
/
Copy pathaction.yml
File metadata and controls
118 lines (107 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Shared Flutter toolchain setup for the analyze_and_test jobs. Both jobs pay
# this prefix (checks needs generated code for analyze/tests; integration needs
# it to build the app), so it lives here to keep the two copies from drifting.
#
# Cache notes: keys derive from lockfiles, so they self-invalidate when deps
# change. When both parallel jobs miss the same key (lockfile just changed),
# both build and both try to save — the first save wins, the second logs a
# benign "cache already exists" warning. No restore-keys on the pub cache on
# purpose: it holds the bull_sdk git clone, and a fuzzy fallback can restore a
# checkout from an OLDER lock whose pinned commit differs; pub then resolves
# against that stale clone and `pub get --enforce-lockfile` fails wanting to
# drop deps. The exact key already pins the commit via pubspec.lock.
name: Flutter setup
description: FVM + pub caches, FVM install, deps, build_runner, translations
inputs:
cargo-cache:
description: Also restore the Cargo cache (only the integration job compiles the FRB native crates)
required: false
default: 'false'
runs:
using: composite
steps:
# runner.arch is in the FVM key because the SDK is native binaries — an
# x64 SDK restored on an arm64 runner is broken. pub/cargo caches hold
# sources only (arch-independent), so they keep os-only keys and stay
# shared across arches.
- name: Cache Flutter SDK (FVM)
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/fvm/versions
key: fvm-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.fvmrc') }}
- name: Cache pub (hosted + git deps)
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.pub-cache
key: pub-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
- name: Cache Cargo (FRB native crates)
if: ${{ inputs.cargo-cache == 'true' }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
restore-keys: cargo-${{ runner.os }}-
- name: Install FVM
shell: bash
run: |
case "$(uname -m)" in
x86_64) fvm_arch=x64 ;;
aarch64|arm64) fvm_arch=arm64 ;;
*) echo "Unsupported FVM architecture: $(uname -m)" >&2; exit 1 ;;
esac
archive="$RUNNER_TEMP/fvm-4.1.2-linux-${fvm_arch}.tar.gz"
curl --retry 5 --retry-all-errors -fL \
"https://github.com/conceptadev/fvm/releases/download/4.1.2/fvm-4.1.2-linux-${fvm_arch}.tar.gz" \
-o "$archive"
mkdir -p "$HOME/fvm/bin"
# Extract the whole tree, not just `fvm/fvm`: the two release archives
# have different layouts. x64 ships a self-contained binary, arm64 a
# launcher script that execs `src/dart` relative to its own directory —
# unpacking the launcher alone yields `exec: .../src/dart: not found`
# on every fvm invocation.
tar -xzf "$archive" -C "$HOME/fvm/bin" --strip-components=1
chmod +x "$HOME/fvm/bin/fvm"
if [ -f "$HOME/fvm/bin/src/dart" ]; then
chmod +x "$HOME/fvm/bin/src/dart"
fi
# Prove the launcher actually runs before anything depends on it.
"$HOME/fvm/bin/fvm" --version
echo "$HOME/fvm/bin" >> $GITHUB_PATH
- name: Check Flutter version
shell: bash
run: make fvm-check
- name: Get dependencies
shell: bash
run: make deps
# build_runner's incremental cache — RESTORE ONLY. PR jobs never save (a sha-keyed save per push would blow the 10GB repo cache quota and evict the FVM/pub/cargo caches); only the cache-warmer workflow saves, on develop pushes, so all PRs restore develop's latest warm snapshot.
# ALL gitignored generated source files are cached alongside .dart_tool/build so the restored state is self-consistent (outputs present + asset graph present); build_runner hashes inputs itself and regenerates what changed.
# The suffix list MUST cover every gitignored to-source output: build_runner trusts .dart_tool/build and will NOT regenerate an output whose file is missing from disk (it reports "N skipped"), so a suffix left out here is silently absent after restore and breaks the build — that is how the missing assets.gen.dart (flutter_gen, *.gen.dart ≠ *.g.dart) incident happened.
# *.gr.dart / *.config.dart match nothing today but are pre-listed to mirror the format-filter regex (makefile format-check), so adding auto_route/injectable later cannot reproduce the incident; *.steps.dart is deliberately NOT cached — drift schema snapshots are git-tracked, and restoring a tracked file would overwrite the checkout (same reason main.directories.g.dart is excluded below).
# Arch is in the key defensively: the build cache holds kernel/asset hashes we don't want shared across arches.
# The key embeds hashFiles of this action and the warmer workflow, so any edit to either file self-busts the cache instead of restoring a stale pre-edit snapshot — no manual version token to bump (this replaced the short-lived -v2- token).
# Keep path + key in sync with the save step in cache-warmer.yml.
- name: Restore build_runner cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
.dart_tool/build
**/*.g.dart
**/*.freezed.dart
**/*.mocks.dart
**/*.gen.dart
**/*.gr.dart
**/*.config.dart
!packages/bull_ui_catalogue/lib/main.directories.g.dart
key: buildrunner-${{ hashFiles('.github/actions/flutter-setup/action.yml', '.github/workflows/cache-warmer.yml') }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pubspec.lock') }}-${{ github.sha }}
restore-keys: buildrunner-${{ hashFiles('.github/actions/flutter-setup/action.yml', '.github/workflows/cache-warmer.yml') }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pubspec.lock') }}-
- name: Generate code (build_runner)
shell: bash
run: make build-runner
- name: Generate translations
shell: bash
run: make translations
- name: Disk telemetry (for trimming free-disk later)
shell: bash
run: df -h /