Skip to content

Commit 6c47611

Browse files
author
Mikhail Orlov
committed
fix guidelines and ci
1 parent a0d16a3 commit 6c47611

11 files changed

Lines changed: 106 additions & 42 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- name: Get dependencies
3737
run: flutter pub get
3838

39+
- name: Check no outdated deps message
40+
run: bash script/check_no_outdated_deps.sh
41+
3942
- name: Generate l10n
4043
run: flutter gen-l10n
4144

@@ -65,7 +68,7 @@ jobs:
6568
run: flutter gen-l10n
6669

6770
- name: Run unit tests
68-
run: flutter test test/domain test/storage test/router test/l10n
71+
run: flutter test test/domain test/storage test/router test/l10n test/deps_no_outdated_message_test.dart
6972

7073
test-widget:
7174
name: Widget tests

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ After dependency upgrades (e.g. `flutter_timezone`), run at least `flutter pub g
121121
3. Ensure **all CI jobs pass**, including **Build Android APK**. If you cannot build APK locally, push and check the PR pipeline. Build APK is the only gate for Android config (desugaring, etc.).
122122
4. Do not downgrade plugins with native code to versions that use the old Flutter embedding (e.g. `flutter_timezone` must stay **^5.0.0** or higher; see [docs/DEPENDENCIES.md](docs/DEPENDENCIES.md)).
123123

124-
**"N packages have newer versions" during build:** Run `make outdated` (or `flutter pub outdated`) to see which dependencies can be updated. Prefer updating direct dependencies and following the upgrade checklist above so the message stays minimal. See [docs/DEPENDENCIES.md §6](docs/DEPENDENCIES.md) for details.
124+
**"N packages have newer versions" during build:** A **test** (`test/deps_no_outdated_message_test.dart`) and a **CI step** (`script/check_no_outdated_deps.sh`) fail when this message appears. To fix: run `make outdated` (or `flutter pub outdated`), update `pubspec.yaml` or `dependency_overrides`, then `make check-deps` or `make test`. See [docs/DEPENDENCIES.md §6](docs/DEPENDENCIES.md).
125125

126126
---
127127

@@ -136,6 +136,7 @@ What the guidelines require is enforced as follows. **If it can be automated, it
136136
| Unit tests pass | **CI Unit tests**`flutter test test/domain test/storage test/router test/l10n`. |
137137
| Widget tests pass | **CI Widget tests**`flutter test test/screens test/helpers`. |
138138
| Web builds | **CI Build Web**`flutter build web --release`. |
139+
| No "packages have newer versions" message after pub get | **CI Lint**`script/check_no_outdated_deps.sh`. **Unit tests**`test/deps_no_outdated_message_test.dart`. Locally: `make check-deps`. |
139140
| Android APK builds (incl. Gradle/native config) | **CI Build Android APK**`flutter build apk --release`. Catches missing desugaring, wrong embedding, etc. |
140141
| New/changed behavior has tests | Process: add or update tests in the same PR; CI runs the full test suite. |
141142
| Dependency upgrades: native config applied | **CI Build Android APK** fails if e.g. desugaring is missing. No separate test; the build is the gate. |

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Take Your Meds — Make targets
22
# Requires: Flutter SDK on PATH (for run/build/test), Docker (for run-chrome-docker).
33

4-
.PHONY: help run run-chrome build-android build-ios run-chrome-docker test test-unit test-widget test-integration clean deps gen-l10n analyze format check outdated
4+
.PHONY: help run run-chrome build-android build-ios run-chrome-docker test test-unit test-widget test-integration clean deps gen-l10n analyze format check check-deps outdated
55

66
help:
77
@echo "Take Your Meds — targets:"
@@ -19,6 +19,7 @@ help:
1919
@echo " analyze Run static analysis (flutter analyze lib test)"
2020
@echo " format Format lib and test (dart format). Run before every commit."
2121
@echo " check Same as CI Lint job: analyze + format check. Fails if not formatted."
22+
@echo " check-deps Fail if 'flutter pub get' reports packages with newer versions incompatible with constraints."
2223
@echo " outdated List outdated packages (flutter pub outdated). Run periodically to keep deps current."
2324
@echo " clean Clean build artifacts"
2425

@@ -41,7 +42,7 @@ test:
4142
flutter test
4243

4344
test-unit:
44-
flutter test test/domain test/storage test/router test/l10n
45+
flutter test test/domain test/storage test/router test/l10n test/deps_no_outdated_message_test.dart
4546

4647
test-widget:
4748
flutter test test/screens test/helpers
@@ -65,6 +66,9 @@ check:
6566
flutter analyze lib test
6667
dart format --set-exit-if-changed lib test
6768

69+
check-deps:
70+
bash script/check_no_outdated_deps.sh
71+
6872
outdated:
6973
flutter pub outdated
7074

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Key paths:
6969
| `make analyze` | Run static analysis (lib + test) |
7070
| `make format` | Format `lib` and `test` (run before every commit; CI checks this) |
7171
| `make check` | Same as CI Lint: analyze + format check |
72+
| `make check-deps` | Fail if `flutter pub get` reports "packages have newer versions incompatible with constraints" (same as CI; see test `deps_no_outdated_message_test.dart`) |
7273
| `make outdated` | List outdated packages; run periodically to keep deps current (see docs/DEPENDENCIES.md) |
7374
| `make clean` | Clean build artifacts |
7475

docker/docker-compose.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/DEPENDENCIES.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ Summary: **Dependency upgrades that touch native code must be validated by a ful
9292

9393
When you run `flutter pub get` or build the app, you may see: *"N packages have newer versions incompatible with dependency constraints. Try \`flutter pub outdated\` for more information."*
9494

95-
**What to do:**
95+
**Enforcement:** A **test** and a **CI step** fail when this message appears, so every developer and CI see the failure until it is fixed:
9696

97-
1. **Run `flutter pub outdated`** (or `make outdated` if available). It lists direct and transitive dependencies and shows which can be upgraded within current constraints ("Upgradable") or need a constraint change ("Resolvable" / "Latest").
98-
2. **Prioritize direct dependencies.** Update `pubspec.yaml` constraints for our direct dependencies so they resolve to current, compatible versions. Follow the upgrade checklist in §3 and the native-plugin rules in §2.
99-
3. **Transitive dependencies** (e.g. `characters`, `meta`, `matcher`) are pulled in by the SDK or other packages. We do not list them in `pubspec.yaml`; they are upgraded when we upgrade Flutter or the direct packages. Do not add overrides unless necessary to fix a security or build issue.
100-
4. **After any dependency change:** run `make format`, `make check`, `make test`, and ensure CI (including Build Android APK) passes.
97+
- **Test:** `test/deps_no_outdated_message_test.dart` runs `flutter pub get` and fails if the output contains that message. It is run with unit tests (`make test-unit` or `flutter test test/... test/deps_no_outdated_message_test.dart`).
98+
- **CI:** The Lint job runs `script/check_no_outdated_deps.sh` after `flutter pub get`; the script exits 1 if the message is present.
99+
- **Locally:** Run `make check-deps` to run the same check without running the full test suite.
101100

102-
This keeps the "N packages have newer versions" message to a minimum and avoids accumulating technical debt. Prefer upgrading one or a few related packages per change, with tests and CI green.
101+
**What to do when the test or check fails:**
102+
103+
1. **Run `flutter pub outdated`** (or `make outdated`). It lists which packages have newer versions and whether they are "Upgradable" or need a constraint change.
104+
2. **Update direct dependencies** in `pubspec.yaml` to compatible newer versions where possible. Follow the upgrade checklist in §4.
105+
3. **Transitive dependencies** that still show "incompatible with constraints" can be pinned to a newer version via **dependency_overrides** in `pubspec.yaml` (see current overrides in this project for characters, matcher, meta, etc.). Use overrides sparingly and only for transitive deps we cannot fix by upgrading direct deps.
106+
4. After changes: run `make format`, `make check`, `make test` (or at least `make check-deps`), and ensure CI passes.
107+
108+
This keeps the "N packages have newer versions" message gone and ensures the test and CI stay green.

pubspec.lock

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ packages:
2626
source: hosted
2727
version: "2.1.2"
2828
characters:
29-
dependency: transitive
29+
dependency: "direct overridden"
3030
description:
3131
name: characters
32-
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
32+
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
3333
url: "https://pub.dev"
3434
source: hosted
35-
version: "1.4.0"
35+
version: "1.4.1"
3636
clock:
3737
dependency: transitive
3838
description:
@@ -293,29 +293,29 @@ packages:
293293
source: hosted
294294
version: "1.3.0"
295295
matcher:
296-
dependency: transitive
296+
dependency: "direct overridden"
297297
description:
298298
name: matcher
299-
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
299+
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
300300
url: "https://pub.dev"
301301
source: hosted
302-
version: "0.12.17"
302+
version: "0.12.18"
303303
material_color_utilities:
304-
dependency: transitive
304+
dependency: "direct overridden"
305305
description:
306306
name: material_color_utilities
307-
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
307+
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
308308
url: "https://pub.dev"
309309
source: hosted
310-
version: "0.11.1"
310+
version: "0.13.0"
311311
meta:
312-
dependency: transitive
312+
dependency: "direct overridden"
313313
description:
314314
name: meta
315-
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
315+
sha256: "9f29b9bcc8ee287b1a31e0d01be0eae99a930dbffdaecf04b3f3d82a969f296f"
316316
url: "https://pub.dev"
317317
source: hosted
318-
version: "1.17.0"
318+
version: "1.18.1"
319319
mocktail:
320320
dependency: "direct dev"
321321
description:
@@ -341,13 +341,13 @@ packages:
341341
source: hosted
342342
version: "1.0.0"
343343
objective_c:
344-
dependency: transitive
344+
dependency: "direct overridden"
345345
description:
346346
name: objective_c
347-
sha256: "983c7fa1501f6dcc0cb7af4e42072e9993cb28d73604d25ebf4dab08165d997e"
347+
sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52"
348348
url: "https://pub.dev"
349349
source: hosted
350-
version: "9.2.5"
350+
version: "9.3.0"
351351
path:
352352
dependency: "direct main"
353353
description:
@@ -610,21 +610,21 @@ packages:
610610
source: hosted
611611
version: "1.2.2"
612612
test_api:
613-
dependency: transitive
613+
dependency: "direct overridden"
614614
description:
615615
name: test_api
616-
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
616+
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
617617
url: "https://pub.dev"
618618
source: hosted
619-
version: "0.7.7"
619+
version: "0.7.9"
620620
timezone:
621621
dependency: "direct main"
622622
description:
623623
name: timezone
624-
sha256: dd14a3b83cfd7cb19e7888f1cbc20f258b8d71b54c06f79ac585f14093a287d1
624+
sha256: "784a5e34d2eb62e1326f24d6f600aaaee452eb8ca8ef2f384a59244e292d158b"
625625
url: "https://pub.dev"
626626
source: hosted
627-
version: "0.10.1"
627+
version: "0.11.0"
628628
typed_data:
629629
dependency: transitive
630630
description:

pubspec.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ dev_dependencies:
5151
flutter_lints: ^6.0.0
5252
mocktail: ^1.0.4
5353

54+
# Keep transitive deps at latest compatible to avoid "packages have newer versions"
55+
# message. See script/check_no_outdated_deps.sh and test/deps_no_outdated_message_test.dart.
56+
dependency_overrides:
57+
characters: ^1.4.1
58+
matcher: ^0.12.18
59+
material_color_utilities: ^0.13.0
60+
meta: ^1.18.0
61+
objective_c: ^9.3.0
62+
test_api: ^0.7.9
63+
timezone: ^0.11.0
64+
5465
# The following section is specific to Flutter packages.
5566
flutter:
5667
generate: true

script/check_no_outdated_deps.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
# Fail if `flutter pub get` prints the "packages have newer versions incompatible
3+
# with dependency constraints" message. Used in CI and locally (make check-deps)
4+
# so that developers and bots see a clear failure until dependencies are updated.
5+
set -e
6+
7+
out=$(flutter pub get 2>&1) || true
8+
echo "$out"
9+
10+
if echo "$out" | grep -q "packages have newer versions incompatible with dependency constraints"; then
11+
echo ""
12+
echo "FAIL: flutter pub get reported packages with newer versions incompatible with constraints."
13+
echo "Run: make outdated (or flutter pub outdated)"
14+
echo "Then update pubspec.yaml / dependency_overrides and see docs/DEPENDENCIES.md"
15+
exit 1
16+
fi
17+
exit 0

test/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ This file describes what each test file and each test does. Use it for QA and on
3838
- **notification action labels** — The strings for "OK", "Skip", "Postpone 10 min", "Postpone 30 min" come from the app's localization (ARB), not hardcoded.
3939
- **notification body** — The reminder body text ("Time to take your medication") also comes from localization.
4040

41+
### `deps_no_outdated_message_test.dart` — No "packages have newer versions" message
42+
43+
- **pub get does not report packages with newer versions incompatible with constraints** — Runs `flutter pub get` and fails if the output contains the "packages have newer versions incompatible with dependency constraints" message. Ensures developers and CI see a failing test until dependencies are updated (run `make outdated`, update pubspec or dependency_overrides). Also enforced by CI step `script/check_no_outdated_deps.sh` and locally by `make check-deps`.
44+
4145
---
4246

4347
## Widget tests (screens with fake data)

0 commit comments

Comments
 (0)