3333 channel : " master"
3434 flutter-version : " ${{ env.FLUTTER_VERSION }}"
3535 cache : true
36+ cache-key : flutter-${{ runner.os }}-${{ env.FLUTTER_VERSION }}
37+ pub-cache-key : flutter-pub-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}
3638
3739 - name : Install demo dependencies
3840 run : flutter pub get
5759 channel : " master"
5860 flutter-version : " ${{ env.FLUTTER_VERSION }}"
5961 cache : true
62+ cache-key : flutter-${{ runner.os }}-${{ env.FLUTTER_VERSION }}
63+ pub-cache-key : flutter-pub-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}
6064
6165 - name : Install package dependencies
6266 run : flutter pub get
@@ -147,6 +151,8 @@ jobs:
147151 channel : " master"
148152 flutter-version : " ${{ env.FLUTTER_VERSION }}"
149153 cache : true
154+ cache-key : flutter-${{ runner.os }}-${{ env.FLUTTER_VERSION }}
155+ pub-cache-key : flutter-pub-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}
150156
151157 # In order for flutter_js to be testable on linux platform in widget tests, we need to first build our app for linux to compile the native libraries, which are then loaded during widget tests. This is a bit of a workaround but allows us to run widget tests for flutter_js on CI.
152158 - name : Install Linux dependencies
@@ -237,6 +243,9 @@ jobs:
237243 channel : " master"
238244 flutter-version : " ${{ env.FLUTTER_VERSION }}"
239245 cache : true
246+ cache-key : flutter-${{ runner.os }}-${{ env.FLUTTER_VERSION }}
247+ pub-cache-key : flutter-pub-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}
248+
240249 - name : Install package dependencies
241250 run : flutter pub get
242251
@@ -252,6 +261,20 @@ jobs:
252261 # working-directory: .
253262 # run: make test-integration
254263
264+ - name : Cache Flutter build artifacts (iOS)
265+ uses : actions/cache@v4
266+ with :
267+ path : |
268+ build
269+ .dart_tool
270+ demo/build
271+ demo/.dart_tool
272+ ~/Library/Developer/Xcode/DerivedData
273+ key : flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-${{ github.sha }}
274+ restore-keys : |
275+ flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-
276+ flutter-build-${{ github.job }}-${{ runner.os }}-
277+
255278 - name : Run integration tests (iOS) with coverage
256279 working-directory : .
257280 run : make test-integration
@@ -299,7 +322,7 @@ jobs:
299322 sudo udevadm trigger --name-match=kvm
300323
301324 - name : Checkout code
302- uses : actions/checkout@v2
325+ uses : actions/checkout@v4
303326
304327 - name : Setup Java
305328 uses : actions/setup-java@v2
@@ -313,11 +336,12 @@ jobs:
313336 channel : " master"
314337 flutter-version : " ${{ env.FLUTTER_VERSION }}"
315338 cache : true
339+ cache-key : flutter-${{ runner.os }}-${{ env.FLUTTER_VERSION }}
340+ pub-cache-key : flutter-pub-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}
341+
342+ - name : Setup Gradle cache
343+ uses : gradle/actions/setup-gradle@v4
316344
317- - name : Install Android SDK
318- uses : malinskiy/action-android/install-sdk@release/0.1.2
319- - run : echo $ANDROID_HOME
320- - run : sdkmanager --install "build-tools;30.0.3"
321345 - name : Install package dependencies
322346 run : flutter pub get
323347
@@ -328,23 +352,52 @@ jobs:
328352 run : |
329353 dart pub global activate junitreport
330354 echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
331- # - name: Run integration tests (Android)
332- # uses: malinskiy/action-android/emulator-run-cmd@release/0.1.2
333- # with:
334- # cmd: make test-integration
335- # api: 31
336- # cmdOptions: -no-snapshot-save -noaudio -no-boot-anim -cores 2 -memory 3072 -no-window
337- # tag: google_apis
338- # abi: x86_64
355+ - name : AVD cache
356+ uses : actions/cache@v4
357+ id : avd-cache
358+ with :
359+ path : |
360+ ~/.android/avd/*
361+ ~/.android/adb*
362+ key : avd-api-31
363+
364+ - name : Cache Flutter build artifacts (Android)
365+ uses : actions/cache@v4
366+ with :
367+ path : |
368+ build
369+ .dart_tool
370+ demo/build
371+ demo/.dart_tool
372+ key : flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-${{ github.sha }}
373+ restore-keys : |
374+ flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-
375+ flutter-build-${{ github.job }}-${{ runner.os }}-
376+
377+ - name : Create AVD snapshot for caching
378+ if : steps.avd-cache.outputs.cache-hit != 'true'
379+ uses : reactivecircus/android-emulator-runner@v2
380+ with :
381+ api-level : 31
382+ target : google_apis
383+ arch : x86_64
384+ profile : pixel_7_pro
385+ force-avd-creation : false
386+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
387+ disable-animations : false
388+ script : echo "Generated AVD snapshot for caching."
339389
340390 - name : Run integration tests (Android)
341- uses : malinskiy/action- android/ emulator-run-cmd@release/0.1.2
391+ uses : reactivecircus/ android- emulator-runner@v2
342392 with :
343- cmd : make test-integration
344- api : 31
345- cmdOptions : -no-snapshot-save -noaudio -no-boot-anim -cores 2 -memory 3072 -no-window
346- tag : google_apis
347- abi : x86_64
393+ api-level : 31
394+ target : google_apis
395+ arch : x86_64
396+ profile : pixel_7_pro
397+ force-avd-creation : false
398+ emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
399+ disable-animations : true
400+ script : make test-integration
348401
349402 - name : Upload Integration Test Coverage (Android)
350403 uses : actions/upload-artifact@v4
@@ -394,6 +447,8 @@ jobs:
394447 channel : " master"
395448 flutter-version : " ${{ env.FLUTTER_VERSION }}"
396449 cache : true
450+ cache-key : flutter-${{ runner.os }}-${{ env.FLUTTER_VERSION }}
451+ pub-cache-key : flutter-pub-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}
397452
398453 # - name: Install package dependencies
399454 # run: flutter pub get
@@ -434,6 +489,19 @@ jobs:
434489 sudo mv /opt/google/chrome/chrome /opt/google/chrome/chrome.bak || true
435490 sudo ln -sf "${{ steps.setup-chrome.outputs.chrome-path }}" /opt/google/chrome/chrome
436491
492+ - name : Cache Flutter build artifacts (Web Tests)
493+ uses : actions/cache@v4
494+ with :
495+ path : |
496+ build
497+ .dart_tool
498+ demo/build
499+ demo/.dart_tool
500+ key : flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-${{ github.sha }}
501+ restore-keys : |
502+ flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-
503+ flutter-build-${{ github.job }}-${{ runner.os }}-
504+
437505 # - name: Install junitreport converter
438506 # run: |
439507 # dart pub global activate junitreport
@@ -510,6 +578,8 @@ jobs:
510578 channel : " master"
511579 flutter-version : " ${{ env.FLUTTER_VERSION }}"
512580 cache : true
581+ cache-key : flutter-${{ runner.os }}-${{ env.FLUTTER_VERSION }}
582+ pub-cache-key : flutter-pub-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}
513583
514584 - name : Setup Pages
515585 id : pages
@@ -522,6 +592,20 @@ jobs:
522592 run : flutter pub get
523593 working-directory : ${{ env.PATH_TO_DEMO }}
524594
595+ - name : Cache Flutter build artifacts (Web Build)
596+ if : always()
597+ uses : actions/cache@v4
598+ with :
599+ path : |
600+ build
601+ .dart_tool
602+ demo/build
603+ demo/.dart_tool
604+ key : flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-${{ github.sha }}
605+ restore-keys : |
606+ flutter-build-${{ github.job }}-${{ runner.os }}-${{ hashFiles('pubspec.lock', 'demo/pubspec.lock') }}-
607+ flutter-build-${{ github.job }}-${{ runner.os }}-
608+
525609 - name : Build app for web
526610 run : flutter build web --base-href "${{ steps.pages.outputs.base_path }}/"
527611 working-directory : ${{ env.PATH_TO_DEMO }}
0 commit comments