Skip to content

Commit 889d193

Browse files
committed
refactor: use diff to only run commands for changes
1 parent 3c51614 commit 889d193

File tree

10 files changed

+93
-141
lines changed

10 files changed

+93
-141
lines changed

.github/workflows/legacy_version_analyze.yml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@ on:
99
push:
1010
branches:
1111
- master
12-
paths:
13-
- 'packages/**'
14-
- '.github/workflows/legacy_version_analyze.yml'
1512
pull_request:
1613
branches:
1714
- master
18-
paths:
19-
- 'packages/**'
20-
- '.github/workflows/legacy_version_analyze.yml'
2115

2216
concurrency:
2317
group: ${{ github.workflow }}-${{ github.ref }}
@@ -34,38 +28,26 @@ jobs:
3428
if: github.event.pull_request.draft == false
3529
runs-on: ubuntu-latest
3630
steps:
37-
- name: "Git Checkout"
31+
- name: 📚 Git Checkout
3832
uses: actions/checkout@v4
3933
with:
4034
fetch-depth: 0
4135

42-
- name: "Install Flutter"
36+
- name: 🎯 Setup Flutter
4337
uses: subosito/flutter-action@v2
4438
with:
45-
flutter-version: ${{ env.flutter_version }}
46-
channel: stable
4739
cache: true
40+
channel: stable
41+
flutter-version: ${{ env.flutter_version }}
4842
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
4943

50-
- name: "Install Tools"
44+
- name: 📦 Install Tools
5145
run: flutter pub global activate melos
5246

53-
- name: "Bootstrap Workspace"
54-
run: melos bootstrap --verbose
55-
56-
# Only analyze lib/; non-client code doesn't need to work on
57-
# all supported legacy version.
58-
- name: "Stream Chat Analyze"
59-
run: cd packages/stream_chat/lib && dart analyze --fatal-infos .
60-
61-
- name: "Stream Chat Flutter Core Analyze"
62-
run: cd packages/stream_chat_flutter_core/lib && dart analyze --fatal-infos .
63-
64-
- name: "Stream Chat Flutter Analyze"
65-
run: cd packages/stream_chat_flutter/lib && dart analyze --fatal-infos .
66-
67-
- name: "Stream Chat Persistence Analyze"
68-
run: cd packages/stream_chat_persistence/lib && dart analyze --fatal-infos .
47+
- name: ⚙️ Bootstrap Workspace
48+
run: melos bootstrap
6949

70-
- name: "Stream Chat Localizations Analyze"
71-
run: cd packages/stream_chat_localizations/lib && dart analyze --fatal-infos .
50+
- name: 🕵️ Analyze
51+
# Only analyze lib/; non-client code doesn't need to work on
52+
# all supported legacy version.
53+
run: melos exec -c 1 --diff=origin/master...HEAD --include-dependents -- "dart analyze lib --fatal-infos"

.github/workflows/pr_title.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
doc
2727
repo
2828
localization
29+
sample_app
2930
requireScope: true
3031
env:
3132
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 52 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
name: stream_flutter_workflow
22

33
env:
4-
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
4+
# Note: The versions below should be manually updated after a new major
5+
# version comes out.
56
flutter_version: "3.x"
67

78
on:
89
pull_request:
9-
paths:
10-
- 'packages/**'
11-
- '.github/workflows/stream_flutter_workflow.yml'
1210
types:
1311
- opened
1412
- reopened
@@ -23,127 +21,102 @@ concurrency:
2321
cancel-in-progress: true
2422

2523
jobs:
26-
analyze:
27-
timeout-minutes: 15
28-
if: github.event.pull_request.draft == false
29-
runs-on: ubuntu-latest
30-
steps:
31-
- name: "Git Checkout"
32-
uses: actions/checkout@v4
33-
with:
34-
fetch-depth: 0
35-
- name: "Install Flutter"
36-
uses: subosito/flutter-action@v2
37-
with:
38-
flutter-version: ${{ env.flutter_version }}
39-
channel: stable
40-
cache: true
41-
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
42-
- name: "Install Tools"
43-
run: |
44-
flutter pub global activate melos
45-
- name: "Bootstrap Workspace"
46-
run: melos bootstrap --verbose
47-
- name: "Dart Analyze"
48-
run: |
49-
melos run analyze
50-
- name: "Pub Check"
51-
if: github.base_ref == 'master'
52-
run: |
53-
melos run lint:pub
54-
55-
format:
24+
lint:
5625
runs-on: ubuntu-latest
57-
if: github.event.pull_request.draft == false
5826
timeout-minutes: 15
5927
steps:
60-
- name: "Git Checkout"
28+
- name: 📚 Git Checkout
6129
uses: actions/checkout@v4
6230
with:
6331
fetch-depth: 0
64-
- name: "Install Flutter"
32+
33+
- name: 🎯 Setup Flutter
6534
uses: subosito/flutter-action@v2
6635
with:
67-
flutter-version: ${{ env.flutter_version }}
68-
channel: stable
6936
cache: true
37+
channel: stable
38+
flutter-version: ${{ env.flutter_version }}
7039
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
71-
- name: "Install Tools"
72-
run: |
73-
flutter pub global activate melos
74-
- name: "Bootstrap Workspace"
40+
41+
- name: 📦 Install Tools
42+
run: flutter pub global activate melos
43+
44+
- name: ⚙️ Bootstrap Workspace
7545
run: melos bootstrap
76-
- name: "Melos Format"
77-
run: melos run format
78-
- name: "Validate Formatting"
79-
run: |
80-
./.github/workflows/scripts/validate-formatting.sh
46+
47+
- name: ✨ Check Formatting
48+
run: melos run format:changes
49+
50+
- name: 🕵️ Analyze
51+
run: melos run analyze:changes
52+
53+
- if: github.base_ref == 'master'
54+
name: 🚀 Pub Check
55+
run: melos run publish:dry-run:changes
8156

8257
test:
8358
runs-on: ubuntu-latest
84-
if: github.event.pull_request.draft == false
8559
timeout-minutes: 30
8660
steps:
87-
- name: "Git Checkout"
61+
- name: 📚 Git Checkout
8862
uses: actions/checkout@v4
8963
with:
9064
fetch-depth: 0
91-
- name: "Install Flutter"
65+
66+
- name: 🎯 Setup Flutter
9267
uses: subosito/flutter-action@v2
9368
with:
94-
flutter-version: ${{ env.flutter_version }}
95-
channel: stable
9669
cache: true
70+
channel: stable
71+
flutter-version: ${{ env.flutter_version }}
9772
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
98-
# This step is needed due to https://github.com/actions/runner-images/issues/11279
99-
- name: Install SQLite3
100-
run: sudo apt-get update && sudo apt-get install -y sqlite3 libsqlite3-dev
101-
- name: "Install Tools"
73+
74+
- name: 📦 Install Tools
10275
run: |
10376
flutter pub global activate melos
10477
flutter pub global activate remove_from_coverage
105-
- name: "Bootstrap Workspace"
78+
79+
- name: ⚙️ Bootstrap Workspace
10680
run: melos bootstrap
107-
- name: "Flutter Test"
108-
run: melos run test:all
109-
- name: "Collect Coverage"
81+
82+
- name: 🧪 Run Tests
83+
run: melos run test:packages:changed
84+
85+
- name: 📊 Collect Coverage
11086
run: melos run coverage:ignore-file --no-select
111-
- name: "Upload Coverage"
112-
uses: codecov/codecov-action@v5
113-
with:
114-
token: ${{secrets.CODECOV_TOKEN}}
115-
files: packages/*/coverage/lcov.info
116-
- name: "Stream Chat Coverage Check"
87+
88+
- name: ✅ Stream Chat Coverage Check
11789
uses: VeryGoodOpenSource/very_good_coverage@v3.0.0
11890
with:
11991
path: packages/stream_chat/coverage/lcov.info
12092
min_coverage: 70
121-
- name: "Stream Chat Localizations Coverage Check"
93+
94+
- name: ✅ Stream Chat Localizations Coverage Check
12295
uses: VeryGoodOpenSource/very_good_coverage@v3.0.0
12396
with:
12497
path: packages/stream_chat_localizations/coverage/lcov.info
12598
min_coverage: 100
126-
- name: "Stream Chat Persistence Coverage Check"
99+
100+
- name: ✅ Stream Chat Persistence Coverage Check
127101
uses: VeryGoodOpenSource/very_good_coverage@v3.0.0
128102
with:
129103
path: packages/stream_chat_persistence/coverage/lcov.info
130104
min_coverage: 95
131-
- name: "Stream Chat Flutter Core Coverage Check"
105+
106+
- name: ✅ Stream Chat Flutter Core Coverage Check
132107
uses: VeryGoodOpenSource/very_good_coverage@v3.0.0
133108
with:
134109
path: packages/stream_chat_flutter_core/coverage/lcov.info
135110
min_coverage: 30
136-
- name: "Stream Chat Flutter Coverage Check"
111+
112+
- name: ✅ Stream Chat Flutter Coverage Check
137113
uses: VeryGoodOpenSource/very_good_coverage@v3.0.0
138114
with:
139115
path: packages/stream_chat_flutter/coverage/lcov.info
140116
min_coverage: 44
141117

142-
draft-build:
143-
runs-on: ubuntu-latest
144-
if: github.event.pull_request.draft == true
145-
timeout-minutes: 1
146-
147-
steps:
148-
- name: Run a one-line script
149-
run: echo Draft PR, you are good.
118+
- name: 📁 Upload coverage to Codecov
119+
uses: codecov/codecov-action@v5
120+
with:
121+
token: ${{secrets.CODECOV_TOKEN}}
122+
files: packages/*/coverage/lcov.info

melos.yaml

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -117,38 +117,31 @@ scripts:
117117
run: melos run analyze && melos run format
118118
description: Run all static analysis checks
119119

120-
analyze:all:
121-
run: melos run analyze && melos run metrics
122-
description: Run all
123-
124120
analyze:
125-
run: |
126-
melos exec -c 5 --ignore="*example*" -- \
127-
dart analyze --fatal-infos .
128-
description: |
129-
Run `dart analyze` in all packages.
130-
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
121+
run: melos exec -c 5 --ignore="*example*" -- "dart analyze --fatal-infos ."
122+
description: Run `dart analyze` in all packages.
123+
124+
analyze:changes:
125+
run: melos exec -c 1 --diff=origin/master...HEAD --include-dependents -- "dart analyze --fatal-infos ."
126+
description: Run `dart analyze` in all changed packages.
131127

132128
format:
133129
run: dart format --set-exit-if-changed .
134-
description: |
135-
Run `dart format --set-exit-if-changed .` in all packages.
130+
description: Run `dart format --set-exit-if-changed .` in all packages.
136131

137-
metrics:
138-
run: |
139-
melos exec -c 1 --ignore="*example*" -- \
140-
flutter pub run dart_code_metrics:metrics analyze lib
141-
description: |
142-
Run `dart_code_metrics` in all packages.
143-
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
132+
format:changes:
133+
run: melos exec -c 1 --diff=origin/master...HEAD --include-dependents -- "dart format --set-exit-if-changed ."
134+
description: Run `dart format` in all changed packages.
144135

145136
lint:pub:
146-
run: |
147-
melos exec -c 5 --no-private --ignore="*example*" -- \
148-
flutter pub publish --dry-run
149-
description: |
150-
Run `pub publish --dry-run` in all packages.
151-
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
137+
run: melos exec -c 5 --no-private --ignore="*example*" -- "flutter pub publish --dry-run"
138+
description: Run `pub publish --dry-run` in all packages.
139+
140+
publish:dry-run:changes:
141+
run: >-
142+
melos exec -c 1 --diff=origin/master...HEAD --no-private --include-dependents --
143+
"[ -f pubspec.yaml ] && ! grep -q 'publish_to: none' pubspec.yaml && flutter pub publish --dry-run || echo 'Package not publishable, skipping'"
144+
description: Run `flutter pub publish --dry-run` in all changed packages.
152145

153146
generate:all:
154147
run: melos run generate:dart && melos run generate:flutter
@@ -180,6 +173,10 @@ scripts:
180173
flutter: true
181174
dirExists: test
182175

176+
test:changes:
177+
run: melos exec -c 1 --diff=origin/master...HEAD --include-dependents -- "[ -d test ] && flutter test --no-pub --coverage || echo 'No tests found, skipping'"
178+
description: Run `flutter test` in all changed packages.
179+
183180
update:goldens:
184181
run: melos exec -c 1 --depends-on="alchemist" -- "flutter test --tags golden --update-goldens"
185182
description: Update golden files for all packages in this project.
@@ -191,8 +188,7 @@ scripts:
191188
flutter: true
192189

193190
coverage:ignore-file:
194-
run: |
195-
melos exec -c 5 --fail-fast -- "\$MELOS_ROOT_PATH/.github/workflows/scripts/remove-from-coverage.sh"
191+
run: melos exec -c 1 --fail-fast -- "\$MELOS_ROOT_PATH/.github/workflows/scripts/remove-from-coverage.sh"
196192
description: Removes all the ignored files from the coverage report.
197193
packageFilters:
198194
dirExists: coverage

packages/stream_chat/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: stream_chat_example
22
description: A new Flutter project.
33

4-
publish_to: "none"
4+
publish_to: none
55
version: 1.0.0+1
66

77
# Note: The environment configuration and dependency versions are managed by Melos.

packages/stream_chat_flutter/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: stream_chat_flutter_example
22
description: A new Flutter project.
3-
publish_to: 'none'
3+
publish_to: none
44
version: 1.0.0+1
55

66
# Note: The environment configuration and dependency versions are managed by Melos.

packages/stream_chat_flutter_core/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: stream_chat_flutter_core_example
22
description: Example app for testing stream_chat_flutter_core
3-
publish_to: 'none'
3+
publish_to: none
44
version: 1.0.0+1
55

66
# Note: The environment configuration and dependency versions are managed by Melos.

packages/stream_chat_localizations/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: stream_chat_localizations_example
22
description: A new Flutter project.
33

4-
publish_to: 'none'
4+
publish_to: none
55
version: 1.0.0+1
66

77
# Note: The environment configuration and dependency versions are managed by Melos.

packages/stream_chat_persistence/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: stream_chat_persistence_example
22
description: A new Flutter project.
3-
publish_to: 'none'
3+
publish_to: none
44
version: 1.0.0+1
55

66
# Note: The environment configuration and dependency versions are managed by Melos.

sample_app/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sample_app
22
description: A new Flutter project.
3-
publish_to: "none"
3+
publish_to: none
44
version: 2.2.0
55

66
# Note: The environment configuration and dependency versions are managed by Melos.

0 commit comments

Comments
 (0)